diff --git a/l10n_es_pos/__init__.py b/l10n_es_pos/__init__.py index e1b99a7cba9..7cac8ac3961 100644 --- a/l10n_es_pos/__init__.py +++ b/l10n_es_pos/__init__.py @@ -2,3 +2,4 @@ from . import models from .hooks import post_init_hook, uninstall_hook +from . import wizard diff --git a/l10n_es_pos/__manifest__.py b/l10n_es_pos/__manifest__.py index d784fa8321a..2e7c5aecde5 100644 --- a/l10n_es_pos/__manifest__.py +++ b/l10n_es_pos/__manifest__.py @@ -9,15 +9,13 @@ "Odoo Community Association (OCA)", "website": "https://github.com/OCA/l10n-spain", "license": "AGPL-3", - "version": "15.0.1.0.0", + "version": "16.0.1.0.0", "depends": ["point_of_sale"], - "data": ["views/pos_views.xml"], + "data": ["views/pos_views.xml", "views/res_config_settings_views.xml"], "assets": { - "web.assets_qweb": [ + "point_of_sale.assets": [ "l10n_es_pos/static/src/xml/pos.xml", "l10n_es_pos/static/src/xml/Screens/OrderManagementScreen/TicketScreen.xml", - ], - "point_of_sale.assets": [ "l10n_es_pos/static/src/js/PaymentScreen.js", "l10n_es_pos/static/src/js/models.js", "l10n_es_pos/static/src/js/Screens/TicketScreen/TicketScreen.js", diff --git a/l10n_es_pos/i18n/es.po b/l10n_es_pos/i18n/es.po index 77320c11bdd..a38d1c4aca5 100644 --- a/l10n_es_pos/i18n/es.po +++ b/l10n_es_pos/i18n/es.po @@ -4,77 +4,53 @@ # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 11.0\n" +"Project-Id-Version: Odoo Server 16.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-04-12 14:13+0000\n" -"PO-Revision-Date: 2020-07-27 09:19+0000\n" -"Last-Translator: Daniel Martinez Vila \n" +"POT-Creation-Date: 2022-11-21 10:09+0000\n" +"PO-Revision-Date: 2022-11-21 10:09+0000\n" +"Last-Translator: \n" "Language-Team: \n" -"Language: es\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: \n" -"Plural-Forms: nplurals=2; plural=n != 1;\n" -"X-Generator: Weblate 3.10\n" +"Plural-Forms: \n" #. module: l10n_es_pos -#. openerp-web -#: code:addons/l10n_es_pos/static/src/xml/pos.xml:0 -#, python-format -msgid "" -"!env.pos.config.iface_l10n_es_simplified_invoice or receipt.is_to_invoice" -msgstr "" - -#. module: l10n_es_pos -#: model_terms:ir.ui.view,arch_db:l10n_es_pos.pos_config_view_form +#: model_terms:ir.ui.view,arch_db:l10n_es_pos.res_config_settings_view_form msgid "Above this limit the simplified invoice won't be made" msgstr "Por encima de este límite no se creará factura simplificada" #. module: l10n_es_pos #: model:ir.model.fields,help:l10n_es_pos.field_pos_config__l10n_es_simplified_invoice_sequence_id +#: model:ir.model.fields,help:l10n_es_pos.field_res_config_settings__pos_l10n_es_simplified_invoice_sequence_id msgid "Autogenerate for each POS created" msgstr "Autogenerada por cada TPV creado" +#. module: l10n_es_pos +#: model:ir.model,name:l10n_es_pos.model_res_config_settings +msgid "Config Settings" +msgstr "Opciones de configuración" + #. module: l10n_es_pos #. openerp-web #: code:addons/l10n_es_pos/static/src/xml/pos.xml:0 #, python-format msgid "Customer:" -msgstr "Cliente:" - -#. module: l10n_es_pos -#: model:ir.model.fields,field_description:l10n_es_pos.field_ir_sequence__display_name -#: model:ir.model.fields,field_description:l10n_es_pos.field_pos_config__display_name -#: model:ir.model.fields,field_description:l10n_es_pos.field_pos_order__display_name -msgid "Display Name" -msgstr "" - -#. module: l10n_es_pos -#: model:ir.model.fields,field_description:l10n_es_pos.field_ir_sequence__id -#: model:ir.model.fields,field_description:l10n_es_pos.field_pos_config__id -#: model:ir.model.fields,field_description:l10n_es_pos.field_pos_order__id -msgid "ID" msgstr "" #. module: l10n_es_pos -#: model_terms:ir.ui.view,arch_db:l10n_es_pos.pos_config_view_form +#: model_terms:ir.ui.view,arch_db:l10n_es_pos.res_config_settings_view_form msgid "Invoice Journal" -msgstr "Diario de facturas" +msgstr "" #. module: l10n_es_pos #: model_terms:ir.ui.view,arch_db:l10n_es_pos.view_pos_order_filter_simplified_invoice msgid "Invoices" msgstr "Diario de facturas" -#. module: l10n_es_pos -#: model:ir.model.fields,field_description:l10n_es_pos.field_ir_sequence____last_update -#: model:ir.model.fields,field_description:l10n_es_pos.field_pos_config____last_update -#: model:ir.model.fields,field_description:l10n_es_pos.field_pos_order____last_update -msgid "Last Modified on" -msgstr "" - #. module: l10n_es_pos #: model:ir.model.fields,help:l10n_es_pos.field_pos_config__l10n_es_simplified_invoice_limit +#: model:ir.model.fields,help:l10n_es_pos.field_res_config_settings__pos_l10n_es_simplified_invoice_limit msgid "Over this amount is not legally posible to create a simplified invoice" msgstr "Por encima de esta cantidad no es legal crear una factura simplificada" @@ -88,61 +64,74 @@ msgstr "Configuración Punto de Venta" msgid "Point of Sale Orders" msgstr "Pedidos del Punto de Venta" +#. module: l10n_es_pos +#: model:ir.model,name:l10n_es_pos.model_pos_session +msgid "Point of Sale Session" +msgstr "Sesión TPV" + #. module: l10n_es_pos #: model:ir.model,name:l10n_es_pos.model_ir_sequence msgid "Sequence" msgstr "Secuencia" #. module: l10n_es_pos -#: model_terms:ir.ui.view,arch_db:l10n_es_pos.pos_config_view_form +#: model_terms:ir.ui.view,arch_db:l10n_es_pos.res_config_settings_view_form msgid "Set simplified invoice sequence for this POS" msgstr "Establecer secuencia de factura simplificada para este TPV" #. module: l10n_es_pos #: model:ir.model.fields,field_description:l10n_es_pos.field_pos_config__l10n_es_simplified_invoice_limit +#: model:ir.model.fields,field_description:l10n_es_pos.field_res_config_settings__pos_l10n_es_simplified_invoice_limit msgid "Sim.Inv limit amount" msgstr "Límite de factura simplificada" #. module: l10n_es_pos #: model:ir.model.fields,field_description:l10n_es_pos.field_pos_config__l10n_es_simplified_invoice_number +#: model:ir.model.fields,field_description:l10n_es_pos.field_res_config_settings__pos_l10n_es_simplified_invoice_number msgid "Sim.Inv number" msgstr "Número de factura simplificada" #. module: l10n_es_pos #. openerp-web -#: code:addons/l10n_es_pos/static/src/xml/Screens/OrderManagementScreen/OrderList.xml:0 +#: code:addons/l10n_es_pos/static/src/js/Screens/TicketScreen/TicketScreen.js:0 +#: code:addons/l10n_es_pos/static/src/xml/Screens/OrderManagementScreen/TicketScreen.xml:0 +#: code:addons/l10n_es_pos/static/src/xml/Screens/OrderManagementScreen/TicketScreen.xml:0 #, python-format msgid "Simplified Invoice" msgstr "" #. module: l10n_es_pos #: code:addons/l10n_es_pos/models/pos_config.py:0 +#: code:addons/l10n_es_pos/models/pos_config.py:0 #, python-format msgid "Simplified Invoice %s" msgstr "Factura simplificada %s" #. module: l10n_es_pos #: model:ir.model.fields,field_description:l10n_es_pos.field_pos_config__l10n_es_simplified_invoice_sequence_id +#: model:ir.model.fields,field_description:l10n_es_pos.field_res_config_settings__pos_l10n_es_simplified_invoice_sequence_id msgid "Simplified Invoice IDs Sequence" msgstr "Secuencia de Factura Simplificada" #. module: l10n_es_pos -#: model_terms:ir.ui.view,arch_db:l10n_es_pos.pos_config_view_form +#: model_terms:ir.ui.view,arch_db:l10n_es_pos.res_config_settings_view_form msgid "Simplified Invoice Limit" msgstr "Límite de Factura Simplificada" #. module: l10n_es_pos -#: model_terms:ir.ui.view,arch_db:l10n_es_pos.pos_config_view_form +#: model_terms:ir.ui.view,arch_db:l10n_es_pos.res_config_settings_view_form msgid "Simplified Invoice Sequence" msgstr "Secuencia de Factura Simplificada" #. module: l10n_es_pos #: model:ir.model.fields,field_description:l10n_es_pos.field_pos_config__l10n_es_simplified_invoice_padding +#: model:ir.model.fields,field_description:l10n_es_pos.field_res_config_settings__pos_l10n_es_simplified_invoice_padding msgid "Simplified Invoice padding" msgstr "Relleno de Factura Simplificada" #. module: l10n_es_pos #: model:ir.model.fields,field_description:l10n_es_pos.field_pos_config__l10n_es_simplified_invoice_prefix +#: model:ir.model.fields,field_description:l10n_es_pos.field_res_config_settings__pos_l10n_es_simplified_invoice_prefix msgid "Simplified Invoice prefix" msgstr "Prefijo de Factura Simplificada" @@ -176,55 +165,14 @@ msgstr "" #. module: l10n_es_pos #: model:ir.model.fields,field_description:l10n_es_pos.field_pos_config__iface_l10n_es_simplified_invoice +#: model:ir.model.fields,field_description:l10n_es_pos.field_res_config_settings__pos_iface_l10n_es_simplified_invoice msgid "Use simplified invoices for this POS" msgstr "Usar Facturas Simplificadas en este Punto de Venta" #. module: l10n_es_pos #. openerp-web #: code:addons/l10n_es_pos/static/src/xml/pos.xml:0 +#: code:addons/l10n_es_pos/static/src/xml/pos.xml:0 #, python-format msgid "on" msgstr "sobre" - -#~ msgid "Unique Order ID" -#~ msgstr "ID único de pedido" - -#~ msgid "VAT:" -#~ msgstr "NIF:" - -#~ msgid "Address:" -#~ msgstr "Dirección:" - -#~ msgid "Customer data" -#~ msgstr "Datos de cliente" - -#~ msgid "Name:" -#~ msgstr "Nombre:" - -#~ msgid "Product" -#~ msgstr "Producto" - -#~ msgid "Qty" -#~ msgstr "Cantidad" - -#~ msgid "Simplified invoice:" -#~ msgstr "Factura Simplificada:" - -#~ msgid "Subt" -#~ msgstr "Subt" - -#~ msgid "Unit" -#~ msgstr "Ud." - -#~ msgid "" -#~ "The current order is already queued and thus it shouldn't be changed. " -#~ "Click on 'Validate' in order to finalize it." -#~ msgstr "" -#~ "Este pedido ya está en cola, de modo que no debería modificarse. Pulsa en " -#~ "'Validar' para finalizarlo." - -#~ msgid "The order is already queued" -#~ msgstr "El pedido ya está en cola" - -#~ msgid "pos.config" -#~ msgstr "pos.config" diff --git a/l10n_es_pos/i18n/l10n_es_pos.pot b/l10n_es_pos/i18n/l10n_es_pos.pot index 35fabef0a35..3438346554f 100644 --- a/l10n_es_pos/i18n/l10n_es_pos.pot +++ b/l10n_es_pos/i18n/l10n_es_pos.pot @@ -4,8 +4,10 @@ # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 15.0\n" +"Project-Id-Version: Odoo Server 16.0\n" "Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2022-11-21 10:06+0000\n" +"PO-Revision-Date: 2022-11-21 10:06+0000\n" "Last-Translator: \n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -14,23 +16,21 @@ msgstr "" "Plural-Forms: \n" #. module: l10n_es_pos -#. openerp-web -#: code:addons/l10n_es_pos/static/src/xml/pos.xml:0 -#, python-format -msgid "" -"!env.pos.config.iface_l10n_es_simplified_invoice or receipt.is_to_invoice" -msgstr "" - -#. module: l10n_es_pos -#: model_terms:ir.ui.view,arch_db:l10n_es_pos.pos_config_view_form +#: model_terms:ir.ui.view,arch_db:l10n_es_pos.res_config_settings_view_form msgid "Above this limit the simplified invoice won't be made" msgstr "" #. module: l10n_es_pos #: model:ir.model.fields,help:l10n_es_pos.field_pos_config__l10n_es_simplified_invoice_sequence_id +#: model:ir.model.fields,help:l10n_es_pos.field_res_config_settings__pos_l10n_es_simplified_invoice_sequence_id msgid "Autogenerate for each POS created" msgstr "" +#. module: l10n_es_pos +#: model:ir.model,name:l10n_es_pos.model_res_config_settings +msgid "Config Settings" +msgstr "" + #. module: l10n_es_pos #. openerp-web #: code:addons/l10n_es_pos/static/src/xml/pos.xml:0 @@ -39,7 +39,7 @@ msgid "Customer:" msgstr "" #. module: l10n_es_pos -#: model_terms:ir.ui.view,arch_db:l10n_es_pos.pos_config_view_form +#: model_terms:ir.ui.view,arch_db:l10n_es_pos.res_config_settings_view_form msgid "Invoice Journal" msgstr "" @@ -50,6 +50,7 @@ msgstr "" #. module: l10n_es_pos #: model:ir.model.fields,help:l10n_es_pos.field_pos_config__l10n_es_simplified_invoice_limit +#: model:ir.model.fields,help:l10n_es_pos.field_res_config_settings__pos_l10n_es_simplified_invoice_limit msgid "Over this amount is not legally posible to create a simplified invoice" msgstr "" @@ -63,23 +64,30 @@ msgstr "" msgid "Point of Sale Orders" msgstr "" +#. module: l10n_es_pos +#: model:ir.model,name:l10n_es_pos.model_pos_session +msgid "Point of Sale Session" +msgstr "" + #. module: l10n_es_pos #: model:ir.model,name:l10n_es_pos.model_ir_sequence msgid "Sequence" msgstr "" #. module: l10n_es_pos -#: model_terms:ir.ui.view,arch_db:l10n_es_pos.pos_config_view_form +#: model_terms:ir.ui.view,arch_db:l10n_es_pos.res_config_settings_view_form msgid "Set simplified invoice sequence for this POS" msgstr "" #. module: l10n_es_pos #: model:ir.model.fields,field_description:l10n_es_pos.field_pos_config__l10n_es_simplified_invoice_limit +#: model:ir.model.fields,field_description:l10n_es_pos.field_res_config_settings__pos_l10n_es_simplified_invoice_limit msgid "Sim.Inv limit amount" msgstr "" #. module: l10n_es_pos #: model:ir.model.fields,field_description:l10n_es_pos.field_pos_config__l10n_es_simplified_invoice_number +#: model:ir.model.fields,field_description:l10n_es_pos.field_res_config_settings__pos_l10n_es_simplified_invoice_number msgid "Sim.Inv number" msgstr "" @@ -101,26 +109,29 @@ msgstr "" #. module: l10n_es_pos #: model:ir.model.fields,field_description:l10n_es_pos.field_pos_config__l10n_es_simplified_invoice_sequence_id +#: model:ir.model.fields,field_description:l10n_es_pos.field_res_config_settings__pos_l10n_es_simplified_invoice_sequence_id msgid "Simplified Invoice IDs Sequence" msgstr "" #. module: l10n_es_pos -#: model_terms:ir.ui.view,arch_db:l10n_es_pos.pos_config_view_form +#: model_terms:ir.ui.view,arch_db:l10n_es_pos.res_config_settings_view_form msgid "Simplified Invoice Limit" msgstr "" #. module: l10n_es_pos -#: model_terms:ir.ui.view,arch_db:l10n_es_pos.pos_config_view_form +#: model_terms:ir.ui.view,arch_db:l10n_es_pos.res_config_settings_view_form msgid "Simplified Invoice Sequence" msgstr "" #. module: l10n_es_pos #: model:ir.model.fields,field_description:l10n_es_pos.field_pos_config__l10n_es_simplified_invoice_padding +#: model:ir.model.fields,field_description:l10n_es_pos.field_res_config_settings__pos_l10n_es_simplified_invoice_padding msgid "Simplified Invoice padding" msgstr "" #. module: l10n_es_pos #: model:ir.model.fields,field_description:l10n_es_pos.field_pos_config__l10n_es_simplified_invoice_prefix +#: model:ir.model.fields,field_description:l10n_es_pos.field_res_config_settings__pos_l10n_es_simplified_invoice_prefix msgid "Simplified Invoice prefix" msgstr "" @@ -152,12 +163,14 @@ msgstr "" #. module: l10n_es_pos #: model:ir.model.fields,field_description:l10n_es_pos.field_pos_config__iface_l10n_es_simplified_invoice +#: model:ir.model.fields,field_description:l10n_es_pos.field_res_config_settings__pos_iface_l10n_es_simplified_invoice msgid "Use simplified invoices for this POS" msgstr "" #. module: l10n_es_pos #. openerp-web #: code:addons/l10n_es_pos/static/src/xml/pos.xml:0 +#: code:addons/l10n_es_pos/static/src/xml/pos.xml:0 #, python-format msgid "on" msgstr "" diff --git a/l10n_es_pos/models/__init__.py b/l10n_es_pos/models/__init__.py index 6cdbe814493..7466682f7ce 100644 --- a/l10n_es_pos/models/__init__.py +++ b/l10n_es_pos/models/__init__.py @@ -1,3 +1,4 @@ from . import ir_sequence from . import pos_config from . import pos_order +from . import pos_session diff --git a/l10n_es_pos/models/pos_session.py b/l10n_es_pos/models/pos_session.py new file mode 100644 index 00000000000..9b7f704c6ae --- /dev/null +++ b/l10n_es_pos/models/pos_session.py @@ -0,0 +1,12 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import models + + +class PosSession(models.Model): + _inherit = "pos.session" + + def _loader_params_res_company(self): + res = super()._loader_params_res_company() + res["search_params"]["fields"] += ["street", "city", "zip"] + return res diff --git a/l10n_es_pos/readme/CONTRIBUTORS.rst b/l10n_es_pos/readme/CONTRIBUTORS.rst index f5bc9dcf146..efea4f1ee63 100644 --- a/l10n_es_pos/readme/CONTRIBUTORS.rst +++ b/l10n_es_pos/readme/CONTRIBUTORS.rst @@ -23,3 +23,7 @@ * `Sygel `_: * Manuel Regidor + +* `Factor Libre `_: + + * Daniel Duque diff --git a/l10n_es_pos/static/src/js/PaymentScreen.js b/l10n_es_pos/static/src/js/PaymentScreen.js index 3caa11aad8b..6731acc7ff9 100644 --- a/l10n_es_pos/static/src/js/PaymentScreen.js +++ b/l10n_es_pos/static/src/js/PaymentScreen.js @@ -14,11 +14,11 @@ odoo.define("l10n_es_pos.PaymentScreen", function (require) { const L10nEsPosPaymentScreen = (PaymentScreen) => class extends PaymentScreen { async validateOrder(isForceValidate) { - var below_limit = + const below_limit = this.currentOrder.get_total_with_tax() <= this.env.pos.config.l10n_es_simplified_invoice_limit; if (this.env.pos.config.iface_l10n_es_simplified_invoice) { - var order = this.currentOrder; + const order = this.currentOrder; if (below_limit && !order.to_invoice) { await order.set_simple_inv_number(); } else { diff --git a/l10n_es_pos/static/src/js/Screens/TicketScreen/TicketScreen.js b/l10n_es_pos/static/src/js/Screens/TicketScreen/TicketScreen.js index b6ad3f24ff1..7909742459a 100644 --- a/l10n_es_pos/static/src/js/Screens/TicketScreen/TicketScreen.js +++ b/l10n_es_pos/static/src/js/Screens/TicketScreen/TicketScreen.js @@ -6,9 +6,6 @@ odoo.define("l10n_es_pos.TicketScreen", function (require) { const L10nEsPosTicketScreen = (TicketScreen) => class extends TicketScreen { - getSimplifiedInvoiceId(order) { - return order.l10n_es_unique_id ? order.l10n_es_unique_id : ""; - } _getSearchFields() { const fields = super._getSearchFields(); fields.SIMPLIFIED_INVOICE = { diff --git a/l10n_es_pos/static/src/js/models.js b/l10n_es_pos/static/src/js/models.js index bc3d1ee64d3..2f24b85a167 100644 --- a/l10n_es_pos/static/src/js/models.js +++ b/l10n_es_pos/static/src/js/models.js @@ -6,136 +6,139 @@ odoo.define("l10n_es_pos.models", function (require) { "use strict"; - var models = require("point_of_sale.models"); + const {PosGlobalState, Order} = require("point_of_sale.models"); + const Registries = require("point_of_sale.Registries"); - var pos_super = models.PosModel.prototype; - models.PosModel = models.PosModel.extend({ - initialize: function () { - pos_super.initialize.apply(this, arguments); - this.pushed_simple_invoices = []; + const L10NESGlobalState = (PosGlobalState) => + class L10NESGlobalState extends PosGlobalState { + constructor() { + super(...arguments); + this.pushed_simple_invoices = []; - this.own_simplified_invoice_prefix = ""; // Unique UUID - return this; - }, - get_simple_inv_next_number: function () { - return this.rpc({ - method: "search_read", - domain: [["id", "=", this.config_id]], - fields: ["l10n_es_simplified_invoice_number"], - model: "pos.config", - }); - }, - get_padding_simple_inv: function (number) { - var diff = - this.config.l10n_es_simplified_invoice_padding - - number.toString().length; - var result = ""; - if (diff <= 0) { - result = number; - } else { - for (var i = 0; i < diff; i++) { - result += "0"; - } - result += number; + this.own_simplified_invoice_prefix = ""; // Unique UUID } - return result; - }, - push_simple_invoice: function (order) { - if ( - this.pushed_simple_invoices.indexOf(order.data.l10n_es_unique_id) === -1 - ) { - this.pushed_simple_invoices.push(order.data.l10n_es_unique_id); - ++this.config.l10n_es_simplified_invoice_number; + get_simple_inv_next_number() { + return this.env.services.rpc({ + method: "search_read", + domain: [["id", "=", this.env.pos.config.id]], + fields: ["l10n_es_simplified_invoice_number"], + model: "pos.config", + }); } - }, - _flush_orders: function (orders) { - var self = this; - // Save pushed orders numbers - _.each(orders, function (order) { - if (!order.data.to_invoice) { - self.push_simple_invoice(order); + get_padding_simple_inv(number) { + const diff = + this.config.l10n_es_simplified_invoice_padding - + number.toString().length; + let result = ""; + if (diff <= 0) { + result = number; + } else { + for (let i = 0; i < diff; i++) { + result += "0"; + } + result += number; } - }); - return pos_super._flush_orders.apply(this, arguments); - }, - }); - - var order_super = models.Order.prototype; - models.Order = models.Order.extend({ - get_total_with_tax: function () { - var total = order_super.get_total_with_tax.apply(this, arguments); - var below_limit = total <= this.pos.config.l10n_es_simplified_invoice_limit; - this.is_simplified_invoice = - below_limit && this.pos.config.iface_l10n_es_simplified_invoice; - return total; - }, - set_simple_inv_number: function () { - const self = this; - return this.pos - .get_simple_inv_next_number() - .then(function (configs) { - const config = configs[0]; - self.pos.config.l10n_es_simplified_invoice_number = - config.l10n_es_simplified_invoice_number; - const simplified_invoice_number = - self.pos.config.l10n_es_simplified_invoice_prefix + - self.pos.get_padding_simple_inv( - config.l10n_es_simplified_invoice_number - ); - self.l10n_es_unique_id = simplified_invoice_number; - self.is_simplified_invoice = true; - }) - .catch(function () { - self.l10n_es_unique_id = self.uid; - self.is_simplified_invoice = true; + return result; + } + push_simple_invoice(order) { + if ( + this.pushed_simple_invoices.indexOf( + order.data.l10n_es_unique_id + ) === -1 + ) { + this.pushed_simple_invoices.push(order.data.l10n_es_unique_id); + ++this.config.l10n_es_simplified_invoice_number; + } + } + _flush_orders(orders) { + var self = this; + // Save pushed orders numbers + _.each(orders, function (order) { + if (!order.data.to_invoice) { + self.push_simple_invoice(order); + } }); - }, - get_base_by_tax: function () { - var base_by_tax = {}; - this.get_orderlines().forEach(function (line) { - var tax_detail = line.get_tax_details(); - var 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 super._flush_orders(...arguments); + } + }; + Registries.Model.extend(PosGlobalState, L10NESGlobalState); + + const L10NESOrder = (Order) => + class L10NESOrder extends Order { + 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.iface_l10n_es_simplified_invoice; + return total; + } + set_simple_inv_number() { + const self = this; + return this.pos + .get_simple_inv_next_number() + .then(function (configs) { + const config = configs[0]; + self.pos.config.l10n_es_simplified_invoice_number = + config.l10n_es_simplified_invoice_number; + const simplified_invoice_number = + self.pos.config.l10n_es_simplified_invoice_prefix + + self.pos.get_padding_simple_inv( + config.l10n_es_simplified_invoice_number + ); + self.l10n_es_unique_id = simplified_invoice_number; + self.is_simplified_invoice = true; + }) + .catch(function () { + self.l10n_es_unique_id = self.uid; + self.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 base_by_tax; - }, - init_from_JSON: function (json) { - order_super.init_from_JSON.apply(this, arguments); - this.to_invoice = json.to_invoice; - this.l10n_es_unique_id = json.l10n_es_unique_id; - }, - export_as_JSON: function () { - var res = order_super.export_as_JSON.apply(this, arguments); - res.to_invoice = this.is_to_invoice(); - if (!res.to_invoice) { - res.l10n_es_unique_id = this.l10n_es_unique_id; + return res; } - return res; - }, - export_for_printing: function () { - var result = order_super.export_for_printing.apply(this, arguments); - var company = this.pos.company; - result.l10n_es_unique_id = this.l10n_es_unique_id; - result.to_invoice = this.to_invoice; - result.company.street = company.street; - result.company.zip = company.zip; - result.company.city = company.city; - result.company.state_id = company.state_id; - var base_by_tax = this.get_base_by_tax(); - for (const tax of result.tax_details) { - tax.base = base_by_tax[tax.tax.id]; + export_for_printing() { + const result = super.export_for_printing(...arguments); + const company = this.pos.company; + result.l10n_es_unique_id = this.l10n_es_unique_id; + result.to_invoice = this.to_invoice; + result.company.street = company.street; + result.company.zip = company.zip; + result.company.city = company.city; + result.company.state_id = company.state_id; + 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; } - return result; - }, - }); - - models.load_fields("res.company", ["street", "city", "state_id", "zip"]); + }; + Registries.Model.extend(Order, L10NESOrder); }); diff --git a/l10n_es_pos/static/src/xml/pos.xml b/l10n_es_pos/static/src/xml/pos.xml index f133d9bb23a..b802be89c6a 100644 --- a/l10n_es_pos/static/src/xml/pos.xml +++ b/l10n_es_pos/static/src/xml/pos.xml @@ -30,22 +30,34 @@
- -
Customer:
- + +
Customer:
+
:
- -
+ +
- + on - + + on + + !env.pos.config.iface_l10n_es_simplified_invoice or receipt.is_to_invoice diff --git a/l10n_es_pos/views/pos_views.xml b/l10n_es_pos/views/pos_views.xml index 13745ae69ac..56fde6eef30 100644 --- a/l10n_es_pos/views/pos_views.xml +++ b/l10n_es_pos/views/pos_views.xml @@ -45,70 +45,4 @@ - - - PoS Config l10n_es_pos - pos.config - - -
-
-
- -
-
-
-
-
-
-
-
-
-
-
diff --git a/l10n_es_pos/views/res_config_settings_views.xml b/l10n_es_pos/views/res_config_settings_views.xml new file mode 100644 index 00000000000..aad95497054 --- /dev/null +++ b/l10n_es_pos/views/res_config_settings_views.xml @@ -0,0 +1,72 @@ + + + + res.config.settings.view.form + res.config.settings + + + +
+
+ +
+
+
+
+
+
+
+
+
+
+
+
diff --git a/l10n_es_pos/wizard/__init__.py b/l10n_es_pos/wizard/__init__.py new file mode 100644 index 00000000000..0deb68c4680 --- /dev/null +++ b/l10n_es_pos/wizard/__init__.py @@ -0,0 +1 @@ +from . import res_config_settings diff --git a/l10n_es_pos/wizard/res_config_settings.py b/l10n_es_pos/wizard/res_config_settings.py new file mode 100644 index 00000000000..60b11ed640b --- /dev/null +++ b/l10n_es_pos/wizard/res_config_settings.py @@ -0,0 +1,26 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo import fields, models + + +class ResConfigSettings(models.TransientModel): + _inherit = "res.config.settings" + + pos_iface_l10n_es_simplified_invoice = fields.Boolean( + related="pos_config_id.iface_l10n_es_simplified_invoice", + readonly=False, + ) + pos_l10n_es_simplified_invoice_sequence_id = fields.Many2one( + related="pos_config_id.l10n_es_simplified_invoice_sequence_id", + ) + pos_l10n_es_simplified_invoice_limit = fields.Float( + related="pos_config_id.l10n_es_simplified_invoice_limit", + ) + pos_l10n_es_simplified_invoice_prefix = fields.Char( + related="pos_config_id.l10n_es_simplified_invoice_prefix", + ) + pos_l10n_es_simplified_invoice_padding = fields.Integer( + related="pos_config_id.l10n_es_simplified_invoice_padding", + ) + pos_l10n_es_simplified_invoice_number = fields.Integer( + related="pos_config_id.l10n_es_simplified_invoice_number", + ) diff --git a/setup/l10n_es_pos/odoo/addons/l10n_es_pos b/setup/l10n_es_pos/odoo/addons/l10n_es_pos new file mode 120000 index 00000000000..b91d89f4d1d --- /dev/null +++ b/setup/l10n_es_pos/odoo/addons/l10n_es_pos @@ -0,0 +1 @@ +../../../../l10n_es_pos \ No newline at end of file diff --git a/setup/l10n_es_pos/setup.py b/setup/l10n_es_pos/setup.py new file mode 100644 index 00000000000..28c57bb6403 --- /dev/null +++ b/setup/l10n_es_pos/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)