[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 <jco@odoo.com>
This commit is contained in:
bat-odoo
2023-03-10 13:32:41 +01:00
parent 1d8be6517f
commit 0fbf65c66d
7 changed files with 34 additions and 3 deletions
+1
View File
@@ -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',
+1
View File
@@ -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
+15
View File
@@ -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"))
+14
View File
@@ -0,0 +1,14 @@
<odoo>
<data>
<record id="product_uom_form_view_inherit" model="ir.ui.view">
<field name="name">product_uom_form_view_inherit</field>
<field name="model">uom.uom</field>
<field name="inherit_id" ref="uom.product_uom_form_view"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='name']" position="before">
<field name="fiscal_country_codes" invisible="1"/>
</xpath>
</field>
</record>
</data>
</odoo>
+1 -1
View File
@@ -18,7 +18,7 @@
<field name="inherit_id" ref="uom.product_uom_form_view"/>
<field name="arch" type="xml">
<field name="rounding" position="after">
<field name="l10n_ar_afip_code"/>
<field name="l10n_ar_afip_code" attrs="{'invisible': [('fiscal_country_codes', 'not ilike', 'AR')]}"/>
</field>
</field>
</record>
@@ -6,7 +6,7 @@
<field name="inherit_id" ref="uom.product_uom_form_view"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='uom_type']" position="after">
<field name="l10n_eg_unit_code_id"/>
<field name="l10n_eg_unit_code_id" attrs="{'invisible': [('fiscal_country_codes', 'not ilike', 'EG')]}"/>
</xpath>
</field>
</record>
+1 -1
View File
@@ -6,7 +6,7 @@
<field name="inherit_id" ref="uom.product_uom_form_view"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='category_id']" position="after">
<field name="l10n_in_code"/>
<field name="l10n_in_code" attrs="{'invisible': [('fiscal_country_codes', 'not ilike', 'IN')]}"/>
</xpath>
</field>
</record>