简体   繁体   中英

Odoo Javascript, how can I access to the value of this object?

So I'm workin in POS module in Odoo 14, I've created a field in 'pos.order' called 'ticket_number' which is related to the id of the record. So if the id is 15, the ticket_number will be 15 too. This field is already charged to the 'pos.order' model:

odoo.define("custom_pos_order.models", function (require) {
"use strict";

    var models = require('point_of_sale.models');

    models.load_fields('pos.order', 'id');
    models.load_fields('pos.order', 'ticket_number');

});

My purpose is to show this new field in the voucher when you get to the last screen: POS 最后一屏

As you can see, in the red box I would like to show this field.

But, as this field is not native, I have to workaround with some Javascript. I have this object in the console, and this object contains the value of the id of the order: JS 对象

So my question is, how can I access to that value in JS code, to assign it to a new variable?

Please use the below line to load fields in a single line instead writing two and more lines for each fields

models.load_fields("pos.order",['id','ticket_number']);

Also mention the field in the below function to get it in the receipt screen

get_receipt_render_env: function() {
    var order = this.pos.get_order();
    return {
        widget: this,
        pos: this.pos,
        order: order,
        receipt: order.export_for_printing(),
        orderlines: order.get_orderlines(),
        paymentlines: order.get_paymentlines(),
    };
},

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM