From d86a4405c71026476c70b1851d7a9ef63a4b080c Mon Sep 17 00:00:00 2001 From: David Beal Date: Wed, 22 May 2019 09:20:38 +0200 Subject: [PATCH] [IMP] tax_balance: breadcrumb name (#548) --- account_tax_balance/__manifest__.py | 2 +- .../tests/test_account_tax_balance.py | 2 -- .../wizard/open_tax_balances.py | 22 +++++++++++++++++-- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/account_tax_balance/__manifest__.py b/account_tax_balance/__manifest__.py index 6d48462c..d16667b1 100644 --- a/account_tax_balance/__manifest__.py +++ b/account_tax_balance/__manifest__.py @@ -6,7 +6,7 @@ { "name": "Tax Balance", "summary": "Compute tax balances based on date range", - "version": "12.0.1.0.0", + "version": "12.0.1.1.0", "category": "Invoices & Payments", "website": "https://github.com/OCA/account-financial-reporting", "author": "Agile Business Group, Therp BV, Tecnativa, ACSONE SA/NV, " diff --git a/account_tax_balance/tests/test_account_tax_balance.py b/account_tax_balance/tests/test_account_tax_balance.py index 6c140162..a971eeea 100644 --- a/account_tax_balance/tests/test_account_tax_balance.py +++ b/account_tax_balance/tests/test_account_tax_balance.py @@ -105,8 +105,6 @@ class TestAccountTaxBalance(HttpCase): action['context']['from_date'], current_range[0].date_start) self.assertEqual( action['context']['to_date'], current_range[0].date_end) - self.assertEqual( - action['xml_id'], 'account_tax_balance.action_tax_balances_tree') # exercise search has_moves = True taxes = self.env['account.tax'].search([('has_moves', '=', True)]) diff --git a/account_tax_balance/wizard/open_tax_balances.py b/account_tax_balance/wizard/open_tax_balances.py index 2a45efbc..6063a9db 100644 --- a/account_tax_balance/wizard/open_tax_balances.py +++ b/account_tax_balance/wizard/open_tax_balances.py @@ -1,7 +1,7 @@ # © 2016 Lorenzo Battistini - Agile Business Group # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from odoo import api, fields, models +from odoo import _, api, fields, models class WizardOpenTaxBalances(models.TransientModel): @@ -31,7 +31,25 @@ class WizardOpenTaxBalances(models.TransientModel): def open_taxes(self): self.ensure_one() action = self.env.ref('account_tax_balance.action_tax_balances_tree') - vals = action.read()[0] + act_vals = action.read()[0] + # override action name doesn't work in v12 or v10 + # we need to build a dynamic action on main keys + vals = {x: act_vals[x] for x in act_vals + if x in ('res_model', 'view_mode', 'domain', + 'view_id', 'search_view_id', 'name', 'type')} + lang = self.env['res.lang'].search( + [('code', '=', self.env.user.lang or 'en_US')]) + date_format = lang and lang.date_format or "%m/%d/%Y" + infos = {'name': vals['name'], 'target': _(self.target_move), + 'from': self.from_date.strftime(date_format), + 'to': self.to_date.strftime(date_format), + 'company': self.company_id.name} + # name of action which is displayed in breacrumb + vals["name"] = _( + "%(name)s: %(target)s from %(from)s to %(to)s") % infos + multi_cpny_grp = self.env.ref('base.group_multi_company') + if multi_cpny_grp in self.env.user.groups_id: + vals['name'] = '%s (%s)' % (vals['name'], self.company_id.name) vals['context'] = { 'from_date': self.from_date, 'to_date': self.to_date,