From 195bc157aba1e9bcd1c21b349580d1fb2022fc18 Mon Sep 17 00:00:00 2001 From: "Nasreddin Boulif (bon)" Date: Mon, 26 Sep 2022 20:25:02 +0000 Subject: [PATCH] [FIX] account, [l10n_ar_]website_sale: always display b2b fields Steps to reproduce: - Install `l10n_ar_website_sale` module - Go to shop (Argentinian website) and add a product to cart - Open cart and click on checkout - Click on Customize and disable `Show b2b fields` feature Issue: Fields are no more displayed. Cause: Since the b2b fields template (`address_b2b`) is customizable (meaning it can be enabled/disabled), it is possible for all countries to display/hide the b2b fields, but for some countries (for example Argentina) it should not; the b2b fields should always be displayed. Solution: Add a method (`_display_partner_b2b_fields`) on website model to know if b2b fields should be displayed: return True if `address_b2b` view is active on current website or if the company (based on the country) must display them. Move content (b2b fields; vat and company name fields) of view `address_b2b` in `address` main view and let the `address_b2b` only be used as switch to display or hide the b2b fields. Add a condition in `address` view to display b2b fields only if the method `_display_partner_b2b_fields` returns `True` opw-2941199 closes odoo/odoo#104505 X-original-commit: 1b5c85722db00a44ed8c6cb0c2bdba8905dc5292 Signed-off-by: Josse Colpaert Signed-off-by: Nasreddin Boulif (bon) --- addons/l10n_ar_website_sale/__init__.py | 1 + .../l10n_ar_website_sale/models/__init__.py | 4 ++ addons/l10n_ar_website_sale/models/website.py | 13 ++++++ .../l10n_ar_website_sale/views/templates.xml | 2 +- addons/website_sale/models/website.py | 7 ++++ addons/website_sale/views/templates.xml | 41 +++++++++---------- 6 files changed, 46 insertions(+), 22 deletions(-) create mode 100644 addons/l10n_ar_website_sale/models/__init__.py create mode 100644 addons/l10n_ar_website_sale/models/website.py diff --git a/addons/l10n_ar_website_sale/__init__.py b/addons/l10n_ar_website_sale/__init__.py index 2e55169e4f2..4dcc9d3a4b7 100644 --- a/addons/l10n_ar_website_sale/__init__.py +++ b/addons/l10n_ar_website_sale/__init__.py @@ -1,2 +1,3 @@ # Part of Odoo. See LICENSE file for full copyright and licensing details. from . import controllers +from . import models diff --git a/addons/l10n_ar_website_sale/models/__init__.py b/addons/l10n_ar_website_sale/models/__init__.py new file mode 100644 index 00000000000..dea4837b2a9 --- /dev/null +++ b/addons/l10n_ar_website_sale/models/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from . import website diff --git a/addons/l10n_ar_website_sale/models/website.py b/addons/l10n_ar_website_sale/models/website.py new file mode 100644 index 00000000000..18c6fed9dfe --- /dev/null +++ b/addons/l10n_ar_website_sale/models/website.py @@ -0,0 +1,13 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from odoo import models + + +class Website(models.Model): + _inherit = "website" + + def _display_partner_b2b_fields(self): + """ Argentinean localization must always display b2b fields """ + self.ensure_one() + return self.company_id.country_id.code == "AR" or super()._display_partner_b2b_fields() diff --git a/addons/l10n_ar_website_sale/views/templates.xml b/addons/l10n_ar_website_sale/views/templates.xml index 572bca41d2a..e9cb6840582 100644 --- a/addons/l10n_ar_website_sale/views/templates.xml +++ b/addons/l10n_ar_website_sale/views/templates.xml @@ -43,7 +43,7 @@ -