Debian Codegraph @

addons/l10n_sa_edi_pos/static/src/overrides/models/pos_order.js

raw symbols SCIP
1 /** @odoo-module */
2
3 import { PosOrder } from "@point_of_sale/app/models/pos_order";
4 import { patch } from "@web/core/utils/patch";
5 import { qrCodeSrc } from "@point_of_sale/utils";
6
7 patch(PosOrder.prototype, {
8 setup() {
9 super.setup(...arguments);
10 if (this.isInvoiceMandatoryForSA()) {
11 this.to_invoice = true;
12 }
13 },
14
15 isInvoiceMandatoryForSA() {
16 // Zatca enforces invoice, but for settlement due, invoices are not needed
17 // Only applicable if enterprise:pos_settle_due module is installed
18 return this.isSACompany() && !this.is_settling_account;
19 },
20
21 isToInvoice() {
22 if (this.isInvoiceMandatoryForSA()) {
23 return true;
24 }
25 return super.isToInvoice(...arguments);
26 },
27 setToInvoice(to_invoice) {
28 if (this.isInvoiceMandatoryForSA()) {
29 this.assertEditable();
30 this.to_invoice = true;
31 } else {
32 super.setToInvoice(...arguments);
33 }
34 },
35
36 setPartner(partner) {
37 /*
38 The settlement dialog sets is_settling_account = true after creating the order
39 So making it default to false here as this is called after is_settling_account is set
40 is_settling_account is only applicable if enterprise:pos_settle_due module is installed
41 */
42 super.setPartner(partner);
43 if (this.is_settling_account) {
44 this.setToInvoice(false);
45 }
46 },
47
48 get notLegal() {
49 return !this.l10n_sa_invoice_qr_code_str;
50 },
51 generateQrcode() {
52 if (!this.notLegal && this.isSACompany()) {
53 return qrCodeSrc(this.l10n_sa_invoice_qr_code_str);
54 }
55 return false;
56 },
57 });