[IMP] account: tax groups tree view: allow forcing the company of the accounts in domain

This was required by the introduction of tax units on enterprise. When making the closing for a tax unit, it is possible one (or more) of its companies don't have proper receivable/payable accounts configured on their tax groups. If so, a RedirectWarnings is raised pointing to this view in order to configure the groups from the company. All the companies of the unit are then active in the company selector, meaning that the record rules allow choosing accounts from any company, which is confusing and very error-prone.

To solve that, we introduce a context key, used to reduce to 1 the number of companie whose accounts are considered in the domains when configuring the tax groups.

closes odoo/odoo#70588

Related: odoo/upgrade#2482
Related: odoo/enterprise#18234
Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
This commit is contained in:
oco-odoo
2021-06-02 07:50:12 +00:00
parent 1e1c90f995
commit c4f17c69aa
+16 -3
View File
@@ -213,9 +213,22 @@
<field name="sequence" widget="handle"/>
<field name="name"/>
<field name="country_id"/>
<field name="property_tax_payable_account_id"/>
<field name="property_tax_receivable_account_id"/>
<field name="property_advance_tax_payment_account_id"/>
<!--
'force_account_company' context key is used so that the RedirectWarning
potentially raised during tax closing doesn't allow the user choosing
accounts from another company in case the multicompany selector
currently grants access to multiple companies.
-->
<field name="property_tax_payable_account_id"
domain="[('company_id', '=', context['force_account_company'])] if context.get('force_account_company') else []"
/>
<field name="property_tax_receivable_account_id"
domain="[('company_id', '=', context['force_account_company'])] if context.get('force_account_company') else []"
/>
<field name="property_advance_tax_payment_account_id"
domain="[('company_id', '=', context['force_account_company'])] if context.get('force_account_company') else []"
/>
</tree>
</field>
</record>