2
0

[MIG][9.0][account_chart_update] Migrate.

- New-style license headers.
- Remove .pot file.
- Remove tax codes stuff, now removed from v9.
- Refactor methods for search, create, update, delete. Now they are smaller, fitter, happier, more productive.
- Only update fields that have any kind of change on any updated record.
- Place the wizard in the configuration page, instead of its own menu item.
- Display amount of disabled taxes at ending page.
This commit is contained in:
Jairo Llopis 2016-05-25 14:05:38 +02:00 committed by Luis J. Salvatierra
parent 4c5b816db3
commit 88488fd5f1
10 changed files with 718 additions and 1213 deletions

View File

@ -1,5 +1,10 @@
Adds a wizard to update a company account chart from a chart template.
======================================================================
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
===========================================================
Detect changes and update the Account Chart from a template
===========================================================
This is a pretty useful tool to update Odoo installations after tax reforms
on the official charts of accounts, or to apply fixes performed on the chart
@ -17,15 +22,32 @@ The wizard:
Usage
=====
The wizard, accesible from *Accounting > Configuration > Accounts > Update
chart of accounts*, lets the user select what kind of objects must
be checked/updated, and whether old records must be checked for changes and
updates.
The wizard, accesible from *Accounting > Configuration > Settings > Chart of
Accounts > Update chart of accounts*, lets the user select what kind of objects
must be checked/updated, and whether old records must be checked for changes
and updates.
It will display all the objects to be created / updated with some information
about the detected differences, and allow the user to exclude records
individually.
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/92/9.0
Known issues / Roadmap
======================
* Add tests.
Bug Tracker
===========
Bugs are tracked on `GitHub Issues
<https://github.com/OCA/account-financial-tools/issues>`_. In case of trouble,
please check there if your issue has already been reported. If you spotted it
first, help us smashing it by providing a detailed and welcomed feedback.
Credits
=======
@ -39,6 +61,8 @@ Contributors
* invitu
* Stéphane Bidoul <stephane.bidoul@acsone.eu>
* Antonio Espinosa <antonioea@antiun.com>
* Jairo Llopis <jairo.llopis@tecnativa.com>
* Jacques-Etienne Baudoux <je@bcim.be>
Maintainer
----------
@ -53,4 +77,4 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.
To contribute to this module, please visit http://odoo-community.org.
To contribute to this module, please visit https://odoo-community.org.

View File

@ -1,28 +1,7 @@
# -*- coding: utf-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)
#
# 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
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
"""
Account Chart Update Wizard
"""
# © 2010 Zikzakmedia S.L. (http://www.zikzakmedia.com)
# © 2010 Pexego Sistemas Informáticos S.L.(http://www.pexego.es)
# © 2016 Jairo Llopis <jairo.llopis@tecnativa.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import model
from . import wizard

View File

@ -1,51 +1,38 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# 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) 2013 Joaquin Gutierrez (http://www.gutierrezweb.es)
# Pedro Manuel Baeza <pedro.baeza@serviciosbaeza.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
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# 2013/09/08 - Joaquín Gutierrez: Adaptación a la versión
#
##############################################################################
# © 2010 Zikzakmedia S.L. (http://www.zikzakmedia.com)
# © 2010 Pexego Sistemas Informáticos S.L.(http://www.pexego.es)
# © 2013 Joaquin Gutierrez (http://www.gutierrezweb.es)
# © 2015 Pedro Manuel Baeza <pedro.baeza@serviciosbaeza.com>
# © 2016 Jairo Llopis <jairo.llopis@tecnativa.com>
# © 2016 Jacques-Etienne Baudoux <je@bcim.be>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
'name': "Detect changes and update the Account Chart from a template",
'version': "8.0.1.2.0",
"summary": "Wizard to update a company's account chart from a template",
'version': "9.0.1.0.0",
'author': "Zikzakmedia SL, "
"Pexego, "
"Serv. Tecnol. Avanzados - Pedro M. Baeza, "
"ACSONE A/V, "
"Tecnativa, "
"BCIM,"
"Odoo Community Association (OCA)",
'website': "http://odoo-community.org",
'depends': ["account"],
'category': "Generic Modules/Accounting",
'category': "Accounting & Finance",
'contributors': [
'Joaquín Gutierrez',
'Pedro M. Baeza',
'invitu',
'Stéphane Bidoul',
'Jairo Llopis',
'Jacques-Etienne Baudoux',
],
'license': "AGPL-3",
"demo": [],
"data": [
'wizard/wizard_chart_update_view.xml',
'views/account_tax_code_view.xml',
'views/account_config_settings_view.xml',
],
"active": False,
'installable': True
'installable': True,
}

View File

@ -1 +0,0 @@
from . import account_tax_code

View File

@ -1,37 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (c) 2014 ACSONE SA/NV (http://acsone.eu)
# 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
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp import models, fields
class AccountTaxCode(models.Model):
_inherit = 'account.tax.code'
active = fields.Boolean('Active', default=True)
def _sum(self, cr, uid, ids, name, args, context, where='',
where_params=()):
try:
return super(AccountTaxCode, self)._sum(
cr, uid, ids, name, args, context, where=where,
where_params=where_params)
except:
cr.rollback()
return dict.fromkeys(ids, 0.0)

View File

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- © 2016 Jairo Llopis <jairo.llopis@tecnativa.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<odoo>
<record id="view_account_config_settings" model="ir.ui.view">
<field name="name">Open Account Chart Update Wizard</field>
<field name="model">account.config.settings</field>
<field name="inherit_id" ref="account.view_account_config_settings"/>
<field name="arch" type="xml">
<xpath expr="//button[@name='%(account.open_account_charts_modules)d']
/.."
position="after">
<div>
<button string="Update current chart template"
name="%(action_wizard_update_chart)d"
type="action"
class="oe_link"/>
</div>
</xpath>
</field>
</record>
</odoo>

View File

@ -1,17 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_tax_code_form_active" model="ir.ui.view">
<field name="name">account.tax.code.form.active</field>
<field name="model">account.tax.code</field>
<field name="inherit_id" ref="account.view_tax_code_form"/>
<field name="arch" type="xml">
<field name="company_id" position="after">
<field name="active"/>
</field>
</field>
</record>
</data>
</openerp>

View File

@ -1,26 +1,6 @@
# -*- coding: utf-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)
#
# 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
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
"""
Account Chart Update Wizard
"""
# © 2010 Zikzakmedia S.L. (http://www.zikzakmedia.com)
# © 2010 Pexego Sistemas Informáticos S.L.(http://www.pexego.es)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import wizard_chart_update

File diff suppressed because it is too large Load Diff

View File

@ -1,156 +1,133 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<!-- © 2016 Jairo Llopis <jairo.llopis@tecnativa.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<odoo>
<!-- Wizard for Multi Charts of Accounts -->
<record id="view_update_multi_chart" model="ir.ui.view">
<field name="name">Update Chart of Accounts from a Chart Template</field>
<field name="model">wizard.update.charts.accounts</field>
<field name="arch" type="xml">
<form>
<header>
<field
name="state"
select="2"
widget="statusbar"
statusbar_visible="init,ready,done"
statusbar_colors='{"ready":"blue","done":"blue"}' />
</header>
<group attrs="{'invisible':[('state','!=','init')]}">
<h3>
<p><center>This wizard will update your accounts, taxes and fiscal positions according to the selected chart template</center></p>
</h3>
</group>
<group string="Chart of Accounts" attrs="{'invisible':[('state','!=','init')]}">
<field name="company_id"
attrs="{'invisible':[('state','!=','init')]}"
/>
<field name="code_digits" attrs="{'invisible':[('state','!=','init')]}" />
<field name="chart_template_id"
domain="[('visible', '=', True)]"
attrs="{'invisible': [('state','!=','init')], 'required': True}"
/>
<field name="lang" attrs="{'invisible':[('state','!=','init')]}" />
</group>
<group attrs="{'invisible':[('state','!=','init')]}">
<group string="Update records?">
<field name="update_tax" />
<field name="update_account" />
<field name="update_fiscal_position" />
</group>
<group string="Other options" attrs="{'invisible':[('state','!=','init')]}">
<field name="continue_on_errors" />
</group>
</group>
<record id="view_update_multi_chart" model="ir.ui.view">
<field name="name">Update Chart of Accounts from a Chart Template
</field>
<field name="model">wizard.update.charts.accounts</field>
<field name="arch" type="xml">
<form string="Update chart of accounts from a template" version="7.0">
<header>
<field name="state" select="2" widget="statusbar"
statusbar_visible="init,ready,done" statusbar_colors='{"ready":"blue","done":"blue"}' />
</header>
<group attrs="{'invisible':[('state','!=','init')]}">
<h3>
<p><center>This wizard will update your accounts, taxes and fiscal positions according to the selected chart template</center></p>
</h3>
</group>
<group string="Chart of Accounts" attrs="{'invisible':[('state','!=','init')]}">
<field name="company_id"
attrs="{'invisible':[('state','!=','init')]}"
/>
<field name="code_digits" attrs="{'invisible':[('state','!=','init')]}" />
<field name="chart_template_id"
domain="[('visible', '=', True)]"
attrs="{'invisible': [('state','!=','init')], 'required': True}"
/>
<field name="lang" attrs="{'invisible':[('state','!=','init')]}" />
</group>
<group attrs="{'invisible':[('state','!=','init')]}">
<group string="Update records?">
<field name="update_tax_code" />
<field name="update_tax" />
<field name="update_account" />
<field name="update_fiscal_position" />
</group>
<group string="Other options" attrs="{'invisible':[('state','!=','init')]}">
<field name="update_children_accounts_parent" />
<field name="continue_on_errors" />
</group>
</group>
<group attrs="{'invisible':[('state','!=','init')]}">
<h5>
<p>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)</p>
<p>Note: Only the changed fields are updated.</p>
</h5>
</group>
<group attrs="{'invisible':[('state','!=','ready'),]}"
string="Records to create/update">
<notebook colspan="4">
<page string="Taxes" attrs="{'invisible': [('update_tax', '=', False)]}">
<field name="tax_ids" nolabel="1">
<tree string="Taxes" colors="red:type=='updated'">
<field name="tax_id" />
<field name="update_tax_id" />
<field name="type_tax_use"/>
<field name="notes"/>
<field name="type"/>
</tree>
</field>
</page>
<page string="Accounts" attrs="{'invisible': [('update_account', '=', False)]}">
<field name="account_ids" nolabel="1">
<tree string="Accounts" colors="red:type=='updated'">
<field name="account_id" />
<field name="update_account_id" />
<field name="notes"/>
<field name="type"/>
</tree>
</field>
</page>
<page string="Fiscal positions" attrs="{'invisible': [('update_fiscal_position', '=', False)]}">
<field name="fiscal_position_ids" nolabel="1">
<tree string="Fiscal positions" colors="red:type=='updated'">
<field name="fiscal_position_id" />
<field name="update_fiscal_position_id" />
<field name="notes"/>
<field name="type"/>
</tree>
</field>
</page>
<group attrs="{'invisible':[('state','!=','init')]}">
<h5>
<p>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)</p>
<p>Note: Not all the fields are tested for changes, just the main ones</p>
</h5>
</group>
<group attrs="{'invisible':[('state','!=','ready'),]}"
string="Records to create/update">
<notebook colspan="4">
<page string="Tax codes" attrs="{'invisible': [('update_tax_code', '=', False)]}">
<field name="tax_code_ids">
<tree string="Tax codes" colors="red:type=='updated'">
<field name="tax_code_id" />
<field name="update_tax_code_id" />
<field name="notes" readonly="1" />
<field name="type" invisible="1" />
</tree>
</field>
</page>
</notebook>
</group>
<page string="Taxes" attrs="{'invisible': [('update_tax', '=', False)]}">
<field name="tax_ids" nolabel="1">
<tree string="Taxes" colors="red:type=='updated'">
<field name="tax_id" />
<field name="update_tax_id" />
<field name="notes" readonly="1"/>
<field name="type" invisible="1" />
</tree>
</field>
</page>
<page string="Accounts" attrs="{'invisible': [('update_account', '=', False)]}">
<field name="account_ids" nolabel="1">
<tree string="Accounts" colors="red:type=='updated'">
<field name="account_id" />
<field name="update_account_id" />
<field name="notes" readonly="1"/>
<field name="type" invisible="1" />
</tree>
</field>
</page>
<page string="Fiscal positions" attrs="{'invisible': [('update_fiscal_position', '=', False)]}">
<field name="fiscal_position_ids" nolabel="1">
<tree string="Fiscal positions" colors="red:type=='updated'">
<field name="fiscal_position_id" />
<field name="update_fiscal_position_id" />
<field name="notes" readonly="1" />
<field name="type" invisible="1" />
</tree>
</field>
</page>
<group col="4" colspan="4"
attrs="{'invisible':[('state','!=','done'),]}">
<separator colspan="4" string="Log" />
<field name="log" colspan="4" nolabel="1" />
<group colspan="4">
<separator colspan="4" string="Summary of created objects" />
<field name="new_taxes" />
<field name="new_accounts" />
<field name="new_fps" />
</group>
<group colspan="4">
<separator colspan="4" string="Summary of updated objects" />
<field name="updated_taxes" />
<field name="deleted_taxes" />
<field name="updated_accounts" />
<field name="updated_fps" />
</group>
</group>
</notebook>
</group>
<footer>
<span states="init">
<button name="action_find_records" string="Next" class="oe_highlight" type="object" />
</span>
<span states="ready">
<button name="action_init" string="Previous" type="object" />
<button name="action_update_records" string="Create/Update" type="object" class="oe_highlight" />
</span>
<span states="init,ready"> or </span>
<button special="cancel" string="Close" class="oe_link" />
</footer>
</form>
</field>
</record>
<group col="4" colspan="4"
attrs="{'invisible':[('state','!=','done'),]}">
<separator colspan="4" string="Log" />
<field name="log" colspan="4" nolabel="1" />
<group colspan="4">
<separator colspan="4" string="Summary of created objects" />
<field name="new_tax_codes" />
<field name="new_taxes" />
<field name="new_accounts" />
<field name="new_fps" />
</group>
<group colspan="4">
<separator colspan="4" string="Summary of updated objects" />
<field name="updated_tax_codes" />
<field name="updated_taxes" />
<field name="updated_accounts" />
<field name="updated_fps" />
</group>
<group colspan="4">
<separator colspan="4" string="Summary of deleted objects" />
<field name="deleted_tax_codes" />
</group>
</group>
<record id="action_wizard_update_chart" model="ir.actions.act_window">
<field name="name">Update chart of accounts</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">wizard.update.charts.accounts</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
<footer>
<div states="init">
<button name="action_find_records" string="Next" class="oe_highlight" type="object" />
or
<button special="cancel" string="Cancel" class="oe_link" />
</div>
<div states="ready">
<button name="action_init" string="Previous" type="object" />
<button name="action_update_records" string="Create/Update" type="object" class="oe_highlight" />
or
<button special="cancel" string="Cancel" class="oe_link" />
</div>
<div states="done">
<button special="cancel" string="Close" class="oe_link" />
</div>
</footer>
</form>
</field>
</record>
<record id="action_wizard_update_chart" model="ir.actions.act_window">
<field name="name">Update chart of accounts</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">wizard.update.charts.accounts</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
<menuitem sequence="0" parent="account.account_account_menu" action="action_wizard_update_chart" id="menu_wizard" />
</data>
</openerp>
</odoo>