2

I want to show product default code in pos receipt. Can I inherit or edit in models.js or from other ? Thanks.

export_for_printing: function(){
        return {
            ...
            default_code:    this.get_default_code(),
        };
    },


 get_default_code: function(){
        return this.product.default_code;
    },
Dipen Shah
  • 2,396
  • 2
  • 9
  • 21
Ing
  • 551
  • 7
  • 20
  • there is a jquery template on the point of sale on the static/src/XML file where the receipt template is there. you need to extend that and add your custom code it will be on the receipt. – Dipen Shah Jan 21 '21 at 11:39
  • @Dipen Shah , I extended the template : OrderReceipt and I added ; to add fields from model product.product or product.template ; I shoud add it in models.js? – Ing Jan 21 '21 at 11:51

1 Answers1

3

Revise the Solution:

To get the product's other field access you need to do customization in the JS & XML template.

JS Code:

odoo.define('ypour_app.your app', function (require) {
"use strict";

var models = require('point_of_sale.models');
var OrderlineSuper = models.Orderline;
models.Orderline = models.Orderline.extend({
   export_for_printing : function() {
        var data = OrderlineSuper.prototype.export_for_printing.call(this);
        // this.get_product() => you can have here all the product data [barcode/default_code/ etc.]
        data.product_default_code = this.get_product().default_code;
        return data;
    }
});

});

XML Code:

<t t-extend="OrderReceipt">
    <t t-jquery="t[t-foreach*='receipt.orderlines']" t-operation="append">
        <b>Default Code </b>: <t t-esc="line.product_default_code"/>
    </t>
</t>
Dipen Shah
  • 2,396
  • 2
  • 9
  • 21