From 950b0ae88d7769258ebb4a4d05f00538380f28c2 Mon Sep 17 00:00:00 2001 From: "Merlin (megu)" Date: Fri, 11 Feb 2022 09:47:39 +0000 Subject: [PATCH] [FIX] account: show tax reports of company's country MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The tax adjustment wizard shows tax reports of countries other than the current company's country Steps to reproduce: 1. Install Accounting 2. Go to Accounting > Configuration > Management > Tax Reports 3. Create a report for another country than the current company and add a line with a tag name 4. Go to Accounting > Accounting > Actions > Tax Adjustements (in debug mode) 5. The created tax report line is suggested but it shouldn't Solution: Put the domain of `tax_report_line_id` in python and add a filter on the country opw-2760337 closes odoo/odoo#84854 X-original-commit: cc13d20996f1e0a261829ced91cbbe18d6236fb5 Signed-off-by: William André (wan) --- addons/account/wizard/wizard_tax_adjustments.py | 15 ++++++++++++++- .../wizard/wizard_tax_adjustments_view.xml | 3 ++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/addons/account/wizard/wizard_tax_adjustments.py b/addons/account/wizard/wizard_tax_adjustments.py index 6214f572042..379b29bb715 100644 --- a/addons/account/wizard/wizard_tax_adjustments.py +++ b/addons/account/wizard/wizard_tax_adjustments.py @@ -20,10 +20,23 @@ class TaxAdjustments(models.TransientModel): domain="[('deprecated', '=', False), ('is_off_balance', '=', False)]") amount = fields.Monetary(currency_field='company_currency_id', required=True) adjustment_type = fields.Selection([('debit', 'Applied on debit journal item'), ('credit', 'Applied on credit journal item')], string="Adjustment Type", required=True) - tax_report_line_id = fields.Many2one(string="Report Line", comodel_name='account.tax.report.line', required=True, help="The report line to make an adjustment for.") + tax_report_line_id = fields.Many2one( + string="Report Line", + comodel_name='account.tax.report.line', + required=True, + domain="[('tag_name', '!=', None), ('report_id.country_id', 'in', fiscal_country_ids)]", + help="The report line to make an adjustment for.", + ) company_currency_id = fields.Many2one('res.currency', readonly=True, default=lambda x: x.env.company.currency_id) report_id = fields.Many2one(string="Report", related='tax_report_line_id.report_id') + fiscal_country_ids = fields.Many2many('res.country', compute='_compute_fiscal_country_ids', readonly=True) + @api.depends('journal_id') + def _compute_fiscal_country_ids(self): + for record in self: + fiscal_position_country_ids = record.env['account.fiscal.position'].search( + [('company_id', '=', record.journal_id.company_id.id), ('foreign_vat', '!=', False)]).country_id + record.fiscal_country_ids = record.journal_id.company_id.country_id + fiscal_position_country_ids def create_move(self): move_line_vals = [] diff --git a/addons/account/wizard/wizard_tax_adjustments_view.xml b/addons/account/wizard/wizard_tax_adjustments_view.xml index cee3de57bba..ed12812cf8e 100644 --- a/addons/account/wizard/wizard_tax_adjustments_view.xml +++ b/addons/account/wizard/wizard_tax_adjustments_view.xml @@ -11,7 +11,8 @@ - + +