From 0fbf65c66de3b19485182478fd08d38b0abe2dfe Mon Sep 17 00:00:00 2001 From: bat-odoo Date: Tue, 14 Feb 2023 05:41:59 +0000 Subject: [PATCH] [IMP] account,l10n_*: added new field in UoM to hide/unhide fields in Localizations Currently, all localizations of UoM fields are visible in all countries. So in this commit, I have added a new compute field in UoM models, the field contains comma-separated company's country codes, and I have used this field for the hide/unhide fields. closes odoo/odoo#112604 Related: odoo/enterprise#36572 Related: odoo/upgrade#4284 Signed-off-by: Josse Colpaert --- addons/account/__manifest__.py | 1 + addons/account/models/__init__.py | 1 + addons/account/models/uom_uom.py | 15 +++++++++++++++ addons/account/views/uom_uom_views.xml | 14 ++++++++++++++ addons/l10n_ar/views/uom_uom_view.xml | 2 +- addons/l10n_eg_edi_eta/views/uom_uom_view.xml | 2 +- addons/l10n_in/views/uom_uom_views.xml | 2 +- 7 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 addons/account/models/uom_uom.py create mode 100644 addons/account/views/uom_uom_views.xml diff --git a/addons/account/__manifest__.py b/addons/account/__manifest__.py index 0ecd758732b..02d00494814 100644 --- a/addons/account/__manifest__.py +++ b/addons/account/__manifest__.py @@ -72,6 +72,7 @@ You could use this simplified accounting in case you work with an (external) acc 'wizard/accrued_orders.xml', 'views/bill_preview_template.xml', 'data/account_reports_data.xml', + 'views/uom_uom_views.xml', ], 'demo': [ 'demo/account_demo.xml', diff --git a/addons/account/models/__init__.py b/addons/account/models/__init__.py index dc13b1abd44..dedb26f5e69 100644 --- a/addons/account/models/__init__.py +++ b/addons/account/models/__init__.py @@ -38,3 +38,4 @@ from . import ir_module from . import res_currency from . import account_report from . import template_generic_coa +from . import uom_uom diff --git a/addons/account/models/uom_uom.py b/addons/account/models/uom_uom.py new file mode 100644 index 00000000000..0496dc73ddd --- /dev/null +++ b/addons/account/models/uom_uom.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from odoo import fields, models, api + + +class UoM(models.Model): + _inherit = "uom.uom" + + fiscal_country_codes = fields.Char(compute="_compute_fiscal_country_codes") + + @api.depends_context("allowed_company_ids") + def _compute_fiscal_country_codes(self): + for record in self: + record.fiscal_country_codes = ",".join(self.env.companies.mapped("account_fiscal_country_id.code")) diff --git a/addons/account/views/uom_uom_views.xml b/addons/account/views/uom_uom_views.xml new file mode 100644 index 00000000000..e47639d2bc0 --- /dev/null +++ b/addons/account/views/uom_uom_views.xml @@ -0,0 +1,14 @@ + + + + product_uom_form_view_inherit + uom.uom + + + + + + + + + diff --git a/addons/l10n_ar/views/uom_uom_view.xml b/addons/l10n_ar/views/uom_uom_view.xml index 218247e0712..883d61939e6 100644 --- a/addons/l10n_ar/views/uom_uom_view.xml +++ b/addons/l10n_ar/views/uom_uom_view.xml @@ -18,7 +18,7 @@ - + diff --git a/addons/l10n_eg_edi_eta/views/uom_uom_view.xml b/addons/l10n_eg_edi_eta/views/uom_uom_view.xml index 62ffe41d05a..eb8c2ba0f6b 100644 --- a/addons/l10n_eg_edi_eta/views/uom_uom_view.xml +++ b/addons/l10n_eg_edi_eta/views/uom_uom_view.xml @@ -6,7 +6,7 @@ - + diff --git a/addons/l10n_in/views/uom_uom_views.xml b/addons/l10n_in/views/uom_uom_views.xml index 15acdf90a4b..56daf2fd71b 100644 --- a/addons/l10n_in/views/uom_uom_views.xml +++ b/addons/l10n_in/views/uom_uom_views.xml @@ -6,7 +6,7 @@ - +