From 240a518de8f0a8e47b6051e796effaec09d93bd2 Mon Sep 17 00:00:00 2001 From: hugues de keyzer Date: Fri, 1 Nov 2024 11:00:49 +0100 Subject: [PATCH] [IMP] keep to_invoice value of existing orders --- pos_auto_invoice/static/src/js/models.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/pos_auto_invoice/static/src/js/models.js b/pos_auto_invoice/static/src/js/models.js index 4ba964b6ef..8919bb329f 100644 --- a/pos_auto_invoice/static/src/js/models.js +++ b/pos_auto_invoice/static/src/js/models.js @@ -6,12 +6,19 @@ odoo.define("pos_auto_invoice.models", function (require) { const AutoInvoiceOrder = (OriginalOrder) => class extends OriginalOrder { - constructor() { + constructor(obj, options) { super(...arguments); - if (this.pos.config.invoice_by_default) { + if (!options.json && this.pos.config.invoice_by_default) { this.to_invoice = true; } } + + init_from_JSON(json) { + super.init_from_JSON(...arguments); + // This should be done in the original method, but curiously + // it is not (to_invoice is always set to false). + this.to_invoice = json.to_invoice; + } }; Registries.Model.extend(Order, AutoInvoiceOrder);