[MIG] account_chart_update: Migration to 8.0
* Move out of unported * Set account_chart_update installable * value_reference of ir.property is a char * Use get_by_record method of ir.property * number digits is returned before assignment in case of property exist but account not * product_obj isn't used
This commit is contained in:
parent
35ff8d9671
commit
1f48ac7fd6
@ -72,5 +72,5 @@ Any problem found while updating will be shown on the last step.
|
||||
'wizard/wizard_chart_update_view.xml',
|
||||
],
|
||||
"active": False,
|
||||
"installable": True
|
||||
'installable': True
|
||||
}
|
||||
|
@ -19,10 +19,6 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
"""
|
||||
Account Chart Update Wizard
|
||||
"""
|
||||
|
||||
from openerp.osv import fields, orm
|
||||
from openerp.tools.translate import _
|
||||
import logging
|
||||
@ -255,7 +251,6 @@ class wizard_update_charts_accounts(orm.TransientModel):
|
||||
if context is None:
|
||||
context = {}
|
||||
property_obj = self.pool.get('ir.property')
|
||||
account_obj = self.pool.get('account.account')
|
||||
if not company_id:
|
||||
user = self.pool.get('res.users').browse(cr, uid, uid, context)
|
||||
company_id = user.company_id.id
|
||||
@ -265,6 +260,7 @@ class wizard_update_charts_accounts(orm.TransientModel):
|
||||
('res_id', '=', False),
|
||||
('value_reference', '!=', False)
|
||||
])
|
||||
number_digits = 6
|
||||
if not property_ids:
|
||||
# Try to get a generic (no-company) property
|
||||
property_ids = property_obj.search(cr, uid, [
|
||||
@ -272,15 +268,13 @@ class wizard_update_charts_accounts(orm.TransientModel):
|
||||
('res_id', '=', False),
|
||||
('value_reference', '!=', False)
|
||||
])
|
||||
number_digits = 6
|
||||
if property_ids:
|
||||
prop = property_obj.browse(
|
||||
cr, uid, property_ids[0], context=context)
|
||||
account_id = prop.value_reference.id
|
||||
if account_id:
|
||||
code = account_obj.read(
|
||||
cr, uid, account_id, ['code'], context)['code']
|
||||
number_digits = len(code)
|
||||
account = property_obj.get_by_record(cr, uid, prop,
|
||||
context=context)
|
||||
if account:
|
||||
number_digits = len(account.code)
|
||||
return number_digits
|
||||
|
||||
_defaults = {
|
||||
@ -464,6 +458,7 @@ 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(
|
||||
@ -479,6 +474,7 @@ 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,
|
||||
@ -533,6 +529,7 @@ 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)
|
||||
|
150
account_chart_update/wizard/wizard_chart_update_view.xml
Normal file
150
account_chart_update/wizard/wizard_chart_update_view.xml
Normal file
@ -0,0 +1,150 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<!-- 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 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" on_change="onchange_company_id(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: 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)]}">
|
||||
<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>
|
||||
|
||||
</notebook>
|
||||
</group>
|
||||
|
||||
<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>
|
||||
|
||||
<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>
|
Loading…
Reference in New Issue
Block a user