From a560d62acd8fb74a65e2c63ad673df650db8226b Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Wed, 27 Jan 2016 20:38:30 +0100 Subject: [PATCH] [FIX] account_chart_update: Don't write code on account update As there's a constraint that forbids to write the code of the account if it has moves, we delete the corresponding entry on update only, because the method that prepares the values is the same for new and existing accounts. --- account_chart_update/wizard/wizard_chart_update.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/account_chart_update/wizard/wizard_chart_update.py b/account_chart_update/wizard/wizard_chart_update.py index 005c3a2f..b976995a 100644 --- a/account_chart_update/wizard/wizard_chart_update.py +++ b/account_chart_update/wizard/wizard_chart_update.py @@ -1026,12 +1026,14 @@ class WizardUpdateChartsAccounts(models.TransientModel): else: # Update the account account = wiz_account.update_account_id + # Don't write again the same code - it may give an error + code = vals.pop('code') try: account.write(vals) - log.add(_("Updated account %s.\n") % vals['code']) + log.add(_("Updated account %s.\n") % code) except (exceptions.Warning, except_orm, except_osv) as ex: log.add(_("Exception writing account %s: %s - %s.\n") % - (vals['code'], ex.name, ex.value), True) + (code, ex.name, ex.value), True) # Set this account as the parent of the accounts that seem to # be its children (brothers starting with the same code). if self.update_children_accounts_parent: