Skip to Content
Menu
This question has been flagged
1 Reply
1258 Views

hi i wish to add the  Order Ref field in my pos.xml can anyone help me plis ?

Avatar
Discard
Best Answer

Hii pegasuscster@gmail.com,

You can try super call create_from_ui() method from pos and add order_ref. for Example,

Please find Code example in Comment. 

I hope this will help you.

Thanks & Regards,
Email: odoo@aktivsoftware.com
Skype: kalpeshmaheshwari 

Avatar
Discard

@api.model
def create_from_ui(self, orders):
order_ids = super(PosOrder, self).create_from_ui(orders)
for order_id in order_ids:
order_id['order_ref'] = self.sudo().browse([order_id['id']]).name
return order_ids

then after, in js
var _super_order = models.Order.prototype;
models.Order = models.Order.extend({
initialize: function(attr, options) {
_super_order.initialize.apply(this, arguments);
this.order_ref = this.order_ref || "";
},
set_order_name: function(order_ref) {
this.order_ref = order_ref;
this.trigger('change', this);
},
get_order_name: function() {
return this.order_ref;
},
export_for_printing: function() {
var json = _super_order.export_for_printing.apply(this, arguments);
json.order_ref = this.pos.get_order().order_name
return json;
},
});
and overright the _save_to_server function and call set_order_name() in
return this.rpc({
model: 'pos.order',
method: 'create_from_ui',
args: args,
kwargs: { context: this.session.user_context },
}, {
timeout: timeout,
shadow: !options.to_invoice
})
.then(function(server_ids) {
for (var order in order_ids_to_sync) {
var order_id = self.get_order()
for (var server in server_ids) {
order_id.set_order_name(server_ids[server].order_ref)
}
self.db.remove_order(order_ids_to_sync[order]);
self.db.remove_unpaid_order(order_id);
}
self.set('failed', false);
return server_ids;
})
and then after you can put it where you want if in report view.