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>
* invitu
* Stéphane Bidoul <stephane.bidoul@acsone.eu>
* Antonio Espinosa <antonioea@antiun.com>
Maintainer
----------

View File

@ -4,6 +4,8 @@
# Copyright (c) 2010 Zikzakmedia S.L. (http://www.zikzakmedia.com)
# Copyright (c) 2010 Pexego Sistemas Informáticos S.L.(http://www.pexego.es)
# @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
# 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"),
})
def _is_different_tax(self, tax, tax_template, mapping_tax_codes,
mapping_accounts):
def _is_different_tax(self, tax, tax_template, mapping_taxes,
mapping_tax_codes, mapping_accounts):
"""Check the tax for changes.
:return: An string that will be empty if no change detected.
"""
notes = ""
if not tax.active:
notes += _("Tax is disabled.\n")
if tax.name != tax_template.name:
notes += _("The name field is different.\n")
if tax.description != tax_template.description:
@ -582,6 +586,9 @@ class WizardUpdateChartsAccounts(models.TransientModel):
notes += _("The domain field is different.\n")
if tax.child_depend != tax_template.child_depend:
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:
notes += _("The python compute field is different.\n")
# if tax.tax_group != tax_template.tax_group:
@ -648,7 +655,8 @@ class WizardUpdateChartsAccounts(models.TransientModel):
else:
# Check the tax for changes.
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:
# Tax code to update.
wiz_taxes_obj.create({
@ -754,9 +762,10 @@ class WizardUpdateChartsAccounts(models.TransientModel):
break
if not found:
msg = fp_tax_templ.tax_dest_id.name or _('None')
notes += _("Tax mapping not found on the fiscal position "
"instance: %s -> %s.\n") % (
fp_tax_templ.tax_src_id.name, msg)
notes += _(
"Tax mapping not found on the fiscal position "
"instance: %s -> %s.\n") % (
fp_tax_templ.tax_src_id.name, msg)
elif fp_template.tax_ids and not fp.tax_ids:
notes += _("The template has taxes the fiscal position instance "
"does not.\n")
@ -777,8 +786,8 @@ class WizardUpdateChartsAccounts(models.TransientModel):
notes += _(
"Account mapping not found on the fiscal "
"position instance: %s -> %s.\n") % (
fp_acc_templ.account_src_id.name,
fp_acc_templ.account_dest_id.name)
fp_acc_templ.account_src_id.name,
fp_acc_templ.account_dest_id.name)
elif fp_template.account_ids and not fp.account_ids:
notes += _("The template has accounts the fiscal position "
"instance does not.\n")
@ -872,6 +881,7 @@ class WizardUpdateChartsAccounts(models.TransientModel):
def _prepare_tax_vals(self, tax_template, mapping_tax_codes,
mapping_taxes):
return {
'active': True,
'name': tax_template.name,
'sequence': tax_template.sequence,
'amount': tax_template.amount,