Created
July 5, 2023 17:49
-
-
Save celm1990/fcf25df367ccc2bb0cbcf34230f51665 to your computer and use it in GitHub Desktop.
l10n_latam_pos(JS)
This file contains hidden or 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
| odoo.define("l10n_latam_pos.document_types", function (require) { | |
| "use strict"; | |
| var {PosGlobalState, Order} = require("point_of_sale.models"); | |
| const Registries = require("point_of_sale.Registries"); | |
| const PosClPosGlobalState = (PosGlobalState) => | |
| class PosClPosGlobalState extends PosGlobalState { | |
| async _processData(loadedData) { | |
| await super._processData(...arguments); | |
| this.l10n_latam_identification_types = | |
| loadedData["l10n_latam.identification.type"]; | |
| if (this.config.l10n_latam_document_type_ids.length) { | |
| this.l10n_latam_document_types = | |
| loadedData["l10n_latam.document.type"]; | |
| this.l10n_latam_document_type_by_id = | |
| loadedData.l10n_latam_document_type_by_id; | |
| } | |
| } | |
| set_l10n_latam_document_type(l10n_latam_document_type) { | |
| this.l10n_latam_document_type = l10n_latam_document_type; | |
| const selectedOrder = this.get_order(); | |
| if (selectedOrder) { | |
| selectedOrder.l10n_latam_document_type = l10n_latam_document_type; | |
| } | |
| } | |
| get_l10n_latam_document_type() { | |
| let l10n_latam_document_type = {}; | |
| const selectedOrder = this.get_order(); | |
| if (selectedOrder) { | |
| l10n_latam_document_type = selectedOrder.l10n_latam_document_type; | |
| } | |
| return l10n_latam_document_type; | |
| } | |
| }; | |
| Registries.Model.extend(PosGlobalState, PosClPosGlobalState); | |
| const PosOrder = (Order) => | |
| class PosOrder extends Order { | |
| constructor(obj, options) { | |
| super(obj, options); | |
| if (this.pos.config.l10n_latam_document_type_id) { | |
| this.setup_latam_document_type( | |
| this.pos.config.l10n_latam_document_type_id[0] | |
| ); | |
| } | |
| } | |
| setup_latam_document_type(latam_document_type_id) { | |
| this.l10n_latam_document_type = | |
| this.pos.l10n_latam_document_type_by_id[latam_document_type_id]; | |
| } | |
| init_from_JSON(json) { | |
| super.init_from_JSON(...arguments); | |
| if ( | |
| this.pos.config.l10n_latam_document_type_ids.length && | |
| json.l10n_latam_document_type_id | |
| ) { | |
| this.l10n_latam_document_type = | |
| this.pos.l10n_latam_document_type_by_id[ | |
| json.l10n_latam_document_type_id | |
| ]; | |
| } | |
| } | |
| export_as_JSON() { | |
| const json = super.export_as_JSON(...arguments); | |
| if (this.pos.config.l10n_latam_document_type_ids.length) { | |
| json.l10n_latam_document_type_id = this.l10n_latam_document_type | |
| ? this.l10n_latam_document_type.id | |
| : false; | |
| } | |
| return json; | |
| } | |
| }; | |
| Registries.Model.extend(Order, PosOrder); | |
| }); |
This file contains hidden or 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
| <?xml version="1.0" encoding="UTF-8" ?> | |
| <templates id="template" xml:space="preserve"> | |
| <t | |
| t-name="TicketScreen" | |
| t-inherit="point_of_sale.TicketScreen" | |
| t-inherit-mode="extension" | |
| owl="1" | |
| > | |
| <xpath | |
| expr="//div[hasclass('header-row')]//div[position() = 1]" | |
| position="before" | |
| > | |
| <div class="col wide">Tipo Doc.</div> | |
| </xpath> | |
| <xpath | |
| expr="//div[hasclass('order-row')]//div[position() = 1]" | |
| position="before" | |
| > | |
| <div class="col"> | |
| <div t-if="env.isMobile">Tipo Doc.</div> | |
| <div><t t-esc="getL10nLatamDocumentType(order)" /></div> | |
| </div> | |
| </xpath> | |
| </t> | |
| </templates> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment