2
0

[FIX+IMP] account_chart_update: Several things

* Set updated taxes as active
* Check parent_id field in '_is_different_tax' method
* PEP8
* Spanish translation
This commit is contained in:
Antonio Espinosa 2015-06-05 22:00:47 +02:00 committed by Luis J. Salvatierra
parent bc483a106f
commit 317bb9f542
2 changed files with 19 additions and 8 deletions

View File

@ -38,6 +38,7 @@ Contributors
* Joaquín Gutierrez <joaquingpedrosa@gmail.com> * Joaquín Gutierrez <joaquingpedrosa@gmail.com>
* invitu * invitu
* Stéphane Bidoul <stephane.bidoul@acsone.eu> * Stéphane Bidoul <stephane.bidoul@acsone.eu>
* Antonio Espinosa <antonioea@antiun.com>
Maintainer Maintainer
---------- ----------

View File

@ -4,6 +4,8 @@
# Copyright (c) 2010 Zikzakmedia S.L. (http://www.zikzakmedia.com) # Copyright (c) 2010 Zikzakmedia S.L. (http://www.zikzakmedia.com)
# Copyright (c) 2010 Pexego Sistemas Informáticos S.L.(http://www.pexego.es) # Copyright (c) 2010 Pexego Sistemas Informáticos S.L.(http://www.pexego.es)
# @authors: Jordi Esteve (Zikzakmedia), Borja López Soilán (Pexego) # @authors: Jordi Esteve (Zikzakmedia), Borja López Soilán (Pexego)
# Copyright (c) 2015 Antiun Ingeniería S.L. (http://www.antiun.com)
# Antonio Espinosa <antonioea@antiun.com>
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published # it under the terms of the GNU Affero General Public License as published
@ -560,12 +562,14 @@ class WizardUpdateChartsAccounts(models.TransientModel):
'notes': _("To deactivate: not in the template"), 'notes': _("To deactivate: not in the template"),
}) })
def _is_different_tax(self, tax, tax_template, mapping_tax_codes, def _is_different_tax(self, tax, tax_template, mapping_taxes,
mapping_accounts): mapping_tax_codes, mapping_accounts):
"""Check the tax for changes. """Check the tax for changes.
:return: An string that will be empty if no change detected. :return: An string that will be empty if no change detected.
""" """
notes = "" notes = ""
if not tax.active:
notes += _("Tax is disabled.\n")
if tax.name != tax_template.name: if tax.name != tax_template.name:
notes += _("The name field is different.\n") notes += _("The name field is different.\n")
if tax.description != tax_template.description: if tax.description != tax_template.description:
@ -582,6 +586,9 @@ class WizardUpdateChartsAccounts(models.TransientModel):
notes += _("The domain field is different.\n") notes += _("The domain field is different.\n")
if tax.child_depend != tax_template.child_depend: if tax.child_depend != tax_template.child_depend:
notes += _("The child depend field is different.\n") notes += _("The child depend field is different.\n")
if tax.parent_id != self.map_tax_template(tax_template.parent_id,
mapping_taxes):
notes += _("The parent_id field is different.\n")
if tax.python_compute != tax_template.python_compute: if tax.python_compute != tax_template.python_compute:
notes += _("The python compute field is different.\n") notes += _("The python compute field is different.\n")
# if tax.tax_group != tax_template.tax_group: # if tax.tax_group != tax_template.tax_group:
@ -648,7 +655,8 @@ class WizardUpdateChartsAccounts(models.TransientModel):
else: else:
# Check the tax for changes. # Check the tax for changes.
notes = self._is_different_tax( notes = self._is_different_tax(
tax, tax_template, mapping_tax_codes, mapping_accounts) tax, tax_template, mapping_taxes, mapping_tax_codes,
mapping_accounts)
if notes: if notes:
# Tax code to update. # Tax code to update.
wiz_taxes_obj.create({ wiz_taxes_obj.create({
@ -754,7 +762,8 @@ class WizardUpdateChartsAccounts(models.TransientModel):
break break
if not found: if not found:
msg = fp_tax_templ.tax_dest_id.name or _('None') msg = fp_tax_templ.tax_dest_id.name or _('None')
notes += _("Tax mapping not found on the fiscal position " notes += _(
"Tax mapping not found on the fiscal position "
"instance: %s -> %s.\n") % ( "instance: %s -> %s.\n") % (
fp_tax_templ.tax_src_id.name, msg) fp_tax_templ.tax_src_id.name, msg)
elif fp_template.tax_ids and not fp.tax_ids: elif fp_template.tax_ids and not fp.tax_ids:
@ -872,6 +881,7 @@ class WizardUpdateChartsAccounts(models.TransientModel):
def _prepare_tax_vals(self, tax_template, mapping_tax_codes, def _prepare_tax_vals(self, tax_template, mapping_tax_codes,
mapping_taxes): mapping_taxes):
return { return {
'active': True,
'name': tax_template.name, 'name': tax_template.name,
'sequence': tax_template.sequence, 'sequence': tax_template.sequence,
'amount': tax_template.amount, 'amount': tax_template.amount,