credativ team mailing list archive
-
credativ team
-
Mailing list archive
-
Message #02409
[Bug 909243] Re: Default property account search function incorrect for invoices
Eric, did you check for other property ?
IMHO there are many similar constructs
I do not understand the mechanism of property in detail but it seems
that there are these kind of problems
* data: the "parent" of the property has
** has company_id set, the property must match the parent.company_id
** no or an empty company_id field
*** forms: the company is passed in the context to the function (on change,... )
**** this must be default, because there is no working without company id set.
may be I missunderstood something
--
You received this bug notification because you are a member of OpenERP
Framework Experts, which is subscribed to OpenERP Addons.
https://bugs.launchpad.net/bugs/909243
Title:
Default property account search function incorrect for invoices
Status in OpenERP Addons (modules):
New
Bug description:
Several error in the product_id_change function that fails in multi-company environment.
1. account/invoice.py Line 1346 (+/-)
app_acc_exp = account_obj.browse(cr, uid, exp_pro_id, context=context)[0]
is a pointer to a ir_property object instead of a account_account object
I propose to change the code to
my_value = property_obj.read(cr,uid,exp_pro_id,['name','value_reference','res_id'])
# Parse the value_reference field to get the ID of the account.account record
account_id = int (my_value[0]["value_reference"].split(",")[1])
# Use the ID of the account.account record in the browse for the account.account record
app_acc_exp = account_obj.browse(cr, uid, account_id, context=context)
2. In line 1313-1376 (+/-) code search for account according to company.
nevertheless later in account/invoice.py/line 1378
if type in ('out_invoice','out_refund'):
a = res.product_tmpl_id.property_account_income.id
if not a:
a = res.categ_id.property_account_income_categ.id
else:
a = res.product_tmpl_id.property_account_expense.id
if not a:
a = res.categ_id.property_account_expense_categ.id
This piece of code search again the account id without company_id (and it is proposing an account id for another company which is incorrect).
I propose to change the code as follow:
if company_id:
[....]
if type in ('out_invoice','out_refund'):
a = app_acc_in.id
else:
a = app_acc_exp.id
else:#no company_id
if type in ('out_invoice','out_refund'):
a = res.product_tmpl_id.property_account_income.id
if not a:
a = res.categ_id.property_account_income_categ.id
else:
a = res.product_tmpl_id.property_account_expense.id
if not a:
a = res.categ_id.property_account_expense_categ.id
a = fpos_obj.map_account(cr, uid, fpos, a)
To manage notifications about this bug go to:
https://bugs.launchpad.net/openobject-addons/+bug/909243/+subscriptions
Follow ups
References