Skip to Content
Menu
This question has been flagged
2 Replies
2789 Views

Hello, 

I want to inherit this table below in POS and add a column.
If you click on Refund Button it will get you to this table.
How do I go about this?

Thanks in advance.


Here is my code. 

class PosSession(models.Model):
_inherit = 'pos.session'

def _loader_params_pos_order(self):
result = super()._loader_params_pos_order()
result['search_params']['fields'].append('name')
return result


Avatar
Discard
Author Best Answer

I found the solution to my question and here is the answer.

/** @odoo-module **/
odoo.define('pos_customizations.models', function(require) {
'use strict';

var {Order, OrderLine} = require('point_of_sale.models');
const Registries = require('point_of_sale.Registries');

const PosSaleOrder = (Order) => class PosSaleOrder extends Order {
constructor() {
super(...arguments);
this.order_ref = this.order_ref || null;
}

export_as_JSON() {
const json = super.export_as_JSON(...arguments);
json.order_ref = this.order_ref;
return json;
}

init_from_JSON(json) {
super.init_from_JSON(...arguments);
this.order_ref = json.order_ref;
}
};

Registries.Model.extend(Order, PosSaleOrder);
});


Avatar
Discard
Best Answer

Hi,

You can refer this blog to add field onto your pos screen
https://www.cybrosys.com/blog/how-to-load-models-fields-in-the-odoo-16-pos


Hope it helps

Avatar
Discard
Author

Hi @Cybrosys Techno Solutions Pvt.Ltd,

I have followed the blog but the field is still not visible.
What am I missing?

Here is my code.

class PosOrder(models.Model):
_inherit = 'pos.order'

order_ref = fields.Char(string='Order Ref', compute="_getOrderRef")

@api.depends('name')
def _getOrderRef(self):
for rec in self:
rec.order_ref = rec.name
print("order_ref--->", rec.order_ref)

class PosSession(models.Model):
_inherit = 'pos.session'

def _pos_ui_pos_order(self):
result = super()._pos_ui_pos_order()
result.append('pos.order')
print("result", result)
return result

def _loader_params_pos_order(self):
return {
'search_params': {
'fields': ['order_ref'],
},
}

def _get_pos_ui_pos_order(self, params):
return self.env['pos.order'].search_read(**params['search_params'])

JS code:
/** @odoo-module **/
import { PosGlobalState } from 'point_of_sale.models';
import Registries from 'point_of_sale.Registries';
const NewPosGlobalState = (PosGlobalState) => class NewPosGlobalState extends PosGlobalState {
async _processData(loadedData) {
await super._processData(...arguments);
this.order_ref = loadedData['pos.order'];
console.log(this.order_ref)
}
}
Registries.Model.extend(PosGlobalState, NewPosGlobalState);

Related Posts Replies Views Activity
1
Feb 25
1752
1
Mar 24
1854
1
Feb 24
1558
1
Feb 24
1986
0
Nov 23
1423