Rohan Nayani(Open ERP) has proposed merging
lp:~openerp-dev/openobject-addons/trunk-l10n-control-dev-split-properties-func-from-execute-func-ron
into lp:~openerp-dev/openobject-addons/trunk-l10n-control-dev.
Requested reviews:
Rucha (Open ERP) (rpa-openerp)
For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-l10n-control-dev-split-properties-func-from-execute-func-ron/+merge/71671
Hello,
Created generate_properties() function for generating properties. This
function splited from execute method of wizard.multi.charts.accounts.
Thanks
RON
--
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-l10n-control-dev-split-properties-func-from-execute-func-ron/+merge/71671
Your team OpenERP R&D Team is subscribed to branch
lp:~openerp-dev/openobject-addons/trunk-l10n-control-dev.
=== modified file 'account/account.py'
--- account/account.py 2011-08-16 06:37:32 +0000
+++ account/account.py 2011-08-16 12:27:09 +0000
@@ -2861,6 +2861,50 @@
res['fields'][field]['selection'] = template_select
return res
+ def generate_properties(self, cr, uid, chart_template_id, acc_template_ref, company_id, context=None):
+ """
+ This method used for creating properties.
+ @param cr: A database cursor.
+ @param uid: ID of the user currently logged in.
+ @param chart_temp_id: Chart Template Id.
+ @param acc_template_ref: Account templates reference.
+ @param company_id: company_id selected from wizard.multi.charts.accounts.
+ """
+
+ if context is None:
+ context = {}
+ property_obj = self.pool.get('ir.property')
+ fields_obj = self.pool.get('ir.model.fields')
+
+ todo_list = [
+ ('property_account_receivable','res.partner','account.account'),
+ ('property_account_payable','res.partner','account.account'),
+ ('property_account_expense_categ','product.category','account.account'),
+ ('property_account_income_categ','product.category','account.account'),
+ ('property_account_expense','product.template','account.account'),
+ ('property_account_income','product.template','account.account'),
+ ('property_reserve_and_surplus_account','res.company','account.account')
+ ]
+ for record in todo_list:
+ rec_list = []
+ rec_list = property_obj.search(cr, uid, [('name','=', record[0] ),('company_id','=',company_id)])
+ account = getattr(chart_template_id, record[0])
+ field = fields_obj.search(cr, uid, [('name','=',record[0]),('model','=',record[1]),('relation','=',record[2])])
+ vals = {
+ 'name': record[0],
+ 'company_id': company_id,
+ 'fields_id': field[0],
+ 'value': account and 'account.account,' + str(acc_template_ref[account.id]) or False,
+ }
+
+ if rec_list:
+ #the property exist: modify it
+ property_obj.write(cr, uid, r, vals)
+ else:
+ #create the property
+ property_obj.create(cr, uid, vals)
+
+ return {}
def execute(self, cr, uid, ids, context=None):
obj_multi = self.browse(cr, uid, ids[0])
@@ -3106,38 +3150,8 @@
obj_journal.create(cr, uid, vals_journal)
current_num += 1
valid = True
-
- #create the properties
- property_obj = self.pool.get('ir.property')
- fields_obj = self.pool.get('ir.model.fields')
-
- todo_list = [
- ('property_account_receivable','res.partner','account.account'),
- ('property_account_payable','res.partner','account.account'),
- ('property_account_expense_categ','product.category','account.account'),
- ('property_account_income_categ','product.category','account.account'),
- ('property_account_expense','product.template','account.account'),
- ('property_account_income','product.template','account.account'),
- ('property_reserve_and_surplus_account','res.company','account.account')
- ]
- for record in todo_list:
- r = []
- r = property_obj.search(cr, uid, [('name','=', record[0] ),('company_id','=',company_id)])
- account = getattr(obj_multi.chart_template_id, record[0])
- field = fields_obj.search(cr, uid, [('name','=',record[0]),('model','=',record[1]),('relation','=',record[2])])
- vals = {
- 'name': record[0],
- 'company_id': company_id,
- 'fields_id': field[0],
- 'value': account and 'account.account,' + str(acc_template_ref[account.id]) or False,
- }
-
- if r:
- #the property exist: modify it
- property_obj.write(cr, uid, r, vals)
- else:
- #create the property
- property_obj.create(cr, uid, vals)
+ #This method used for creating properties.
+ self.generate_properties(cr, uid, obj_multi.chart_template_id, acc_template_ref, company_id, context=context)
#Generate Fiscal Position , Fiscal Position Accounts and Fiscal Position Taxes from templates
obj_fiscal_position_template.generate_fiscal_position(cr, uid, chart_temp_id, taxes_ids['tax_template_ref'], acc_template_ref, company_id, context=context)
_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help : https://help.launchpad.net/ListHelp