avanzosc team mailing list archive
-
avanzosc team
-
Mailing list archive
-
Message #00214
[Bug 849531] Re: Bug en la creación del arbol de cuentas analíticas
The parnt_id is correct since it's the passed variable form the
function. I have copied the function below. Line 69 is making this into
a recursive function. So as long as acc.parent_id.id is correct this
should be correct.
FILE: manufacturing_analitic_accounts.py
----- CUT -----
56) def calculate_estimated(self, cr, uid, parnt_id, amount):
57)
58) analytic_obj = self.pool.get('account.analytic.account')
59) if parnt_id:
60) acc = analytic_obj.browse(cr, uid, parnt_id)
61)
62) total = acc.total_estimated
63) if total is None:
64) total = 0.0
65) tot = total + amount
66) resu = acc.debit - tot
67) analytic_obj.write(cr,uid,parnt_id,{'total_estimated':tot,'acc_result':resu})
68) if not acc.acc_type == 'MF':
69) self.calculate_estimated(cr, uid, acc.parent_id.id, amount)
70)
71) return True
----- CUT -----
This function is called from wizard/users.py and
wizard/mrp_analytic_schema_wizard.py. The mrp_analytic_schema_wizard.py
is the one calling according to the error dump above.
man_account on line 216 below is the variable sent in that is making the
error. The man_account variable is set on line 187 below. Parent of that
is set on line 162... But wait... Lets look at line 161-163... Earlier
all set states has been done with create but now we do first crteate
tehn we do a browse and we try to use that browserecord with a .id on
line 183.
So the question is do we really need do the browse? and in that case why
does only a few in the chain have the browse. Should the .id online 183
be there ?
FILE: wizard/mrp_analytic_schema_wizard.py
----- CUT -----
150) parent_op_acc = account_analytic_obj.browse(cr, uid, parent_acc_search[0])
151) else:
152) values = {
153) 'name':parent_op_acc_name,
154) 'code':parent_op_acc_name,
155) 'currency_id': wizard_config.company_id.currency_id.id,
156) 'company_id': wizard_config.company_id.id,
157) 'state':'open',
158) 'acc_type':'MF',
159) 'total_estimated':0.0,
160) }
161) parent_op_acc_create = account_analytic_obj.create(cr, uid, values)
162) parent_op_acc = account_analytic_obj.browse(cr, uid,parent_op_acc_create)
163) result.append(values)
164)
165) #Comprobación y creación de cuenta analitica de orden de fabricación
166) op_acc_code = False
167) production_id = False
168) progress = 90 / len(prod_brow)
169) for prod in prod_brow:
170) production_id = prod.id
171) op_acc_code = 'OF' + str(production_id)
172) acc_search = account_analytic_obj.search(cr, uid,[('code', '=', op_acc_code)])
173)
174) if acc_search:
175) raise osv.except_osv(_('Unable to perform action'), _('Analytic account for this Manufacturing order already exists.'))
176) else:
177) values={
178) 'name':op_acc_code + " " +prod.name +" -> "+prod.product_id.name,
179) 'code':op_acc_code,
180) 'currency_id': wizard_config.company_id.currency_id.id,
181) 'company_id': wizard_config.company_id.id,
182) 'state':'open',
183) 'parent_id':parent_op_acc.id,
184) 'total_estimated':0.0,
185) 'acc_type':'OF'
186) }
187) man_account = account_analytic_obj.create(cr, uid, values)
188) values['name'] = '| '+values['name']
189) result.append(values)
190) operations_obj_search = operations_obj.search(cr, uid, [('production_id','=',prod.id)])
191) operations = operations_obj.browse(cr, uid, operations_obj_search)
192)
193) #Cuenta analitica de costes fijos
194)
195) prod_maq_name_acc_code = op_acc_code + 'FIX'
196) cost_fixed = prod.fixed_costs
197) est = 0
198) for fin in cost_fixed:
199) est += fin.estimated
200) values={
201) 'name':prod_maq_name_acc_code + " " + _('Fixed') ,
202) 'code':prod_maq_name_acc_code ,
203) 'currency_id': wizard_config.company_id.currency_id.id,
204) 'company_id': wizard_config.company_id.id,
205) 'state':'open',
206) 'parent_id':man_account,
207) 'total_estimated':est,
208) 'acc_type':'FIX',
209) }
210) man_fix_account = account_analytic_obj.create(cr, uid, values)
211) values['name'] = '| '+values['name']
212) values['parent_id'] = man_fix_account
213) result.append(values)
214) account_analytic_obj.recalculate_result(cr, uid, man_fix_account)
215) account_analytic_obj.calculate_estimated(cr, uid, man_account, est)
216)
----- CUT -----
--
You received this bug notification because you are a member of Avanzosc
Developers, which is subscribed to Avanzosc developments.
https://bugs.launchpad.net/bugs/849531
Title:
Bug en la creación del arbol de cuentas analíticas
Status in Avanzosc OpenERP modules:
Fix Committed
Bug description:
Al pulsar el botón de creación de cuentas analíticas se obtiene:
Environment Information :
System : Windows-32bit
OS Name : nt
Operating System Release :
Operating System Version : 32bit
Operating System Architecture : 32bit
Operating System Locale : es_ES.cp1252
Python Version : 2.5.2
OpenERP-Client Version : 6.0.2
Last revision No. & ID :Bazaar Package not Found !Traceback (most recent call last):
File "/usr/local/lib/python2.6/dist-packages/openerp-server/netsvc.py", line 489, in dispatch
result = ExportService.getService(service_name).dispatch(method, auth, params)
File "/usr/local/lib/python2.6/dist-packages/openerp-server/service/web_services.py", line 599, in dispatch
res = fn(db, uid, *params)
File "/usr/local/lib/python2.6/dist-packages/openerp-server/osv/osv.py", line 122, in wrapper
return f(self, dbname, *args, **kwargs)
File "/usr/local/lib/python2.6/dist-packages/openerp-server/osv/osv.py", line 176, in execute
res = self.execute_cr(cr, uid, obj, method, *args, **kw)
File "/usr/local/lib/python2.6/dist-packages/openerp-server/osv/osv.py", line 167, in execute_cr
return getattr(object, method)(cr, uid, *args, **kw)
File "/usr/local/lib/python2.6/dist-packages/openerp-server/addons/mrp_analytics_control/wizard/mrp_analytic_schema_wizard.py", line 216, in create_analytic_structure
account_analytic_obj.calculate_estimated(cr, uid, man_account, est)
File "/usr/local/lib/python2.6/dist-packages/openerp-server/addons/mrp_analytics_control/manufacturing_analitic_accounts.py", line 68, in calculate_estimated
self.calculate_estimated(cr, uid, acc.parent_id.id, amount)
File "/usr/local/lib/python2.6/dist-packages/openerp-server/addons/mrp_analytics_control/manufacturing_analitic_accounts.py", line 68, in calculate_estimated
self.calculate_estimated(cr, uid, acc.parent_id.id, amount)
File "/usr/local/lib/python2.6/dist-packages/openerp-server/addons/mrp_analytics_control/manufacturing_analitic_accounts.py", line 59, in calculate_estimated
acc = analytic_obj.browse(cr, uid, parnt_id)
File "/usr/local/lib/python2.6/dist-packages/openerp-server/osv/orm.py", line 544, in browse
return browse_record(cr, uid, select, self, cache, context=context, list_class=self._list_class, fields_process=fields_process)
File "/usr/local/lib/python2.6/dist-packages/openerp-server/osv/orm.py", line 156, in __init__
raise BrowseRecordError(_('Wrong ID for the browse record, got %r, expected an integer.') % (id,))
BrowseRecordError: Wrong ID for the browse record, got False, expected an integer.
-------------------
Tiene pinta de un error de sintaxis en la llamada a la variable, aquí:
/manufacturing_analitic_accounts.py", line 59, in calculate_estimated
acc = analytic_obj.browse(cr, uid, parnt_id)
parent_id en vez de parnt_id.
To manage notifications about this bug go to:
https://bugs.launchpad.net/avanzosc/+bug/849531/+subscriptions
References