[IMP] small improvement : calling reopen method in action_init + indentation
This commit is contained in:
parent
dcfd81d0e1
commit
83c5c74a7a
@ -96,9 +96,9 @@ class wizard_update_charts_accounts(orm.TransientModel):
|
|||||||
|
|
||||||
_columns = {
|
_columns = {
|
||||||
'state': fields.selection([
|
'state': fields.selection([
|
||||||
('init', 'Step 1'),
|
('init', 'Step 1'),
|
||||||
('ready', 'Step 2'),
|
('ready', 'Step 2'),
|
||||||
('done', 'Wizard Complete')
|
('done', 'Wizard completed')
|
||||||
], 'Status', readonly=True),
|
], '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', required=True, ondelete='set null'),
|
'chart_template_id': fields.many2one('account.chart.template', 'Chart Template', required=True, ondelete='set null'),
|
||||||
@ -125,9 +125,7 @@ class wizard_update_charts_accounts(orm.TransientModel):
|
|||||||
'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)
|
'log': fields.text('Messages and Errors', readonly=True)
|
||||||
}
|
}
|
||||||
"""
|
|
||||||
Redefine the search to search by company name.
|
|
||||||
"""
|
|
||||||
def name_search(self, cr, user, name,
|
def name_search(self, cr, user, name,
|
||||||
args=None, operator='ilike', context=None, limit=80):
|
args=None, operator='ilike', context=None, limit=80):
|
||||||
if not name:
|
if not name:
|
||||||
@ -183,29 +181,24 @@ class wizard_update_charts_accounts(orm.TransientModel):
|
|||||||
if not company_id:
|
if not company_id:
|
||||||
user = self.pool.get('res.users').browse(cr, uid, uid, context)
|
user = self.pool.get('res.users').browse(cr, uid, uid, context)
|
||||||
company_id = user.company_id.id
|
company_id = user.company_id.id
|
||||||
property_ids = property_obj.search(
|
property_ids = property_obj.search(cr, uid, [
|
||||||
cr,
|
('name', '=', 'property_account_receivable'),
|
||||||
uid,
|
('company_id', '=', company_id),
|
||||||
[('name', '=', 'property_account_receivable'),
|
('res_id', '=', False),
|
||||||
('company_id', '=', company_id),
|
('value_reference', '!=', False)
|
||||||
('res_id', '=', False),
|
])
|
||||||
('value_reference', '!=', False)
|
|
||||||
])
|
|
||||||
if not property_ids:
|
if not property_ids:
|
||||||
# Try to get a generic (no-company) property
|
# Try to get a generic (no-company) property
|
||||||
property_ids = property_obj.search(
|
property_ids = property_obj.search(cr, uid, [
|
||||||
cr,
|
('name', '=', 'property_account_receivable'),
|
||||||
uid,
|
('res_id', '=', False),
|
||||||
[('name', '=', 'property_account_receivable'),
|
('value_reference', '!=', False)
|
||||||
('res_id', '=', False),
|
])
|
||||||
('value_reference', '!=', False)
|
number_digits = 6
|
||||||
])
|
|
||||||
number_digits = 6
|
|
||||||
if property_ids:
|
if property_ids:
|
||||||
prop = property_obj.browse(
|
prop = property_obj.browse(
|
||||||
cr, uid, property_ids[0], context=context)
|
cr, uid, property_ids[0], context=context)
|
||||||
account_id = prop.value_reference.id
|
account_id = prop.value_reference.id
|
||||||
|
|
||||||
if account_id:
|
if account_id:
|
||||||
code = account_obj.read(
|
code = account_obj.read(
|
||||||
cr, uid, account_id, ['code'], context)['code']
|
cr, uid, account_id, ['code'], context)['code']
|
||||||
@ -231,13 +224,9 @@ class wizard_update_charts_accounts(orm.TransientModel):
|
|||||||
def onchange_company_id(self, cr, uid, ids, company_id, context=None):
|
def onchange_company_id(self, cr, uid, ids, company_id, context=None):
|
||||||
res = {
|
res = {
|
||||||
'value': {
|
'value': {
|
||||||
'code_digits': self._get_code_digits(
|
'code_digits': self._get_code_digits(cr, uid, context=context, company_id=company_id),
|
||||||
cr,
|
}
|
||||||
uid,
|
}
|
||||||
context=context,
|
|
||||||
company_id=company_id),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return res
|
return res
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@ -248,22 +237,7 @@ class wizard_update_charts_accounts(orm.TransientModel):
|
|||||||
context = {}
|
context = {}
|
||||||
wizard = self.browse(cr, uid, ids[0], context=context)
|
wizard = self.browse(cr, uid, ids[0], context=context)
|
||||||
self.write(cr, uid, ids, {'state': 'init'}, context)
|
self.write(cr, uid, ids, {'state': 'init'}, context)
|
||||||
view_wizard = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'account_chart_update', 'view_update_multi_chart')
|
return _reopen(self, wizard.id, 'wizard.update.chart.accounts')
|
||||||
view_wizard_id = view_wizard and view_wizard[1] or False,
|
|
||||||
res = {
|
|
||||||
'type': 'ir.actions.act_window',
|
|
||||||
'name': _("Update Chart of Accounts from a Chart Template "),
|
|
||||||
'res_model': 'wizard.update.charts.accounts',
|
|
||||||
'view_type': 'form',
|
|
||||||
'view_mode': 'form',
|
|
||||||
'res_id': wizard.id,
|
|
||||||
'view_id': view_wizard_id,
|
|
||||||
'context': context,
|
|
||||||
'target': 'new',
|
|
||||||
}
|
|
||||||
return res
|
|
||||||
|
|
||||||
return True
|
|
||||||
|
|
||||||
##########################################################################
|
##########################################################################
|
||||||
# Helper methods
|
# Helper methods
|
||||||
@ -397,13 +371,11 @@ class wizard_update_charts_accounts(orm.TransientModel):
|
|||||||
}, context)
|
}, context)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'new': new_tax_codes,
|
'new': new_tax_codes,
|
||||||
'updated': updated_tax_codes,
|
'updated': updated_tax_codes,
|
||||||
'mapping': tax_code_template_mapping
|
'mapping': tax_code_template_mapping
|
||||||
}
|
}
|
||||||
"""
|
|
||||||
Search for, and load, tax templates to create/update.
|
|
||||||
"""
|
|
||||||
def _find_taxes(self, cr, uid, wizard, context=None):
|
def _find_taxes(self, cr, uid, wizard, context=None):
|
||||||
new_taxes = 0
|
new_taxes = 0
|
||||||
updated_taxes = 0
|
updated_taxes = 0
|
||||||
@ -924,8 +896,7 @@ class wizard_update_charts_accounts(orm.TransientModel):
|
|||||||
|
|
||||||
if children_ids:
|
if children_ids:
|
||||||
try:
|
try:
|
||||||
account_account.write(cr, uid, children_ids, {'parent_id':
|
account_account.write(cr, uid, children_ids, {'parent_id': parent_account.id}, context=context)
|
||||||
parent_account.id}, context=context)
|
|
||||||
except orm.except_orm, ex:
|
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)
|
||||||
|
|
||||||
@ -1110,7 +1081,7 @@ class wizard_update_charts_accounts(orm.TransientModel):
|
|||||||
vals_fp = {
|
vals_fp = {
|
||||||
'company_id': wizard.company_id.id,
|
'company_id': wizard.company_id.id,
|
||||||
'name': fp_template.name,
|
'name': fp_template.name,
|
||||||
}
|
}
|
||||||
fp_id = fiscalpositions.create(cr, uid, vals_fp)
|
fp_id = fiscalpositions.create(cr, uid, vals_fp)
|
||||||
new_fps += 1
|
new_fps += 1
|
||||||
modified = True
|
modified = True
|
||||||
@ -1261,8 +1232,8 @@ class wizard_update_charts_accounts_tax_code(orm.TransientModel):
|
|||||||
'tax_code_id': fields.many2one('account.tax.code.template', 'Tax code template', required=True, ondelete='set null'),
|
'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'),
|
'update_chart_wizard_id': fields.many2one('wizard.update.charts.accounts', 'Update chart wizard', required=True, ondelete='cascade'),
|
||||||
'type': fields.selection([
|
'type': fields.selection([
|
||||||
('new', 'New template'),
|
('new', 'New template'),
|
||||||
('updated', 'Updated template'),
|
('updated', 'Updated template'),
|
||||||
], 'Type'),
|
], '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'),
|
'notes': fields.text('Notes'),
|
||||||
@ -1284,8 +1255,8 @@ class wizard_update_charts_accounts_tax(orm.TransientModel):
|
|||||||
'tax_id': fields.many2one('account.tax.template', 'Tax template', required=True, ondelete='set null'),
|
'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'),
|
'update_chart_wizard_id': fields.many2one('wizard.update.charts.accounts', 'Update chart wizard', required=True, ondelete='cascade'),
|
||||||
'type': fields.selection([
|
'type': fields.selection([
|
||||||
('new', 'New template'),
|
('new', 'New template'),
|
||||||
('updated', 'Updated template'),
|
('updated', 'Updated template'),
|
||||||
], 'Type'),
|
], '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'),
|
'notes': fields.text('Notes'),
|
||||||
@ -1312,8 +1283,8 @@ class wizard_update_charts_accounts_account(orm.TransientModel):
|
|||||||
'account_id': fields.many2one('account.account.template', 'Account template', required=True, ondelete='set null'),
|
'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'),
|
'update_chart_wizard_id': fields.many2one('wizard.update.charts.accounts', 'Update chart wizard', required=True, ondelete='cascade'),
|
||||||
'type': fields.selection([
|
'type': fields.selection([
|
||||||
('new', 'New template'),
|
('new', 'New template'),
|
||||||
('updated', 'Updated template'),
|
('updated', 'Updated template'),
|
||||||
], 'Type'),
|
], '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'),
|
'notes': fields.text('Notes'),
|
||||||
@ -1336,9 +1307,9 @@ class wizard_update_charts_accounts_fiscal_position(orm.TransientModel):
|
|||||||
'fiscal_position_id': fields.many2one('account.fiscal.position.template', 'Fiscal position template', required=True, ondelete='set null'),
|
'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'),
|
'update_chart_wizard_id': fields.many2one('wizard.update.charts.accounts', 'Update chart wizard', required=True, ondelete='cascade'),
|
||||||
'type': fields.selection([
|
'type': fields.selection([
|
||||||
('new', 'New template'),
|
('new', 'New template'),
|
||||||
('updated', 'Updated template'),
|
('updated', 'Updated template'),
|
||||||
], 'Type'),
|
], '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'),
|
'notes': fields.text('Notes'),
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user