-
-
Notifications
You must be signed in to change notification settings - Fork 534
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MIG] l10n_es_pos_oca: Migration to 17.0
- Loading branch information
Showing
18 changed files
with
328 additions
and
343 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
l10n_es_pos_oca/static/src/app/screens/payment_screen/payment_screen.esm.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/** @odoo-module */ | ||
|
||
/* Copyright 2016 David Gómez Quilón <david.gomez@aselcis.com> | ||
Copyright 2018 Tecnativa - David Vidal | ||
Copyright 2020 Tecnativa - João Marques | ||
Copyright 2024 (APSL-Nagarro) - Antoni Marroig | ||
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
*/ | ||
|
||
import {PaymentScreen} from "@point_of_sale/app/screens/payment_screen/payment_screen"; | ||
import {patch} from "@web/core/utils/patch"; | ||
|
||
patch(PaymentScreen.prototype, { | ||
async validateOrder(isForceValidate) { | ||
const below_limit = | ||
this.currentOrder.get_total_with_tax() <= | ||
this.pos.config.l10n_es_simplified_invoice_limit; | ||
if (this.pos.config.is_simplified_config) { | ||
const order = this.currentOrder; | ||
if (below_limit && !order.to_invoice) { | ||
await order.set_simple_inv_number(); | ||
} else { | ||
// Force invoice above limit. Online is needed. | ||
order.to_invoice = true; | ||
} | ||
order.partner = | ||
order.partner || | ||
this.pos.db.partner_by_id[this.pos.config.simplified_partner_id[0]]; | ||
} | ||
await super.validateOrder(isForceValidate); | ||
}, | ||
}); |
14 changes: 14 additions & 0 deletions
14
l10n_es_pos_oca/static/src/app/screens/receipt_screen/receipt/order_receipt.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<templates id="template" xml:space="preserve"> | ||
<t | ||
t-name="OrderReceipt" | ||
t-inherit="point_of_sale.OrderReceipt" | ||
t-inherit-mode="extension" | ||
> | ||
<xpath expr="//div[hasclass('pos-receipt-order-data')]" position="attributes"> | ||
<attribute | ||
name="t-if" | ||
>!env.pos.config.is_simplified_config or props.data.is_to_invoice</attribute> | ||
</xpath> | ||
</t> | ||
</templates> |
27 changes: 27 additions & 0 deletions
27
...s_pos_oca/static/src/app/screens/receipt_screen/receipt/receipt_header/receipt_header.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<templates id="template" xml:space="preserve"> | ||
<t | ||
t-name="OrderReceipt" | ||
t-inherit="point_of_sale.ReceiptHeader" | ||
t-inherit-mode="extension" | ||
> | ||
<xpath expr="//div[hasclass('pos-receipt-contact')]/div" position="before"> | ||
<t t-if="props.data.is_simplified_config and !props.data.to_invoice"> | ||
<div>Simplified invoice</div> | ||
<div class="simplified-invoice-number" t-esc="props.data.l10n_es_unique_id" /> | ||
</t> | ||
<div t-if="props.data.company.street" t-esc="props.data.company.street" /> | ||
<div t-if="props.data.company.zip" t-esc="props.data.company.zip" /> | ||
<div t-if="props.data.company.city" t-esc="props.data.company.city" /> | ||
<div t-if="props.data.company.state_id">(<t t-esc="props.data.company.state_id[1]"/>)</div> | ||
</xpath> | ||
<xpath expr="//div[hasclass('pos-receipt-contact')]" position="inside"> | ||
<t t-set="partner" t-value="props.data.partner"/> | ||
<t t-if="partner and partner.id !== props.data.simplified_partner_id"> | ||
<div>Customer: <t t-esc="partner.name" /></div> | ||
<div t-if="partner.vat"><t t-esc="props.data.company.country?.vat_label || 'Tax ID'"/>: <t t-esc="partner.vat" /></div> | ||
<div t-if="partner.address" t-esc="partner.address"/> | ||
</t> | ||
</xpath> | ||
</t> | ||
</templates> |
23 changes: 23 additions & 0 deletions
23
l10n_es_pos_oca/static/src/app/screens/ticket_screen/ticket_screen.esm.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/** @odoo-module */ | ||
|
||
/* Copyright 2016 David Gómez Quilón <david.gomez@aselcis.com> | ||
Copyright 2018-19 Tecnativa - David Vidal | ||
Copyright 2024 (APSL-Nagarro) - Antoni Marroig | ||
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
*/ | ||
|
||
import {TicketScreen} from "@point_of_sale/app/screens/ticket_screen/ticket_screen"; | ||
import {_t} from "@web/core/l10n/translation"; | ||
import {patch} from "@web/core/utils/patch"; | ||
|
||
patch(TicketScreen.prototype, { | ||
_getSearchFields() { | ||
const fields = super._getSearchFields(); | ||
fields.SIMPLIFIED_INVOICE = { | ||
repr: (order) => order.name, | ||
displayName: _t("Simplified Invoice"), | ||
modelField: "l10n_es_unique_id", | ||
}; | ||
return fields; | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/** @odoo-module */ | ||
|
||
/* Copyright 2016 David Gómez Quilón <david.gomez@aselcis.com> | ||
Copyright 2018-19 Tecnativa - David Vidal | ||
Copyright 2024 (APSL-Nagarro) - Antoni Marroig | ||
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
*/ | ||
|
||
import {ConnectionLostError} from "@web/core/network/rpc_service"; | ||
import {Order} from "@point_of_sale/app/store/models"; | ||
import {patch} from "@web/core/utils/patch"; | ||
|
||
patch(Order.prototype, { | ||
get_total_with_tax() { | ||
const total = super.get_total_with_tax(...arguments); | ||
const below_limit = total <= this.pos.config.l10n_es_simplified_invoice_limit; | ||
this.is_simplified_invoice = | ||
below_limit && this.pos.config.is_simplified_config; | ||
return total; | ||
}, | ||
set_simple_inv_number() { | ||
return this.pos | ||
.get_simple_inv_next_number() | ||
.then(([config]) => { | ||
// We'll get the number from DB only when we're online. Otherwise | ||
// the sequence will run on the client side until the orders are | ||
// synced. | ||
this.pos._set_simplified_invoice_number(config); | ||
}) | ||
.catch((error) => { | ||
// We'll only consider network errors | ||
if (!error instanceof ConnectionLostError) { | ||
throw error; | ||
} | ||
}) | ||
.finally(() => { | ||
const simplified_invoice_number = | ||
this.pos._get_simplified_invoice_number(); | ||
this.l10n_es_unique_id = simplified_invoice_number; | ||
this.is_simplified_invoice = true; | ||
}); | ||
}, | ||
get_base_by_tax() { | ||
const base_by_tax = {}; | ||
this.get_orderlines().forEach(function (line) { | ||
const tax_detail = line.get_tax_details(); | ||
const base_price = line.get_price_without_tax(); | ||
if (tax_detail) { | ||
Object.keys(tax_detail).forEach(function (tax) { | ||
if (Object.keys(base_by_tax).includes(tax)) { | ||
base_by_tax[tax] += base_price; | ||
} else { | ||
base_by_tax[tax] = base_price; | ||
} | ||
}); | ||
} | ||
}); | ||
return base_by_tax; | ||
}, | ||
init_from_JSON(json) { | ||
super.init_from_JSON(...arguments); | ||
this.to_invoice = json.to_invoice; | ||
this.l10n_es_unique_id = json.l10n_es_unique_id; | ||
}, | ||
export_as_JSON() { | ||
const res = super.export_as_JSON(...arguments); | ||
res.to_invoice = this.is_to_invoice(); | ||
if (!res.to_invoice) { | ||
res.l10n_es_unique_id = this.l10n_es_unique_id; | ||
} | ||
return res; | ||
}, | ||
export_for_printing() { | ||
const result = super.export_for_printing(...arguments); | ||
result.l10n_es_unique_id = this.l10n_es_unique_id; | ||
result.to_invoice = this.to_invoice; | ||
const base_by_tax = this.get_base_by_tax(); | ||
for (const tax of result.tax_details) { | ||
tax.base = base_by_tax[tax.tax.id]; | ||
} | ||
return result; | ||
}, | ||
}); |
Oops, something went wrong.