Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda

Hello there,

I have tried several options to get it done.. But failed each time on the js function.

_inherit  =  'pos.order'
qr = fields.Char(string="QR")

Later i wanted to fetch this fields and return from the receipt dictionary so that i can print this on pos receipt, like receipt.qr


For the js function i wrote like this,


var b = this.get_name()
var domain = [['pos_reference', '=', b]];
var model = 'pos.order';
// Use an empty array to read all the fields of the records
var fields = [];
var qr = '';

var df = function () {
rpc.query({
model: model,
method: 'search_read',
args: [domain, fields],
}).then(function (data) {
receipt.qr = data[0].qr
});
};

This, add the 'qr' key and the value in the receipt dicctionary, but i cant find it on the templates by receipt.qr. May be because of the Promise function and await issue.

The receipt dictionary is this,

var receipt = {
orderlines: orderlines,
paymentlines: paymentlines,
subtotal: this.get_subtotal(),
total_with_tax: this.get_total_with_tax(),
total_rounded: this.get_total_with_tax() + this.get_rounding_applied(),
total_without_tax: this.get_total_without_tax(),
total_tax: this.get_total_tax(),
total_paid: this.get_total_paid(),
total_discount: this.get_total_discount(),
rounding_applied: this.get_rounding_applied(),
tax_details: this.get_tax_details(),
change: this.locked ? this.amount_return : this.get_change(),
name: this.get_name(),
client: client ? client : null,
invoice_id: null, //TODO
cashier: cashier ? cashier.name : null,
precision: {
price: 2,
money: 2,
quantity: 3,
},
date: {
year: date.getFullYear(),
month: date.getMonth(),
date: date.getDate(), // day of the month
day: date.getDay(), // day of the week
hour: date.getHours(),
minute: date.getMinutes(),
isostring: date.toISOString(),
localestring: this.formatted_validation_date,
},
company: {
email: company.email,
website: company.website,
company_registry: company.company_registry,
contact_address: company.partner_id[1],
vat: company.vat,
vat_label: company.country && company.country.vat_label || _t('Tax ID'),
name: company.name,
phone: company.phone,
logo: this.pos.company_logo_base64,
},
currency: this.pos.currency,
};


if (is_html(this.pos.config.receipt_header)) {
receipt.header = '';
receipt.header_html = render_html(this.pos.config.receipt_header);
} else {
receipt.header = this.pos.config.receipt_header || '';
}

if (is_html(this.pos.config.receipt_footer)) {
receipt.footer = '';
receipt.footer_html = render_html(this.pos.config.receipt_footer);
} else {
receipt.footer = this.pos.config.receipt_footer || '';
}
return receipt;
},

Here, i want to add a new key names 'qr' and the value will be the return from the rpc.query that i have the domain for current order name and based on that i want to take the 'qr' of this order. 


PLease if anybody can guide or help, then it will be very helpful for me. Thanks

Avatar
Buang
Post Terkait Replies Tampilan Aktivitas
0
Jun 23
1945
3
Okt 21
7194
0
Des 20
1596
2
Des 20
3296
2
Mar 20
7189