From be4b8bb28531c5b96f6f7004f6fb5d078c48d998 Mon Sep 17 00:00:00 2001 From: Gianluca Milano Date: Fri, 19 May 2023 11:20:18 +0200 Subject: [PATCH] [MIG] l10n_it_pos_fatturapa: Migration to 14.0 [FIX] GSLabIt review --- l10n_it_pos_fatturapa/README.rst | 6 +- l10n_it_pos_fatturapa/__manifest__.py | 21 +++---- l10n_it_pos_fatturapa/models/res_partner.py | 21 ++++--- l10n_it_pos_fatturapa/readme/CONTRIBUTORS.rst | 2 + .../static/src/js/ClientDetailsEdit.js | 26 ++++++++ l10n_it_pos_fatturapa/static/src/js/models.js | 16 ++--- .../static/src/js/screens.js | 19 ------ l10n_it_pos_fatturapa/static/src/xml/pos.xml | 60 ------------------ .../static/src/xml/pos_dump.xml | 62 +++++++++++++++++++ l10n_it_pos_fatturapa/views/assets.xml | 12 +++- .../odoo/addons/l10n_it_pos_fatturapa | 1 + setup/l10n_it_pos_fatturapa/setup.py | 6 ++ 12 files changed, 139 insertions(+), 113 deletions(-) create mode 100644 l10n_it_pos_fatturapa/static/src/js/ClientDetailsEdit.js delete mode 100644 l10n_it_pos_fatturapa/static/src/js/screens.js delete mode 100644 l10n_it_pos_fatturapa/static/src/xml/pos.xml create mode 100644 l10n_it_pos_fatturapa/static/src/xml/pos_dump.xml create mode 120000 setup/l10n_it_pos_fatturapa/odoo/addons/l10n_it_pos_fatturapa create mode 100644 setup/l10n_it_pos_fatturapa/setup.py diff --git a/l10n_it_pos_fatturapa/README.rst b/l10n_it_pos_fatturapa/README.rst index e89fda895c24..25a7cbd24a66 100644 --- a/l10n_it_pos_fatturapa/README.rst +++ b/l10n_it_pos_fatturapa/README.rst @@ -23,7 +23,7 @@ ITA - POS - Fattura elettronica :target: https://runbot.odoo-community.org/runbot/122/12.0 :alt: Try me on Runbot -|badge1| |badge2| |badge3| |badge4| |badge5| +|badge1| |badge2| |badge3| |badge4| |badge5| **Italiano** @@ -62,6 +62,8 @@ Contributors ~~~~~~~~~~~~ * Roberto Fichera +* berim +* Ooops404 Maintainers ~~~~~~~~~~~ @@ -82,7 +84,7 @@ promote its widespread use. Current `maintainer `__: -|maintainer-robyf70| +|maintainer-robyf70| This module is part of the `OCA/l10n-italy `_ project on GitHub. diff --git a/l10n_it_pos_fatturapa/__manifest__.py b/l10n_it_pos_fatturapa/__manifest__.py index e3735c716e3c..6964df6ea092 100644 --- a/l10n_it_pos_fatturapa/__manifest__.py +++ b/l10n_it_pos_fatturapa/__manifest__.py @@ -1,17 +1,14 @@ -# Copyright 2019 Roberto Fichera # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). { "name": "ITA - POS - Fattura elettronica", - "summary": "Gestione dati fattura elettronica del cliente all'interno " - "dell'interfaccia del POS", - "version": "12.0.1.0.2", + "summary": "Gestione dati fattura elettronica del cliente all'interno" + "dell'interfaccia del POS", + "version": "14.0.1.0.0", "development_status": "Beta", "category": "Point Of Sale", - "website": "https://github.com/OCA/l10n-italy" - "/tree/12.0/l10n_it_pos_fatturapa", - "author": "Roberto Fichera, Odoo Community Association (OCA)", - "maintainers": ["robyf70"], + "website": "https://github.com/OCA/l10n-italy", + "author": "Odoo Community Association (OCA)", "license": "AGPL-3", "application": False, "installable": True, @@ -21,10 +18,8 @@ "l10n_it_pos_fiscalcode", "l10n_it_fatturapa", ], - 'qweb': [ - 'static/src/xml/pos.xml' - ], - 'data': [ - 'views/assets.xml', + "qweb": ["static/src/xml/pos_dump.xml"], + "data": [ + "views/assets.xml", ], } diff --git a/l10n_it_pos_fatturapa/models/res_partner.py b/l10n_it_pos_fatturapa/models/res_partner.py index 4efed824bd58..0628f9e15f56 100644 --- a/l10n_it_pos_fatturapa/models/res_partner.py +++ b/l10n_it_pos_fatturapa/models/res_partner.py @@ -1,19 +1,22 @@ -# Copyright 2019 Roberto Fichera # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). from odoo import api, models class ResPartner(models.Model): - _inherit = 'res.partner' + _inherit = "res.partner" @api.model def create_from_ui(self, partner): - if 'electronic_invoice_subjected' in partner: - electronic_invoice_subjected = \ - partner['electronic_invoice_subjected'] == 'true' - partner['electronic_invoice_subjected'] = \ - electronic_invoice_subjected - partner['electronic_invoice_obliged_subject'] = \ - electronic_invoice_subjected + if "electronic_invoice_subjected" in partner: + electronic_invoice_subjected = bool( + partner.get("electronic_invoice_subjected") + ) + + partner.update( + { + "electronic_invoice_subjected": electronic_invoice_subjected, + "electronic_invoice_obliged_subject": electronic_invoice_subjected, + } + ) return super(ResPartner, self).create_from_ui(partner) diff --git a/l10n_it_pos_fatturapa/readme/CONTRIBUTORS.rst b/l10n_it_pos_fatturapa/readme/CONTRIBUTORS.rst index 1577ff9176ae..17c1e999643e 100644 --- a/l10n_it_pos_fatturapa/readme/CONTRIBUTORS.rst +++ b/l10n_it_pos_fatturapa/readme/CONTRIBUTORS.rst @@ -1 +1,3 @@ * Roberto Fichera +* berim +* Ooops404 diff --git a/l10n_it_pos_fatturapa/static/src/js/ClientDetailsEdit.js b/l10n_it_pos_fatturapa/static/src/js/ClientDetailsEdit.js new file mode 100644 index 000000000000..88a62dd6f11d --- /dev/null +++ b/l10n_it_pos_fatturapa/static/src/js/ClientDetailsEdit.js @@ -0,0 +1,26 @@ +odoo.define("l10n_it_pos_fatturapa.ClientDetailsEdit", function (require) { + "use strict"; + + const ClientDetailsEdit = require("point_of_sale.ClientDetailsEdit"); + const Registries = require("point_of_sale.Registries"); + + const PosClientDetailsEditCode = (ClientDetailsEdit) => + class extends ClientDetailsEdit { + captureChange(event) { + super.captureChange(event); + if (event.target.name === "electronic_invoice_subjected") { + const checked = event.currentTarget.checked; + this.changes[event.target.name] = Boolean(checked); + $(".electronic_invoice_subjected") + .toArray() + .forEach(function (el) { + $(el).css("display", checked ? "block" : "none"); + }); + } + } + }; + + Registries.Component.extend(ClientDetailsEdit, PosClientDetailsEditCode); + + return ClientDetailsEdit; +}); diff --git a/l10n_it_pos_fatturapa/static/src/js/models.js b/l10n_it_pos_fatturapa/static/src/js/models.js index 71f201451da4..1229609cc496 100644 --- a/l10n_it_pos_fatturapa/static/src/js/models.js +++ b/l10n_it_pos_fatturapa/static/src/js/models.js @@ -1,11 +1,13 @@ -odoo.define('l10n_it_pos_fatturapa.models', function (require) { +odoo.define("l10n_it_pos_fatturapa.models", function (require) { "use strict"; - var pos_models = require('point_of_sale.models'); - - pos_models.load_fields("res.partner", - ["electronic_invoice_subjected", "eori_code", - "codice_destinatario", "pec_destinatario", - "pa_partner_code"]); + var pos_models = require("point_of_sale.models"); + pos_models.load_fields("res.partner", [ + "electronic_invoice_subjected", + "eori_code", + "codice_destinatario", + "pec_destinatario", + "ipa_code", + ]); }); diff --git a/l10n_it_pos_fatturapa/static/src/js/screens.js b/l10n_it_pos_fatturapa/static/src/js/screens.js deleted file mode 100644 index 62302840ef49..000000000000 --- a/l10n_it_pos_fatturapa/static/src/js/screens.js +++ /dev/null @@ -1,19 +0,0 @@ -odoo.define('l10n_it_pos_fatturapa.screens', function (require) { - "use strict"; - - var Screens = require('point_of_sale.screens'); - - Screens.ClientListScreenWidget.include({ - - display_client_details: function(visibility,partner,clickpos){ - var self = this; - this._super.apply(self, arguments); - if (visibility === 'edit') { - this.$('.electronic_invoice_subjected').off('change').on('change', function(event) { - this.value = this.checked; - $('#electronic_invoice_subjected').css('display', this.checked ? 'block' : 'none'); - }); - } - }, - }); -}); diff --git a/l10n_it_pos_fatturapa/static/src/xml/pos.xml b/l10n_it_pos_fatturapa/static/src/xml/pos.xml deleted file mode 100644 index bdd835de4df9..000000000000 --- a/l10n_it_pos_fatturapa/static/src/xml/pos.xml +++ /dev/null @@ -1,60 +0,0 @@ - - - - - -
- - e-Invoice -
- -
-
- Code -
- - PEC -
- - EORI -
- - iPA Code - -
-
-
-
-
-
- - - -
- e-Invoice - - -
-
- Code - - - PEC - - - EORI - - - iPA Code - -
-
-
-
-
- -
diff --git a/l10n_it_pos_fatturapa/static/src/xml/pos_dump.xml b/l10n_it_pos_fatturapa/static/src/xml/pos_dump.xml new file mode 100644 index 000000000000..651474d3c47c --- /dev/null +++ b/l10n_it_pos_fatturapa/static/src/xml/pos_dump.xml @@ -0,0 +1,62 @@ + + + + + +
+ e-Invoice + +
+
+
+ Code + +
+
+ PEC + +
+
+ EORI + +
+
+ iPA Code + +
+
+
+
+ +
diff --git a/l10n_it_pos_fatturapa/views/assets.xml b/l10n_it_pos_fatturapa/views/assets.xml index 81bec3bcb296..1e6c233396ee 100644 --- a/l10n_it_pos_fatturapa/views/assets.xml +++ b/l10n_it_pos_fatturapa/views/assets.xml @@ -1,10 +1,16 @@ - +