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 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 on the official charts of accounts, or to apply fixes performed on the chart
@ -17,15 +22,32 @@ The wizard:
Usage Usage
===== =====
The wizard, accesible from *Accounting > Configuration > Accounts > Update The wizard, accesible from *Accounting > Configuration > Settings > Chart of
chart of accounts*, lets the user select what kind of objects must Accounts > Update chart of accounts*, lets the user select what kind of objects
be checked/updated, and whether old records must be checked for changes and must be checked/updated, and whether old records must be checked for changes
updates. and updates.
It will display all the objects to be created / updated with some information It will display all the objects to be created / updated with some information
about the detected differences, and allow the user to exclude records about the detected differences, and allow the user to exclude records
individually. 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 Credits
======= =======
@ -39,6 +61,8 @@ Contributors
* invitu * invitu
* Stéphane Bidoul <stephane.bidoul@acsone.eu> * Stéphane Bidoul <stephane.bidoul@acsone.eu>
* Antonio Espinosa <antonioea@antiun.com> * Antonio Espinosa <antonioea@antiun.com>
* Jairo Llopis <jairo.llopis@tecnativa.com>
* Jacques-Etienne Baudoux <je@bcim.be>
Maintainer 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 mission is to support the collaborative development of Odoo features and
promote its widespread use. 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 -*- # -*- coding: utf-8 -*-
############################################################################## # © 2010 Zikzakmedia S.L. (http://www.zikzakmedia.com)
# # © 2010 Pexego Sistemas Informáticos S.L.(http://www.pexego.es)
# Copyright (c) 2010 Zikzakmedia S.L. (http://www.zikzakmedia.com) # © 2016 Jairo Llopis <jairo.llopis@tecnativa.com>
# Copyright (c) 2010 Pexego Sistemas Informáticos S.L. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
# (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
"""
from . import model
from . import wizard from . import wizard

View File

@ -1,51 +1,38 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
############################################################################## # © 2010 Zikzakmedia S.L. (http://www.zikzakmedia.com)
# # © 2010 Pexego Sistemas Informáticos S.L.(http://www.pexego.es)
# OpenERP, Open Source Management Solution # © 2013 Joaquin Gutierrez (http://www.gutierrezweb.es)
# Copyright (c) 2010 Zikzakmedia S.L. (http://www.zikzakmedia.com) # © 2015 Pedro Manuel Baeza <pedro.baeza@serviciosbaeza.com>
# Copyright (c) 2010 Pexego Sistemas Informáticos S.L.(http://www.pexego.es) # © 2016 Jairo Llopis <jairo.llopis@tecnativa.com>
# Copyright (c) 2013 Joaquin Gutierrez (http://www.gutierrezweb.es) # © 2016 Jacques-Etienne Baudoux <je@bcim.be>
# Pedro Manuel Baeza <pedro.baeza@serviciosbaeza.com> # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
# 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
#
##############################################################################
{ {
'name': "Detect changes and update the Account Chart from a template", '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, " 'author': "Zikzakmedia SL, "
"Pexego, " "Pexego, "
"Serv. Tecnol. Avanzados - Pedro M. Baeza, " "Serv. Tecnol. Avanzados - Pedro M. Baeza, "
"ACSONE A/V, " "ACSONE A/V, "
"Tecnativa, "
"BCIM,"
"Odoo Community Association (OCA)", "Odoo Community Association (OCA)",
'website': "http://odoo-community.org", 'website': "http://odoo-community.org",
'depends': ["account"], 'depends': ["account"],
'category': "Generic Modules/Accounting", 'category': "Accounting & Finance",
'contributors': [ 'contributors': [
'Joaquín Gutierrez', 'Joaquín Gutierrez',
'Pedro M. Baeza', 'Pedro M. Baeza',
'invitu', 'invitu',
'Stéphane Bidoul', 'Stéphane Bidoul',
'Jairo Llopis',
'Jacques-Etienne Baudoux',
], ],
'license': "AGPL-3", 'license': "AGPL-3",
"demo": [],
"data": [ "data": [
'wizard/wizard_chart_update_view.xml', '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 -*- # -*- coding: utf-8 -*-
############################################################################## # © 2010 Zikzakmedia S.L. (http://www.zikzakmedia.com)
# # © 2010 Pexego Sistemas Informáticos S.L.(http://www.pexego.es)
# Copyright (c) 2010 Zikzakmedia S.L. (http://www.zikzakmedia.com) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
# 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
"""
from . import wizard_chart_update 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"?> <?xml version="1.0" encoding="utf-8"?>
<openerp> <!-- © 2016 Jairo Llopis <jairo.llopis@tecnativa.com>
<data> 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"> <group attrs="{'invisible':[('state','!=','init')]}">
<field name="name">Update Chart of Accounts from a Chart Template <h5>
</field> <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>
<field name="model">wizard.update.charts.accounts</field> <p>Note: Only the changed fields are updated.</p>
<field name="arch" type="xml"> </h5>
<form string="Update chart of accounts from a template" version="7.0"> </group>
<header> <group attrs="{'invisible':[('state','!=','ready'),]}"
<field name="state" select="2" widget="statusbar" string="Records to create/update">
statusbar_visible="init,ready,done" statusbar_colors='{"ready":"blue","done":"blue"}' /> <notebook colspan="4">
</header> <page string="Taxes" attrs="{'invisible': [('update_tax', '=', False)]}">
<group attrs="{'invisible':[('state','!=','init')]}"> <field name="tax_ids" nolabel="1">
<h3> <tree string="Taxes" colors="red:type=='updated'">
<p><center>This wizard will update your accounts, taxes and fiscal positions according to the selected chart template</center></p> <field name="tax_id" />
</h3> <field name="update_tax_id" />
</group> <field name="type_tax_use"/>
<group string="Chart of Accounts" attrs="{'invisible':[('state','!=','init')]}"> <field name="notes"/>
<field name="company_id" <field name="type"/>
attrs="{'invisible':[('state','!=','init')]}" </tree>
/> </field>
<field name="code_digits" attrs="{'invisible':[('state','!=','init')]}" /> </page>
<field name="chart_template_id" <page string="Accounts" attrs="{'invisible': [('update_account', '=', False)]}">
domain="[('visible', '=', True)]" <field name="account_ids" nolabel="1">
attrs="{'invisible': [('state','!=','init')], 'required': True}" <tree string="Accounts" colors="red:type=='updated'">
/> <field name="account_id" />
<field name="lang" attrs="{'invisible':[('state','!=','init')]}" /> <field name="update_account_id" />
</group> <field name="notes"/>
<group attrs="{'invisible':[('state','!=','init')]}"> <field name="type"/>
<group string="Update records?"> </tree>
<field name="update_tax_code" /> </field>
<field name="update_tax" /> </page>
<field name="update_account" /> <page string="Fiscal positions" attrs="{'invisible': [('update_fiscal_position', '=', False)]}">
<field name="update_fiscal_position" /> <field name="fiscal_position_ids" nolabel="1">
</group> <tree string="Fiscal positions" colors="red:type=='updated'">
<group string="Other options" attrs="{'invisible':[('state','!=','init')]}"> <field name="fiscal_position_id" />
<field name="update_children_accounts_parent" /> <field name="update_fiscal_position_id" />
<field name="continue_on_errors" /> <field name="notes"/>
</group> <field name="type"/>
</group> </tree>
</field>
</page>
<group attrs="{'invisible':[('state','!=','init')]}"> </notebook>
<h5> </group>
<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>
<page string="Taxes" attrs="{'invisible': [('update_tax', '=', False)]}"> <group col="4" colspan="4"
<field name="tax_ids" nolabel="1"> attrs="{'invisible':[('state','!=','done'),]}">
<tree string="Taxes" colors="red:type=='updated'"> <separator colspan="4" string="Log" />
<field name="tax_id" /> <field name="log" colspan="4" nolabel="1" />
<field name="update_tax_id" /> <group colspan="4">
<field name="notes" readonly="1"/> <separator colspan="4" string="Summary of created objects" />
<field name="type" invisible="1" /> <field name="new_taxes" />
</tree> <field name="new_accounts" />
</field> <field name="new_fps" />
</page> </group>
<page string="Accounts" attrs="{'invisible': [('update_account', '=', False)]}"> <group colspan="4">
<field name="account_ids" nolabel="1"> <separator colspan="4" string="Summary of updated objects" />
<tree string="Accounts" colors="red:type=='updated'"> <field name="updated_taxes" />
<field name="account_id" /> <field name="deleted_taxes" />
<field name="update_account_id" /> <field name="updated_accounts" />
<field name="notes" readonly="1"/> <field name="updated_fps" />
<field name="type" invisible="1" /> </group>
</tree> </group>
</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>
</notebook> <footer>
</group> <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" <record id="action_wizard_update_chart" model="ir.actions.act_window">
attrs="{'invisible':[('state','!=','done'),]}"> <field name="name">Update chart of accounts</field>
<separator colspan="4" string="Log" /> <field name="type">ir.actions.act_window</field>
<field name="log" colspan="4" nolabel="1" /> <field name="res_model">wizard.update.charts.accounts</field>
<group colspan="4"> <field name="view_type">form</field>
<separator colspan="4" string="Summary of created objects" /> <field name="view_mode">form</field>
<field name="new_tax_codes" /> <field name="target">new</field>
<field name="new_taxes" /> </record>
<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>
<footer> </odoo>
<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>