Odoo Technical

Welcome!

This community is for professionals and enthusiasts of our products and services.
Share and discuss the best content and new marketing ideas, build your professional profile and become a better marketer together.

0

Adding new fields to existing model in POS

Avatar
Mohanraj
Avatar
Discard
1 Answer
2
Avatar
Nithyakumari
Best Answer

Existing Model in POS:
First add fields in python. For example, I inherit pos.order and add a new field “custom_field” .

class PosOrderInherit(models.Model):
_inherit = "pos.order"
custom_field = fields.Text(string="Custom Field")

Then loaded in the js file.
odoo.define('custom_module', function (require) {
"use strict";
var screens = require('point_of_sale.screens');
var models = require('point_of_sale.models');
models.load_fields('pos.order', ['custom_field']);
//Add the customization code
});
In Odoo16:
Adding fields in python for example I inherit pos.order and add a new field “custom_field” .
class PosOrderInherit(models.Model):
_inherit = "pos.order"
custom_field = fields.Text(string="Custom Field")
Then loaded in a python file.
def _loader_params_pos_order(self):
result = super()._loader_params_pos_order()
result['search_params']['fields'].extend(['custom_field'])
return result


Avatar
Discard