[FIX] account: check if tax name on copy method

With this commit, it will check if the tax name is given by external method and take that name if any.

For example,
vals = {'rate': 5.2, 'name': 'Odoo New Tax'}
tax_template = self.env['account.tax'].search(domain, limit=1)
new_tax = tax_template.copy(default=vals)

Current Behavior:
new_tax.name => 'Odoo New Tax (Copy)'

Instead of 'Odoo New tax'

closes odoo/odoo#75406

X-original-commit: 10a5ecceead2f450822387c6f1f2d98f98317a15
Signed-off-by: oco-odoo <oco-odoo@users.noreply.github.com>
This commit is contained in:
Bhavesh Odedra
2021-08-26 13:56:26 +00:00
committed by oco-odoo
parent 01b12bdcf2
commit 6cb526fe91
+3 -1
View File
@@ -214,7 +214,9 @@ class AccountTax(models.Model):
@api.returns('self', lambda value: value.id)
def copy(self, default=None):
default = dict(default or {}, name=_("%s (Copy)", self.name))
default = dict(default or {})
if 'name' not in default:
default['name'] = _("%s (Copy)") % self.name
return super(AccountTax, self).copy(default=default)
def name_get(self):