From 35ff8d96712f6c96ffefcd2d49751f573e4a8649 Mon Sep 17 00:00:00 2001
From: Nicolas Bessi
Date: Mon, 30 Jun 2014 11:12:36 +0200
Subject: [PATCH] Set all addons to uninstallable
---
account_chart_update/__init__.py | 5 +-
account_chart_update/__openerp__.py | 18 +-
account_chart_update/wizard/__init__.py | 5 +-
.../wizard/wizard_chart_update.py | 794 ++++++++++++------
.../wizard/wizard_chart_update_view.xml | 151 ----
5 files changed, 535 insertions(+), 438 deletions(-)
delete mode 100644 account_chart_update/wizard/wizard_chart_update_view.xml
diff --git a/account_chart_update/__init__.py b/account_chart_update/__init__.py
index 36d5407d..d04374b7 100644
--- a/account_chart_update/__init__.py
+++ b/account_chart_update/__init__.py
@@ -2,7 +2,8 @@
##############################################################################
#
# 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)
#
# This program is free software: you can redistribute it and/or modify
@@ -22,4 +23,4 @@
"""
Account Chart Update Wizard
"""
-import wizard
+from . import wizard
diff --git a/account_chart_update/__openerp__.py b/account_chart_update/__openerp__.py
index fc619522..1ebdbfc8 100644
--- a/account_chart_update/__openerp__.py
+++ b/account_chart_update/__openerp__.py
@@ -3,7 +3,7 @@
#
# OpenERP, Open Source Management Solution
# 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)
# Copyright (c) 2013 Joaquin Gutierrez (http://www.gutierrezweb.es)
# Pedro Manuel Baeza
# $Id$
@@ -26,7 +26,7 @@
{
'name': "Detect changes and update the Account Chart from a template",
- 'version': "1.1",
+ 'version': "1.2",
'author': "Zikzakmedia SL",
'website': "www.zikzakmedia.com",
'depends': ["account"],
@@ -41,23 +41,25 @@
Adds a wizard to update a company account chart from a chart template.
======================================================================
-This is a pretty useful tool to update OpenERP instalations after tax reforms
-on the oficial charts of accounts, or to apply fixes performed on the chart
+This is a pretty useful tool to update OpenERP installations after tax reforms
+on the official charts of accounts, or to apply fixes performed on the chart
template.
The wizard:
+
- Allows the user to compare a chart and a template showing differences
- on accounts, taxes, tax codes and fiscal positions.
+ on accounts, taxes, tax codes and fiscal positions.
- It may create the new account, taxes, tax codes and fiscal positions detected
- on the template.
+ on the template.
- It can also update (overwrite) the accounts, taxes, tax codes and fiscal
- positions that got modified on the template.
+ positions that got modified on the template.
The wizard lets the user select what kind of objects must be checked/updated,
-and whether old records must be checked for changes and updated.
+and whether old records must be checked for changes and updates.
It will display all the accounts to be created / updated with some information
about the detected differences, and allow the user to exclude records
individually.
+
Any problem found while updating will be shown on the last step.
""",
'license': "AGPL-3",
diff --git a/account_chart_update/wizard/__init__.py b/account_chart_update/wizard/__init__.py
index 8d0cfc9e..787022f1 100644
--- a/account_chart_update/wizard/__init__.py
+++ b/account_chart_update/wizard/__init__.py
@@ -2,7 +2,8 @@
##############################################################################
#
# 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)
#
# This program is free software: you can redistribute it and/or modify
@@ -22,4 +23,4 @@
"""
Account Chart Update Wizard
"""
-import wizard_chart_update
+from . import wizard_chart_update
diff --git a/account_chart_update/wizard/wizard_chart_update.py b/account_chart_update/wizard/wizard_chart_update.py
index be17b466..1cd81750 100644
--- a/account_chart_update/wizard/wizard_chart_update.py
+++ b/account_chart_update/wizard/wizard_chart_update.py
@@ -2,7 +2,7 @@
##############################################################################
#
# 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)
#
# This program is free software: you can redistribute it and/or modify
@@ -36,7 +36,8 @@ def _reopen(self, res_id, model):
'res_id': res_id,
'res_model': self._name,
'target': 'new',
- # save original model in context, because selecting the list of available
+ # save original model in context,
+ # because selecting the list of available
# templates requires a model in context
'context': {
'default_model': model,
@@ -54,10 +55,10 @@ class WizardLog:
self.messages = []
self.errors = []
- """
- Adds a message to the log.
- """
def add(self, message, is_error=False):
+ """
+ Adds a message to the log.
+ """
logger = logging.getLogger("account_chart_update")
if is_error:
logger.warning(u"Log line: %s" % message)
@@ -66,10 +67,10 @@ class WizardLog:
logger.debug(u"Log line: %s" % message)
self.messages.append(message)
- """
- Returns whether errors where logged.
- """
def has_errors(self):
+ """
+ Returns whether errors where logged.
+ """
return self.errors
def __call__(self):
@@ -85,10 +86,10 @@ class WizardLog:
class wizard_update_charts_accounts(orm.TransientModel):
_name = 'wizard.update.charts.accounts'
- """
- Gets the available languages for the selection.
- """
- def _get_lang_selection_options(self, cr, uid, context={}):
+ def _get_lang_selection_options(self, cr, uid, context=None):
+ """
+ Gets the available languages for the selection.
+ """
obj = self.pool.get('res.lang')
ids = obj.search(cr, uid, [], context=context)
res = obj.read(cr, uid, ids, ['code', 'name'], context)
@@ -100,36 +101,111 @@ class wizard_update_charts_accounts(orm.TransientModel):
('ready', 'Step 2'),
('done', 'Wizard completed')
], 'Status', readonly=True),
- 'company_id': fields.many2one('res.company', 'Company', required=True, ondelete='set null'),
+ 'company_id': fields.many2one(
+ 'res.company',
+ 'Company',
+ required=True,
+ ondelete='set null'
+ ),
'chart_template_id': fields.many2one(
- 'account.chart.template', 'Chart Template', ondelete='cascade',
- required=True),
- 'code_digits': fields.integer('# of digits', required=True, help="No. of digits to use for account code. Make sure it is the same number as existing accounts."),
- 'lang': fields.selection(_get_lang_selection_options, 'Language', size=5, help="For records searched by name (taxes, tax codes, fiscal positions), the template name will be matched against the record name on this language."),
- 'update_tax_code': fields.boolean('Update tax codes', help="Existing tax codes are updated. Tax codes are searched by name."),
- 'update_tax': fields.boolean('Update taxes', help="Existing taxes are updated. Taxes are searched by name."),
- 'update_account': fields.boolean('Update accounts', help="Existing accounts are updated. Accounts are searched by code."),
- 'update_fiscal_position': fields.boolean('Update fiscal positions', help="Existing fiscal positions are updated. Fiscal positions are searched by name."),
- 'update_children_accounts_parent': fields.boolean("Update children accounts parent",
- help="Update the parent of accounts that seem (based on the code) to be children of the newly created ones. If you had an account 430 with a child 4300000, and a 4300 account is created, the 4300000 parent will be set to 4300."),
- 'continue_on_errors': fields.boolean("Continue on errors", help="If set, the wizard will continue to the next step even if there are minor errors (for example the parent account of a new account couldn't be set)."),
- 'tax_code_ids': fields.one2many('wizard.update.charts.accounts.tax.code', 'update_chart_wizard_id', 'Tax codes', ondelete='cascade'),
- 'tax_ids': fields.one2many('wizard.update.charts.accounts.tax', 'update_chart_wizard_id', 'Taxes', ondelete='cascade'),
- 'account_ids': fields.one2many('wizard.update.charts.accounts.account', 'update_chart_wizard_id', 'Accounts', ondelete='cascade'),
- 'fiscal_position_ids': fields.one2many('wizard.update.charts.accounts.fiscal.position', 'update_chart_wizard_id', 'Fiscal positions', ondelete='cascade'),
+ 'account.chart.template',
+ 'Chart Template',
+ ondelete='cascade',
+ required=True
+ ),
+ 'code_digits': fields.integer(
+ '# of digits',
+ required=True,
+ help="No. of digits to use for account code. "
+ "Make sure it is the same number as existing accounts."
+ ),
+ 'lang': fields.selection(
+ _get_lang_selection_options,
+ 'Language',
+ size=5,
+ help="For records searched by name "
+ "(taxes, tax codes, fiscal positions), "
+ "the template name will be matched against the record "
+ "name on this language."
+ ),
+ 'update_tax_code': fields.boolean(
+ 'Update tax codes',
+ help="Existing tax codes are updated."
+ " Tax codes are searched by name."
+ ),
+ 'update_tax': fields.boolean(
+ 'Update taxes',
+ help="Existing taxes are updated. Taxes are searched by name."
+ ),
+ 'update_account': fields.boolean(
+ 'Update accounts',
+ help="Existing accounts are updated. "
+ "Accounts are searched by code."
+ ),
+ 'update_fiscal_position': fields.boolean(
+ 'Update fiscal positions',
+ help="Existing fiscal positions are updated. "
+ "Fiscal positions are searched by name."
+ ),
+ 'update_children_accounts_parent': fields.boolean(
+ "Update children accounts parent",
+ help="Update the parent of accounts that seem (based on the code)"
+ " to be children of the newly created ones."
+ " If you had an account 430 with a child 4300000, and a 4300 "
+ "account is created, the 4300000 parent will be set to 4300."
+ ),
+ 'continue_on_errors': fields.boolean(
+ "Continue on errors",
+ help="If set, the wizard will continue to the next step even if "
+ "there are minor errors (for example the parent account "
+ "of a new account couldn't be set)."
+ ),
+ 'tax_code_ids': fields.one2many(
+ 'wizard.update.charts.accounts.tax.code',
+ 'update_chart_wizard_id',
+ 'Tax codes',
+ ondelete='cascade'
+ ),
+ 'tax_ids': fields.one2many(
+ 'wizard.update.charts.accounts.tax',
+ 'update_chart_wizard_id',
+ 'Taxes',
+ ondelete='cascade'
+ ),
+ 'account_ids': fields.one2many(
+ 'wizard.update.charts.accounts.account',
+ 'update_chart_wizard_id',
+ 'Accounts',
+ ondelete='cascade'
+ ),
+ 'fiscal_position_ids': fields.one2many(
+ 'wizard.update.charts.accounts.fiscal.position',
+ 'update_chart_wizard_id',
+ 'Fiscal positions',
+ ondelete='cascade'
+ ),
'new_tax_codes': fields.integer('New tax codes', readonly=True),
'new_taxes': fields.integer('New taxes', readonly=True),
'new_accounts': fields.integer('New accounts', readonly=True),
'new_fps': fields.integer('New fiscal positions', readonly=True),
- 'updated_tax_codes': fields.integer('Updated tax codes', readonly=True),
+ 'updated_tax_codes': fields.integer(
+ 'Updated tax codes',
+ readonly=True
+ ),
'updated_taxes': fields.integer('Updated taxes', readonly=True),
'updated_accounts': fields.integer('Updated accounts', readonly=True),
- 'updated_fps': fields.integer('Updated fiscal positions', readonly=True),
+ 'updated_fps': fields.integer(
+ 'Updated fiscal positions',
+ readonly=True
+ ),
'log': fields.text('Messages and Errors', readonly=True)
}
def name_search(self, cr, user, name,
args=None, operator='ilike', context=None, limit=80):
+ """
+ Redefine the search to search by company name.
+ """
if not name:
name = '%'
if not args:
@@ -142,10 +218,10 @@ class wizard_update_charts_accounts(orm.TransientModel):
cr, user, [('company_id', operator, name)] + args, limit=limit)
return self.name_get(cr, user, ids, context=context)
- """
- Use the company name and template as name.
- """
def name_get(self, cr, uid, ids, context=None):
+ """
+ Use the company name and template as name.
+ """
if context is None:
context = {}
if not len(ids):
@@ -157,10 +233,10 @@ class wizard_update_charts_accounts(orm.TransientModel):
' - ' + record.chart_template_id.name))
return res
- """
- Returns the default chart template.
- """
def _get_chart(self, cr, uid, context=None):
+ """
+ Returns the default chart template.
+ """
if context is None:
context = {}
ids = self.pool.get(
@@ -169,13 +245,13 @@ class wizard_update_charts_accounts(orm.TransientModel):
return ids[0]
return False
- """
- Returns the default code size for the accounts.
- To figure out the number of digits of the accounts it look at the
- code size of the default receivable account of the company
- (or user's company if any company is given).
- """
def _get_code_digits(self, cr, uid, context=None, company_id=None):
+ """
+ Returns the default code size for the accounts.
+ To figure out the number of digits of the accounts it look at the
+ code size of the default receivable account of the company
+ (or user's company if any company is given).
+ """
if context is None:
context = {}
property_obj = self.pool.get('ir.property')
@@ -209,7 +285,9 @@ class wizard_update_charts_accounts(orm.TransientModel):
_defaults = {
'state': 'init',
- 'company_id': lambda self, cr, uid, context: self.pool.get('res.users').browse(cr, uid, [uid], context)[0].company_id.id,
+ 'company_id': lambda self, cr, uid, context:
+ self.pool.get('res.users').browse(
+ cr, uid, [uid], context)[0].company_id.id,
'chart_template_id': _get_chart,
'update_tax_code': True,
'update_tax': True,
@@ -217,24 +295,26 @@ class wizard_update_charts_accounts(orm.TransientModel):
'update_fiscal_position': True,
'update_children_accounts_parent': True,
'continue_on_errors': False,
- 'lang': lambda self, cr, uid, context: context and context.get('lang') or None,
+ 'lang': lambda self, cr, uid, context:
+ context and context.get('lang') or None,
}
- """
- Update the code size when the company changes
- """
def onchange_company_id(self, cr, uid, ids, company_id, context=None):
+ """
+ Update the code size when the company changes
+ """
res = {
'value': {
- 'code_digits': self._get_code_digits(cr, uid, context=context, company_id=company_id),
+ 'code_digits': self._get_code_digits(
+ cr, uid, context=context, company_id=company_id),
}
}
return res
- """
- Initial action that sets the initial state.
- """
def action_init(self, cr, uid, ids, context=None):
+ """
+ Initial action that sets the initial state.
+ """
if context is None:
context = {}
wizard = self.browse(cr, uid, ids[0], context=context)
@@ -317,14 +397,15 @@ class wizard_update_charts_accounts(orm.TransientModel):
if acc_templ.type != 'view':
if code and len(code) <= wizard.code_digits:
code = '%s%s' % (code, '0' * (wizard.code_digits - len(code)))
- acc_ids = acc_obj.search(cr, uid, [
- ('code', '=', code),
- ('company_id', '=', wizard.company_id.id)
- ], context=context)
+ acc_ids = acc_obj.search(cr, uid,
+ [('code', '=', code),
+ ('company_id', '=', wizard.company_id.id)],
+ context=context)
acc_templ_mapping[acc_templ.id] = acc_ids and acc_ids[0] or False
return acc_templ_mapping[acc_templ.id]
- def _map_fp_template(self, cr, uid, wizard, fp_templ_mapping, fp_template, context=None):
+ def _map_fp_template(self, cr, uid, wizard, fp_templ_mapping,
+ fp_template, context=None):
"""
Adds a fiscal position template -> fiscal position id to the mapping.
"""
@@ -345,7 +426,7 @@ class wizard_update_charts_accounts(orm.TransientModel):
context=None):
"""
Search for, and load, tax code templates to create/update.
-
+
@param chart_template_ids: IDs of the chart templates to look on,
calculated once in the calling method.
"""
@@ -360,18 +441,20 @@ class wizard_update_charts_accounts(orm.TransientModel):
# Remove previous tax codes
wiz_tax_code_obj.unlink(cr, uid, wiz_tax_code_obj.search(cr, uid, []))
# Search for new / updated tax codes
- #
root_tax_code_id = wizard.chart_template_id.tax_code_root_id.id
children_tax_code_template = tax_code_templ_obj.search(cr, uid, [(
'parent_id', 'child_of', [root_tax_code_id])], order='id',
context=context)
- for tax_code_template in tax_code_templ_obj.browse(cr, uid,
- children_tax_code_template, context=context):
+ for tax_code_template in tax_code_templ_obj.browse(
+ cr, uid,
+ children_tax_code_template, context=context):
# Ensure the tax code template is on the map (search for the mapped
# tax code id).
- tax_code_id = self._map_tax_code_template(cr, uid, wizard,
- tax_code_template_mapping,
- tax_code_template, context=context)
+ tax_code_id = self._map_tax_code_template(
+ cr, uid, wizard,
+ tax_code_template_mapping,
+ tax_code_template, context=context
+ )
if not tax_code_id:
new_tax_codes += 1
wiz_tax_code_obj.create(cr, uid, {
@@ -381,9 +464,6 @@ class wizard_update_charts_accounts(orm.TransientModel):
'notes': _('Name or code not found.'),
}, context)
elif wizard.update_tax_code:
- #
- # Check the tax code for changes.
- #
modified = False
notes = ""
tax_code = tax_code_obj.browse(
@@ -399,9 +479,6 @@ class wizard_update_charts_accounts(orm.TransientModel):
modified = True
# TODO: We could check other account fields for changes...
if modified:
- #
- # Tax code to update.
- #
updated_tax_codes += 1
wiz_tax_code_obj.create(cr, uid, {
'tax_code_id': tax_code_template.id,
@@ -419,7 +496,7 @@ class wizard_update_charts_accounts(orm.TransientModel):
def _find_taxes(self, cr, uid, wizard, chart_template_ids, context=None):
"""
Search for, and load, tax templates to create/update.
-
+
@param chart_template_ids: IDs of the chart templates to look on,
calculated once in the calling method.
"""
@@ -456,9 +533,6 @@ class wizard_update_charts_accounts(orm.TransientModel):
else:
delay_wiz_tax.append(vals_wiz)
elif wizard.update_tax:
- #
- # Check the tax for changes.
- #
modified = False
notes = ""
tax = tax_obj.browse(cr, uid, tax_id, context=context)
@@ -500,9 +574,7 @@ class wizard_update_charts_accounts(orm.TransientModel):
modified = True
# TODO: We could check other tax fields for changes...
if modified:
- #
# Tax code to update.
- #
updated_taxes += 1
wiz_taxes_obj.create(cr, uid, {
'tax_id': tax_templ.id,
@@ -514,11 +586,10 @@ class wizard_update_charts_accounts(orm.TransientModel):
for delay_vals_wiz in delay_wiz_tax:
wiz_taxes_obj.create(cr, uid, delay_vals_wiz, context)
- return {'new': new_taxes, 'updated': updated_taxes, 'mapping': tax_templ_mapping}
+ return {'new': new_taxes,
+ 'updated': updated_taxes,
+ 'mapping': tax_templ_mapping}
- """
- Search for, and load, account templates to create/update.
- """
def _find_accounts(self, cr, uid, wizard, context=None):
"""
Search for, and load, account templates to create/update.
@@ -535,15 +606,16 @@ class wizard_update_charts_accounts(orm.TransientModel):
wiz_accounts_ids = wiz_accounts.search(cr, uid, [], context=context)
wiz_accounts.unlink(cr, uid, wiz_accounts_ids, context=context)
# Search for new / updated accounts
- #
root_account_id = wizard.chart_template_id.account_root_id.id
acc_templ_criteria = [('chart_template_id',
'=',
wizard.chart_template_id.id)]
if root_account_id:
- acc_templ_criteria = (['|'] + acc_templ_criteria +
- ['&', ('parent_id', 'child_of', [root_account_id]),
- ('chart_template_id', '=', False)])
+ acc_templ_criteria = (
+ ['|'] + acc_templ_criteria +
+ ['&', ('parent_id', 'child_of', [root_account_id]),
+ ('chart_template_id', '=', False)]
+ )
acc_ids = acc_templ_obj.search(cr, uid, acc_templ_criteria,
context=context)
acc_ids.sort()
@@ -564,13 +636,12 @@ class wizard_update_charts_accounts(orm.TransientModel):
'notes': _('Code not found.'),
}, context)
elif wizard.update_account:
- #
# Check the account for changes.
- #
modified = False
notes = ""
account = acc_obj.browse(cr, uid, account_id, context=context)
- if account.name != acc_templ.name and account.name != wizard.company_id.name:
+ if (account.name != acc_templ.name and
+ account.name != wizard.company_id.name):
notes += _("The name is different.\n")
modified = True
if account.type != acc_templ.type:
@@ -584,9 +655,7 @@ class wizard_update_charts_accounts(orm.TransientModel):
modified = True
# TODO: We could check other account fields for changes...
if modified:
- #
# Account to update.
- #
updated_accounts += 1
wiz_accounts.create(cr, uid, {
'account_id': acc_templ.id,
@@ -595,17 +664,15 @@ class wizard_update_charts_accounts(orm.TransientModel):
'update_account_id': account_id,
'notes': notes,
}, context)
- return {
- 'new': new_accounts,
+ return {'new': new_accounts,
'updated': updated_accounts,
- 'mapping': acc_templ_mapping
- }
+ 'mapping': acc_templ_mapping}
def _find_fiscal_positions(self, cr, uid, wizard, chart_template_ids,
context=None):
"""
Search for, and load, fiscal position templates to create/update.
-
+
@param chart_template_ids: IDs of the chart templates to look on,
calculated once in the calling method.
"""
@@ -626,15 +693,13 @@ class wizard_update_charts_accounts(orm.TransientModel):
chart_template_ids)],
context=context)
for fp_templ in fp_templ_obj.browse(cr, uid, fp_template_ids,
- context=context):
+ context=context):
# Ensure the fiscal position template is on the map (search for the
# mapped fiscal position id).
fp_id = self._map_fp_template(cr, uid, wizard, fp_templ_mapping,
fp_templ, context=context)
if not fp_id:
- #
# New fiscal position template.
- #
new_fps += 1
wiz_fp.create(cr, uid, {
'fiscal_position_id': fp_templ.id,
@@ -651,14 +716,18 @@ class wizard_update_charts_accounts(orm.TransientModel):
if fp_templ.tax_ids and fp.tax_ids:
for fp_tax_templ in fp_templ.tax_ids:
found = False
- tax_src_id = self._map_tax_template(cr, uid, wizard,
- tax_templ_mapping,
- fp_tax_templ.tax_src_id,
- context=None)
- tax_dest_id = self._map_tax_template(cr, uid, wizard,
- tax_templ_mapping,
- fp_tax_templ.tax_dest_id,
- context=None)
+ tax_src_id = self._map_tax_template(
+ cr, uid, wizard,
+ tax_templ_mapping,
+ fp_tax_templ.tax_src_id,
+ context=None
+ )
+ tax_dest_id = self._map_tax_template(
+ cr, uid, wizard,
+ tax_templ_mapping,
+ fp_tax_templ.tax_dest_id,
+ context=None
+ )
for fp_tax in fp.tax_ids:
if fp_tax.tax_src_id.id == tax_src_id:
if not fp_tax.tax_dest_id:
@@ -670,12 +739,18 @@ class wizard_update_charts_accounts(orm.TransientModel):
found = True
break
if not found:
- notes += _("Tax mapping not found on the fiscal position instance: %s -> %s.\n") % (
- fp_tax_templ.tax_src_id.name,
- fp_tax_templ.tax_dest_id and fp_tax_templ.tax_dest_id.name or _('None'))
+ msg = (fp_tax_templ.tax_dest_id and
+ 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
+ )
modified = True
elif fp_templ.tax_ids and not fp.tax_ids:
- notes += _("The template has taxes the fiscal position instance does not.\n")
+ notes += _("The template has taxes the fiscal "
+ "position instance does not.\n")
modified = True
# Check fiscal position accounts for changes
if fp_templ.account_ids and fp.account_ids:
@@ -693,10 +768,11 @@ class wizard_update_charts_accounts(orm.TransientModel):
found = True
break
if not found:
- 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)
+ 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)
modified = True
elif fp_templ.account_ids and not fp.account_ids:
notes += _("The template has accounts the fiscal position "
@@ -712,12 +788,14 @@ class wizard_update_charts_accounts(orm.TransientModel):
'update_fiscal_position_id': fp_id,
'notes': notes,
}, context=context)
- return {'new': new_fps, 'updated': updated_fps, 'mapping': fp_templ_mapping}
+ return {'new': new_fps,
+ 'updated': updated_fps,
+ 'mapping': fp_templ_mapping}
- """
- Searchs for records to update/create and shows them
- """
def action_find_records(self, cr, uid, ids, context=None):
+ """
+ Searchs for records to update/create and shows them
+ """
if context is None:
context = {}
wizard = self.browse(cr, uid, ids[0], context=context)
@@ -750,7 +828,6 @@ class wizard_update_charts_accounts(orm.TransientModel):
chart_template_ids,
context=context)
# Write the results, and go to the next step.
- #
self.write(cr, uid, [wizard.id], {
'state': 'ready',
'new_tax_codes': tax_codes_res.get('new', 0),
@@ -764,10 +841,11 @@ class wizard_update_charts_accounts(orm.TransientModel):
}, context)
return _reopen(self, wizard.id, 'wizard.update.chart.accounts')
- """
- Search for, and load, tax code templates to create/update.
- """
+
def _update_tax_codes(self, cr, uid, wizard, log, context=None):
+ """
+ Search for, and load, tax code templates to create/update.
+ """
taxcodes = self.pool.get('account.tax.code')
root_tax_code_id = wizard.chart_template_id.tax_code_root_id.id
new_tax_codes = 0
@@ -775,62 +853,64 @@ class wizard_update_charts_accounts(orm.TransientModel):
tax_code_template_mapping = {}
for wiz_tax_code in wizard.tax_code_ids:
tax_code_template = wiz_tax_code.tax_code_id
- tax_code_name = (root_tax_code_id == tax_code_template.id) and wizard.company_id.name or tax_code_template.name
+ tax_code_name = ((root_tax_code_id == tax_code_template.id) and
+ wizard.company_id.name or tax_code_template.name)
# Ensure the parent tax code template is on the map.
self._map_tax_code_template(cr, uid, wizard,
tax_code_template_mapping,
tax_code_template.parent_id,
context=context)
# Values
- #
+ p_id = tax_code_template.parent_id.id
vals = {
'name': tax_code_name,
'code': tax_code_template.code,
'info': tax_code_template.info,
- 'parent_id': tax_code_template.parent_id and tax_code_template_mapping.get(tax_code_template.parent_id.id),
+ 'parent_id': (tax_code_template.parent_id and
+ tax_code_template_mapping.get(p_id)),
'company_id': wizard.company_id.id,
'sign': tax_code_template.sign,
}
tax_code_id = None
modified = False
if wiz_tax_code.type == 'new':
- #
# Create the tax code
- #
tax_code_id = taxcodes.create(cr, uid, vals)
log.add(_("Created tax code %s.\n") % tax_code_name)
new_tax_codes += 1
modified = True
elif wizard.update_tax_code and wiz_tax_code.update_tax_code_id:
- #
# Update the tax code
- #
tax_code_id = wiz_tax_code.update_tax_code_id.id
taxcodes.write(cr, uid, [tax_code_id], vals)
log.add(_("Updated tax code %s.\n") % tax_code_name)
updated_tax_codes += 1
modified = True
else:
- tax_code_id = wiz_tax_code.update_tax_code_id and wiz_tax_code.update_tax_code_id.id
+ tax_code_id = (wiz_tax_code.update_tax_code_id and
+ wiz_tax_code.update_tax_code_id.id)
modified = False
# Store the tax codes on the map
tax_code_template_mapping[tax_code_template.id] = tax_code_id
if modified:
- #
# Detect errors
- #
- if tax_code_template.parent_id and not tax_code_template_mapping.get(tax_code_template.parent_id.id):
- log.add(_("Tax code %s: The parent tax code %s can not be set.\n") % (tax_code_name, tax_code_template.parent_id.name), True)
+ p_id = tax_code_template.parent_id.id
+ if (tax_code_template.parent_id and
+ not tax_code_template_mapping.get(p_id)):
+ log.add(
+ _("Tax code %s: The parent tax code %s "
+ "can not be set.\n") % (
+ tax_code_name, tax_code_template.parent_id.name),
+ True
+ )
return {
'new': new_tax_codes,
'updated': updated_tax_codes,
'mapping': tax_code_template_mapping
}
- """
- Search for, and load, tax templates to create/update.
- """
- def _update_taxes(self, cr, uid, wizard, log, tax_code_template_mapping, context=None):
+ def _update_taxes(self, cr, uid, wizard, log, tax_code_template_mapping,
+ context=None):
"""
Search for, and load, tax templates to create/update.
"""
@@ -845,19 +925,18 @@ class wizard_update_charts_accounts(orm.TransientModel):
self._map_tax_template(cr, uid, wizard, tax_template_mapping,
tax_template.parent_id, context)
# Ensure the referenced tax codes are on the map.
- #
tax_code_templates_to_find = [
tax_template.base_code_id,
tax_template.tax_code_id,
tax_template.ref_base_code_id,
tax_template.ref_tax_code_id
]
- for tax_code_template in [tmpl for tmpl in tax_code_templates_to_find if tmpl]:
+ for tax_code_template in \
+ [tmpl for tmpl in tax_code_templates_to_find if tmpl]:
self._map_tax_code_template(cr, uid, wizard,
tax_code_template_mapping,
tax_code_template, context=context)
# Values
- #
vals_tax = {
'name': tax_template.name,
'sequence': tax_template.sequence,
@@ -865,18 +944,35 @@ class wizard_update_charts_accounts(orm.TransientModel):
'type': tax_template.type,
'applicable_type': tax_template.applicable_type,
'domain': tax_template.domain,
- 'parent_id': tax_template.parent_id and tax_template_mapping.get(tax_template.parent_id.id),
+ 'parent_id': (
+ tax_template.parent_id and
+ tax_template_mapping.get(tax_template.parent_id.id)
+ ),
'child_depend': tax_template.child_depend,
'python_compute': tax_template.python_compute,
'python_compute_inv': tax_template.python_compute_inv,
'python_applicable': tax_template.python_applicable,
- #'tax_group': tax_template.tax_group,
- 'base_code_id': tax_template.base_code_id and tax_code_template_mapping.get(tax_template.base_code_id.id),
- 'tax_code_id': tax_template.tax_code_id and tax_code_template_mapping.get(tax_template.tax_code_id.id),
+ 'base_code_id': (
+ tax_template.base_code_id and
+ tax_code_template_mapping.get(tax_template.base_code_id.id)
+ ),
+ 'tax_code_id': (
+ tax_template.tax_code_id and
+ tax_code_template_mapping.get(tax_template.tax_code_id.id)
+ ),
'base_sign': tax_template.base_sign,
'tax_sign': tax_template.tax_sign,
- 'ref_base_code_id': tax_template.ref_base_code_id and tax_code_template_mapping.get(tax_template.ref_base_code_id.id),
- 'ref_tax_code_id': tax_template.ref_tax_code_id and tax_code_template_mapping.get(tax_template.ref_tax_code_id.id),
+ 'ref_base_code_id': (
+ tax_template.ref_base_code_id and
+ tax_code_template_mapping.get(
+ tax_template.ref_base_code_id.id
+ )
+ ),
+ 'ref_tax_code_id': (
+ tax_template.ref_tax_code_id and
+ tax_code_template_mapping.get(
+ tax_template.ref_tax_code_id.id)
+ ),
'ref_base_sign': tax_template.ref_base_sign,
'ref_tax_sign': tax_template.ref_tax_sign,
'include_base_amount': tax_template.include_base_amount,
@@ -887,17 +983,13 @@ class wizard_update_charts_accounts(orm.TransientModel):
tax_id = None
modified = False
if wiz_tax.type == 'new':
- #
# Create a new tax.
- #
tax_id = taxes.create(cr, uid, vals_tax)
log.add(_("Created tax %s.\n") % tax_template.name)
new_taxes += 1
modified = True
elif wizard.update_tax and wiz_tax.update_tax_id:
- #
# Update a tax.
- #
tax_id = wiz_tax.update_tax_id.id
taxes.write(cr, uid, [tax_id], vals_tax)
log.add(_("Updated tax %s.\n") % tax_template.name)
@@ -908,25 +1000,67 @@ class wizard_update_charts_accounts(orm.TransientModel):
# Update the tax template map
tax_template_mapping[tax_template.id] = tax_id
if modified:
- #
# Add to the dict of taxes waiting for accounts.
- #
taxes_pending_for_accounts[tax_id] = {
- 'account_collected_id': tax_template.account_collected_id and tax_template.account_collected_id.id or False,
- 'account_paid_id': tax_template.account_paid_id and tax_template.account_paid_id.id or False,
+ 'account_collected_id': (
+ tax_template.account_collected_id and
+ tax_template.account_collected_id.id or False
+ ),
+ 'account_paid_id': (
+ tax_template.account_paid_id and
+ tax_template.account_paid_id.id or False
+ ),
}
# Detect errors
- #
- if tax_template.parent_id and not tax_template_mapping.get(tax_template.parent_id.id):
- log.add(_("Tax %s: The parent tax %s can not be set.\n") % (tax_template.name, tax_template.parent_id.name), True)
- if tax_template.base_code_id and not tax_code_template_mapping.get(tax_template.base_code_id.id):
- log.add(_("Tax %s: The tax code for the base %s can not be set.\n") % (tax_template.name, tax_template.base_code_id.name), True)
- if tax_template.tax_code_id and not tax_code_template_mapping.get(tax_template.tax_code_id.id):
- log.add(_("Tax %s: The tax code for the tax %s can not be set.\n") % (tax_template.name, tax_template.tax_code_id.name), True)
- if tax_template.ref_base_code_id and not tax_code_template_mapping.get(tax_template.ref_base_code_id.id):
- log.add(_("Tax %s: The tax code for the base refund %s can not be set.\n") % (tax_template.name, tax_template.ref_base_code_id.name), True)
- if tax_template.ref_tax_code_id and not tax_code_template_mapping.get(tax_template.ref_tax_code_id.id):
- log.add(_("Tax %s: The tax code for the tax refund %s can not be set.\n") % (tax_template.name, tax_template.ref_tax_code_id.name), True)
+ if (tax_template.parent_id and not
+ tax_template_mapping.get(tax_template.parent_id.id)):
+ log.add(
+ _("Tax %s: The parent tax %s can not be set.\n") % (
+ tax_template.name, tax_template.parent_id.name),
+ True
+ )
+ if (tax_template.base_code_id and not
+ tax_code_template_mapping.get(
+ tax_template.base_code_id.id
+ )):
+ log.add(
+ _("Tax %s: The tax code for the base %s "
+ "can not be set.\n") % (
+ tax_template.name, tax_template.base_code_id.name),
+ True
+ )
+ if (tax_template.tax_code_id and not
+ tax_code_template_mapping.get(
+ tax_template.tax_code_id.id)):
+ log.add(
+ _("Tax %s: The tax code for the tax %s "
+ "can not be set.\n") % (
+ tax_template.name, tax_template.tax_code_id.name
+ ),
+ True
+ )
+ if (tax_template.ref_base_code_id and
+ not tax_code_template_mapping.get(
+ tax_template.ref_base_code_id.id)):
+ log.add(
+ _("Tax %s: The tax code for the base refund %s "
+ "can not be set.\n") % (
+ tax_template.name,
+ tax_template.ref_base_code_id.name
+ ),
+ True
+ )
+ if (tax_template.ref_tax_code_id and not
+ tax_code_template_mapping.get(
+ tax_template.ref_tax_code_id.id)):
+ log.add(
+ _("Tax %s: The tax code for the tax refund %s"
+ " can not be set.\n") % (
+ tax_template.name,
+ tax_template.ref_tax_code_id.name
+ ),
+ True
+ )
return {
'new': new_taxes,
'updated': updated_taxes,
@@ -934,12 +1068,13 @@ class wizard_update_charts_accounts(orm.TransientModel):
'pending': taxes_pending_for_accounts
}
- """
- Updates the parent_id of accounts that seem to be children of the
- given account (accounts that start with the same code and are brothers
- of the first account).
- """
- def _update_children_accounts_parent(self, cr, uid, wizard, log, parent_account_id, context=None):
+ def _update_children_accounts_parent(self, cr, uid, wizard,
+ log, parent_account_id, context=None):
+ """
+ Updates the parent_id of accounts that seem to be children of the
+ given account (accounts that start with the same code and are brothers
+ of the first account).
+ """
account_account = self.pool.get('account.account')
parent_account = account_account.browse(
cr, uid, parent_account_id, context=context)
@@ -957,20 +1092,30 @@ class wizard_update_charts_accounts(orm.TransientModel):
if children_ids:
try:
- account_account.write(cr, uid, children_ids, {'parent_id': parent_account.id}, context=context)
+ account_account.write(cr, uid, children_ids,
+ {'parent_id': parent_account.id},
+ context=context)
except orm.except_orm, ex:
- log.add(_("Exception setting the parent of account %s children: %s - %s.\n") % (parent_account.code, ex.name, ex.value), True)
+ log.add(
+ _("Exception setting the parent of "
+ "account %s children: %s - %s.\n") % (
+ parent_account.code, ex.name, ex.value
+ ),
+ True
+ )
return True
- """
- Search for, and load, account templates to create/update.
- """
- def _update_accounts(self, cr, uid, wizard, log, tax_template_mapping, context=None):
+ def _update_accounts(self, cr, uid, wizard, log, tax_template_mapping,
+ context=None):
+ """
+ Search for, and load, account templates to create/update.
+ """
accounts = self.pool.get('account.account')
root_account_id = wizard.chart_template_id.account_root_id.id
- # Disable the parent_store computing on account_account during the batch
- # processing, we will force _parent_store_compute afterwards.
+ # Disable the parent_store computing on account_account
+ # during the batch processing,
+ # we will force _parent_store_compute afterwards.
self.pool._init = True
new_accounts = 0
updated_accounts = 0
@@ -978,44 +1123,54 @@ class wizard_update_charts_accounts(orm.TransientModel):
for wiz_account in wizard.account_ids:
account_template = wiz_account.account_id
# Ensure the parent account template is on the map.
- self._map_account_template(cr, uid, wizard, account_template_mapping, account_template.parent_id, context)
+ self._map_account_template(cr, uid, wizard,
+ account_template_mapping,
+ account_template.parent_id,
+ context)
# Ensure the related tax templates are on the map.
- #
for tax_template in account_template.tax_ids:
self._map_tax_template(cr, uid, wizard, tax_template_mapping,
tax_template, context)
# Get the tax ids
- tax_ids = [tax_template_mapping[tax_template.id] for tax_template in account_template.tax_ids if tax_template_mapping[tax_template.id]]
+ tax_ids = [tax_template_mapping[tax_template.id]
+ for tax_template in account_template.tax_ids
+ if tax_template_mapping[tax_template.id]]
# Calculate the account code (we need to add zeros to non-view
# account codes)
- #
code = account_template.code or ''
if account_template.type != 'view':
if len(code) > 0 and len(code) <= wizard.code_digits:
code = '%s%s' % (
code, '0' * (wizard.code_digits - len(code)))
# Values
- #
+ p_id = account_template.parent_id.id
vals = {
- 'name': (root_account_id == account_template.id) and wizard.company_id.name or account_template.name,
- #'sign': account_template.sign,
- 'currency_id': account_template.currency_id and account_template.currency_id.id or False,
+ 'name': ((root_account_id == account_template.id) and
+ wizard.company_id.name or
+ account_template.name),
+ 'currency_id': (account_template.currency_id and
+ account_template.currency_id.id or
+ False),
'code': code,
'type': account_template.type,
- 'user_type': account_template.user_type and account_template.user_type.id or False,
+ 'user_type': (account_template.user_type and
+ account_template.user_type.id or
+ False),
'reconcile': account_template.reconcile,
'shortcut': account_template.shortcut,
'note': account_template.note,
- 'parent_id': account_template.parent_id and account_template_mapping.get(account_template.parent_id.id) or False,
+ 'parent_id': (
+ account_template.parent_id
+ and account_template_mapping.get(p_id) or
+ False
+ ),
'tax_ids': [(6, 0, tax_ids)],
'company_id': wizard.company_id.id,
}
account_id = None
modified = False
if wiz_account.type == 'new':
- #
# Create the account
- #
try:
account_id = accounts.create(cr, uid, vals)
log.add(_("Created account %s.\n") % code)
@@ -1025,9 +1180,7 @@ class wizard_update_charts_accounts(orm.TransientModel):
log.add(_("Exception creating account %s: %s - %s.\n")
% (code, ex.name, ex.value), True)
elif wizard.update_account and wiz_account.update_account_id:
- #
# Update the account
- #
account_id = wiz_account.update_account_id.id
try:
accounts.write(cr, uid, [account_id], vals)
@@ -1038,24 +1191,29 @@ class wizard_update_charts_accounts(orm.TransientModel):
log.add(_("Exception writing account %s: %s - %s.\n")
% (code, ex.name, ex.value), True)
else:
- account_id = wiz_account.update_account_id and wiz_account.update_account_id.id
+ account_id = (wiz_account.update_account_id and
+ wiz_account.update_account_id.id)
# Store the account on the map
account_template_mapping[account_template.id] = account_id
if modified:
- #
# Detect errors
- #
- if account_template.parent_id and not account_template_mapping.get(account_template.parent_id.id):
- log.add(_("Account %s: The parent account %s can not be set.\n") % (code, account_template.parent_id.code), True)
+ if (account_template.parent_id and not
+ account_template_mapping.get(
+ account_template.parent_id.id)):
+ log.add(
+ _("Account %s: The parent account %s "
+ "can not be set.\n") % (
+ code, account_template.parent_id.code
+ ),
+ True
+ )
# Set this account as the parent of the accounts that seem to
# be its children (brothers starting with the same code).
- #
if wizard.update_children_accounts_parent:
self._update_children_accounts_parent(
cr, uid, wizard, log, account_id, context=context)
# Reenable the parent_store computing on account_account
# and force the recomputation.
- #
self.pool._init = False
self.pool.get('account.account')._parent_store_compute(cr)
return {
@@ -1075,9 +1233,7 @@ class wizard_update_charts_accounts(orm.TransientModel):
taxes = self.pool['account.tax']
accounts_template = self.pool['account.account.template']
for key, value in taxes_pending_for_accounts.items():
- #
# Ensure the related account templates are on the map.
- #
if value['account_collected_id']:
acc_templ = accounts_template.browse(
cr, uid, value['account_collected_id'], context=context)
@@ -1089,27 +1245,43 @@ class wizard_update_charts_accounts(orm.TransientModel):
self._map_account_template(cr, uid, wizard, acc_templ_mapping,
acc_templ, context=context)
if value['account_collected_id'] or value['account_paid_id']:
- if acc_templ_mapping.get(value['account_collected_id']) and acc_templ_mapping.get(value['account_paid_id']):
+ if (acc_templ_mapping.get(value['account_collected_id']) and
+ acc_templ_mapping.get(value['account_paid_id'])):
vals = {
- 'account_collected_id': acc_templ_mapping[value['account_collected_id']],
- 'account_paid_id': acc_templ_mapping[value['account_paid_id']],
+ 'account_collected_id': acc_templ_mapping[
+ value['account_collected_id']
+ ],
+ 'account_paid_id': acc_templ_mapping[
+ value['account_paid_id']
+ ],
}
taxes.write(cr, uid, [key], vals)
else:
tax = taxes.browse(cr, uid, key)
- if not acc_templ_mapping.get(value['account_collected_id']):
- log.add(_("Tax %s: The collected account can not be set.\n") % (tax.name), True)
+ val = value['account_collected_id']
+ if not acc_templ_mapping.get(val):
+ log.add(
+ _("Tax %s: The collected account "
+ "can not be set.\n") % (
+ tax.name
+ ),
+ True
+ )
if not acc_templ_mapping.get(value['account_paid_id']):
log.add(_("Tax %s: The paid account can not be set.\n")
% (tax.name), True)
- def _update_fiscal_positions(self, cr, uid, wizard, log, tax_template_mapping, acc_templ_mapping, context=None):
+ def _update_fiscal_positions(self, cr, uid, wizard, log,
+ tax_template_mapping,
+ acc_templ_mapping, context=None):
"""
Search for, and load, fiscal position templates to create/update.
"""
fiscalpositions = self.pool.get('account.fiscal.position')
fiscalpositions_taxes = self.pool.get('account.fiscal.position.tax')
- fiscalpositions_account = self.pool.get('account.fiscal.position.account')
+ fiscalpositions_account = self.pool.get(
+ 'account.fiscal.position.account'
+ )
new_fps = 0
updated_fps = 0
@@ -1119,9 +1291,7 @@ class wizard_update_charts_accounts(orm.TransientModel):
fp_id = None
modified = False
if wiz_fp.type == 'new':
- #
# Create a new fiscal position
- #
vals_fp = {
'company_id': wizard.company_id.id,
'name': fp_template.name,
@@ -1129,11 +1299,10 @@ class wizard_update_charts_accounts(orm.TransientModel):
fp_id = fiscalpositions.create(cr, uid, vals_fp)
new_fps += 1
modified = True
- elif wizard.update_fiscal_position and wiz_fp.update_fiscal_position_id:
- #
+ elif (wizard.update_fiscal_position and
+ wiz_fp.update_fiscal_position_id):
# Update the given fiscal position (remove the tax and account
# mappings, that will be regenerated later)
- #
fp_id = wiz_fp.update_fiscal_position_id.id
updated_fps += 1
modified = True
@@ -1146,42 +1315,51 @@ class wizard_update_charts_accounts(orm.TransientModel):
cr, uid, [('position_id', '=', fp_id)])
fiscalpositions_account.unlink(cr, uid, fp_account_ids)
else:
- fp_id = wiz_fp.update_fiscal_position_id and wiz_fp.update_fiscal_position_id.id
+ fp_id = (wiz_fp.update_fiscal_position_id and
+ wiz_fp.update_fiscal_position_id.id)
if modified:
- #
# (Re)create the tax mappings
- #
for fp_tax in fp_template.tax_ids:
- #
# Ensure the related tax templates are on the map.
- #
- self._map_tax_template(cr, uid, wizard, tax_template_mapping, fp_tax.tax_src_id, context)
+ self._map_tax_template(cr, uid, wizard,
+ tax_template_mapping,
+ fp_tax.tax_src_id, context)
if fp_tax.tax_dest_id:
- self._map_tax_template(cr, uid, wizard, tax_template_mapping, fp_tax.tax_dest_id, context)
-
- #
+ self._map_tax_template(cr, uid, wizard,
+ tax_template_mapping,
+ fp_tax.tax_dest_id, context)
# Create the fp tax mapping
- #
vals_tax = {
- 'tax_src_id': tax_template_mapping.get(fp_tax.tax_src_id.id),
- 'tax_dest_id': fp_tax.tax_dest_id and tax_template_mapping.get(fp_tax.tax_dest_id.id),
+ 'tax_src_id': tax_template_mapping.get(
+ fp_tax.tax_src_id.id
+ ),
+ 'tax_dest_id': (fp_tax.tax_dest_id and
+ tax_template_mapping.get(
+ fp_tax.tax_dest_id.id)),
'position_id': fp_id,
}
fiscalpositions_taxes.create(cr, uid, vals_tax)
-
- #
# Check for errors
- #
if not tax_template_mapping.get(fp_tax.tax_src_id.id):
- log.add(_("Fiscal position %s: The source tax %s can not be set.\n") % (fp_template.name, fp_tax.tax_src_id.code), True)
- if fp_tax.tax_dest_id and not tax_template_mapping.get(fp_tax.tax_dest_id.id):
- log.add(_("Fiscal position %s: The destination tax %s can not be set.\n") % (fp_template.name, fp_tax.tax_dest_id.name), True)
- #
+ log.add(
+ _("Fiscal position %s: The source tax %s "
+ "can not be set.\n") % (
+ fp_template.name, fp_tax.tax_src_id.code
+ ),
+ True
+ )
+ if fp_tax.tax_dest_id and not tax_template_mapping.get(
+ fp_tax.tax_dest_id.id):
+ log.add(
+ _("Fiscal position %s: The destination"
+ "tax %s can not be set.\n") % (
+ fp_template.name, fp_tax.tax_dest_id.name
+ ),
+ True
+ )
# (Re)create the account mappings
- #
for fp_account in fp_template.account_ids:
- #
# Ensure the related account templates are on the map.
self._map_account_template(cr, uid, wizard,
acc_templ_mapping,
@@ -1193,29 +1371,49 @@ class wizard_update_charts_accounts(orm.TransientModel):
fp_account.account_dest_id,
context=context)
# Create the fp account mapping
- #
vals_account = {
- 'account_src_id': acc_templ_mapping.get(fp_account.account_src_id.id),
- 'account_dest_id': fp_account.account_dest_id and acc_templ_mapping.get(fp_account.account_dest_id.id),
+ 'account_src_id': acc_templ_mapping.get(
+ fp_account.account_src_id.id
+ ),
+ 'account_dest_id': (
+ fp_account.account_dest_id and
+ acc_templ_mapping.get(
+ fp_account.account_dest_id.id
+ )
+ ),
'position_id': fp_id,
}
fiscalpositions_account.create(cr, uid, vals_account)
-
- #
# Check for errors
if not acc_templ_mapping.get(fp_account.account_src_id.id):
- log.add(_("Fiscal position %s: The source account %s can not be set.\n") % (fp_template.name, fp_account.account_src_id.code), True)
- if fp_account.account_dest_id and not acc_templ_mapping.get(fp_account.account_dest_id.id):
- log.add(_("Fiscal position %s: The destination account %s can not be set.\n") % (fp_template.name, fp_account.account_dest_id.code), True)
+ log.add(
+ _("Fiscal position %s: The source account %s "
+ "can not be set.\n") % (
+ fp_template.name,
+ fp_account.account_src_id.code
+ ),
+ True
+ )
+ if (fp_account.account_dest_id and not
+ acc_templ_mapping.get(
+ fp_account.account_dest_id.id)):
+ log.add(
+ _("Fiscal position %s: The destination account %s "
+ "can not be set.\n") % (
+ fp_template.name,
+ fp_account.account_dest_id.code
+ ),
+ True
+ )
log.add(_("Created or updated fiscal position %s.\n")
% fp_template.name)
return {'new': new_fps, 'updated': updated_fps}
- """
- Action that creates/updates the selected elements.
- """
def action_update_records(self, cr, uid, ids, context=None):
+ """
+ Action that creates/updates the selected elements.
+ """
if context is None:
context = {}
wizard = self.browse(cr, uid, ids[0], context=context)
@@ -1252,12 +1450,10 @@ class wizard_update_charts_accounts(orm.TransientModel):
accounts_res['mapping'],
context=context)
# Check if errors where detected and wether we should stop.
- #
if log.has_errors() and not wizard.continue_on_errors:
raise orm.except_orm(_('Error'), _(
"One or more errors detected!\n\n%s") % log.get_errors_str())
# Store the data and go to the next step.
- #
self.write(cr, uid, [wizard.id], {
'state': 'done',
'new_tax_codes': tax_codes_res.get('new', 0),
@@ -1272,8 +1468,6 @@ class wizard_update_charts_accounts(orm.TransientModel):
}, context=context)
return _reopen(self, wizard.id, 'wizard.update.chart.accounts')
-wizard_update_charts_accounts()
-
class wizard_update_charts_accounts_tax_code(orm.TransientModel):
"""
@@ -1283,19 +1477,32 @@ class wizard_update_charts_accounts_tax_code(orm.TransientModel):
"""
_name = 'wizard.update.charts.accounts.tax.code'
_columns = {
- 'tax_code_id': fields.many2one('account.tax.code.template', 'Tax code template', required=True, ondelete='set null'),
- 'update_chart_wizard_id': fields.many2one('wizard.update.charts.accounts', 'Update chart wizard', required=True, ondelete='cascade'),
+ 'tax_code_id': fields.many2one(
+ 'account.tax.code.template',
+ 'Tax code template',
+ required=True,
+ ondelete='set null'
+ ),
+ 'update_chart_wizard_id': fields.many2one(
+ 'wizard.update.charts.accounts',
+ 'Update chart wizard',
+ required=True,
+ ondelete='cascade'
+ ),
'type': fields.selection([
('new', 'New template'),
('updated', 'Updated template'),
], 'Type'),
- 'update_tax_code_id': fields.many2one('account.tax.code', 'Tax code to update', required=False, ondelete='set null'),
+ 'update_tax_code_id': fields.many2one(
+ 'account.tax.code',
+ 'Tax code to update',
+ required=False,
+ ondelete='set null'
+ ),
'notes': fields.text('Notes'),
}
_defaults = {
- }
-
-wizard_update_charts_accounts_tax_code()
+ }
class wizard_update_charts_accounts_tax(orm.TransientModel):
@@ -1306,20 +1513,33 @@ class wizard_update_charts_accounts_tax(orm.TransientModel):
"""
_name = 'wizard.update.charts.accounts.tax'
_columns = {
- 'tax_id': fields.many2one('account.tax.template', 'Tax template', required=True, ondelete='set null'),
- 'update_chart_wizard_id': fields.many2one('wizard.update.charts.accounts', 'Update chart wizard', required=True, ondelete='cascade'),
+ 'tax_id': fields.many2one(
+ 'account.tax.template',
+ 'Tax template',
+ required=True,
+ ondelete='set null'
+ ),
+ 'update_chart_wizard_id': fields.many2one(
+ 'wizard.update.charts.accounts',
+ 'Update chart wizard',
+ required=True,
+ ondelete='cascade'
+ ),
'type': fields.selection([
('new', 'New template'),
('updated', 'Updated template'),
], 'Type'),
- 'update_tax_id': fields.many2one('account.tax', 'Tax to update', required=False, ondelete='set null'),
+ 'update_tax_id': fields.many2one(
+ 'account.tax',
+ 'Tax to update',
+ required=False,
+ ondelete='set null'
+ ),
'notes': fields.text('Notes'),
}
_defaults = {
- }
-
-wizard_update_charts_accounts_tax()
+ }
class wizard_update_charts_accounts_account(orm.TransientModel):
@@ -1332,22 +1552,34 @@ class wizard_update_charts_accounts_account(orm.TransientModel):
# The chart of accounts can have a lot of accounts, so we need an higher
# limit for the objects in memory to let the wizard create all the items
# at once.
- _max_count = 4096
_columns = {
- 'account_id': fields.many2one('account.account.template', 'Account template', required=True, ondelete='set null'),
- 'update_chart_wizard_id': fields.many2one('wizard.update.charts.accounts', 'Update chart wizard', required=True, ondelete='cascade'),
+ 'account_id': fields.many2one(
+ 'account.account.template',
+ 'Account template',
+ required=True,
+ ondelete='set null'
+ ),
+ 'update_chart_wizard_id': fields.many2one(
+ 'wizard.update.charts.accounts',
+ 'Update chart wizard',
+ required=True,
+ ondelete='cascade'
+ ),
'type': fields.selection([
('new', 'New template'),
('updated', 'Updated template'),
], 'Type'),
- 'update_account_id': fields.many2one('account.account', 'Account to update', required=False, ondelete='set null'),
+ 'update_account_id': fields.many2one(
+ 'account.account',
+ 'Account to update',
+ required=False,
+ ondelete='set null'
+ ),
'notes': fields.text('Notes'),
}
_defaults = {
- }
-
-wizard_update_charts_accounts_account()
+ }
class wizard_update_charts_accounts_fiscal_position(orm.TransientModel):
@@ -1358,19 +1590,31 @@ class wizard_update_charts_accounts_fiscal_position(orm.TransientModel):
"""
_name = 'wizard.update.charts.accounts.fiscal.position'
_columns = {
- 'fiscal_position_id': fields.many2one('account.fiscal.position.template', 'Fiscal position template', required=True, ondelete='set null'),
- 'update_chart_wizard_id': fields.many2one('wizard.update.charts.accounts', 'Update chart wizard', required=True, ondelete='cascade'),
+ 'fiscal_position_id': fields.many2one(
+ 'account.fiscal.position.template',
+ 'Fiscal position template',
+ required=True,
+ ondelete='set null'
+ ),
+ 'update_chart_wizard_id': fields.many2one(
+ 'wizard.update.charts.accounts',
+ 'Update chart wizard',
+ required=True,
+ ondelete='cascade'
+ ),
'type': fields.selection([
('new', 'New template'),
('updated', 'Updated template'),
], 'Type'),
- 'update_fiscal_position_id': fields.many2one('account.fiscal.position', 'Fiscal position to update', required=False, ondelete='set null'),
+ 'update_fiscal_position_id': fields.many2one(
+ 'account.fiscal.position',
+ 'Fiscal position to update',
+ required=False,
+ ondelete='set null'
+ ),
'notes': fields.text('Notes'),
}
_defaults = {
- }
-
-
-wizard_update_charts_accounts_fiscal_position()
+ }
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/account_chart_update/wizard/wizard_chart_update_view.xml b/account_chart_update/wizard/wizard_chart_update_view.xml
deleted file mode 100644
index b0b93d39..00000000
--- a/account_chart_update/wizard/wizard_chart_update_view.xml
+++ /dev/null
@@ -1,151 +0,0 @@
-
-
-
-
-
-
-
- Update Chart of Accounts from a Chart Template
-
- wizard.update.charts.accounts
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
If you leave these options set, the wizard will not just create new records, but also update records with changes (i.e. different tax amount)
- Note: Not all the fields are tested for changes, just the main ones
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Update Chart of Accounts from a Chart Template
-
- ir.actions.act_window
- wizard.update.charts.accounts
- form
- form
- new
-
-
-
-
-
-