[V6]on_change_product search for the property id instead of account_id

Bug #900266 reported by Damien Raemy
16
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Odoo Addons (MOVED TO GITHUB)
Confirmed
Low
OpenERP Publisher's Warranty Team

Bug Description

Hello,

In addons/account/invoice.py, you'll see this lines (1345):
    app_acc_exp = account_obj.browse(cr, uid, exp_pro_id, context=context)[0]
But, if you search at exp_pro_id, you'll see that it is define in line 1319:

    exp_pro_id = property_obj.search(cr, uid, [('name','=','property_account_expense'), 'res_id','=','product.template,'+str(res.product_tmpl_id.id)+''),('company_id','=',company_id)])

or 1321:

    exp_pro_id = property_obj.search(cr, uid, [('name','=','property_account_expense_categ'),('res_id','=','product.template,'+str(res.categ_id.id)+''),('company_id','=',company_id)])

exp_pro_id is the id of a property (table ir.property), not of an account. This causes errors.

To resolve the problem, you should use the same function that the in account.

     # Get the fields from the ir.property record
     my_value = property_obj.read(cr,uid,in_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])

I use OpenERP 6.0.3 (the release we can download from the download page in the openerp website)

Tags: maintenance
Revision history for this message
Ravish(OpenERP) (rmu-openerp) wrote :

Hello Damien

I have checked your issue at my side. It's working properly
the code you have suggested is already updated in stable(6.0.3) at line no "1332".
so you please check with updated code.
if you still face the problem. notify us
Thanks
Ravish

Changed in openobject-addons:
status: New → Incomplete
Revision history for this message
Damien Raemy (damien.raemy) wrote :

Hello,

I looked at the last version of the code on http://bazaar.launchpad.net/~openerp/openobject-addons/6.0/view/head:/account/invoice.py

At the line 1332 and following (-> 1337), the variable app_acc_in is defined, and defined correctly.

What I said is that the variable app_acc_exp should be defined like that too (see line 1346).

Because the browse search to the account with the id exp_pro_id, but exp_pro_id contains the id of the property, not of the account (see line 1320 or 1322: "property_obj.search(cr, uid, [...").

Do you agree with me?

Revision history for this message
hifly (csnlca) wrote : Re: [Bug 900266] Re: on_change_product search for the property id instead of account_id

Hello,

I checked the source version 6.0.3 (in Aug.).
Damien is exactly!

Pls check the newest code!

Thanks

Hifly

On Wed, Dec 21, 2011 at 9:28 PM, Damien <email address hidden> wrote:

> Hello,
>
> I looked at the last version of the code on
> http://bazaar.launchpad.net/~openerp/openobject-
> addons/6.0/view/head:/account/invoice.py
>
> At the line 1332 and following (-> 1337), the variable app_acc_in is
> defined, and defined correctly.
>
> What I said is that the variable app_acc_exp should be defined like that
> too (see line 1346).
>
> Because the browse search to the account with the id exp_pro_id, but
> exp_pro_id contains the id of the property, not of the account (see line
> 1320 or 1322: "property_obj.search(cr, uid, [...").
>
> Do you agree with me?
>
> --
> 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/900266
>
> Title:
> on_change_product search for the property id instead of account_id
>
> Status in OpenERP Addons (modules):
> Incomplete
>
> Bug description:
> Hello,
>
> In addons/account/invoice.py, you'll see this lines (1345):
> app_acc_exp = account_obj.browse(cr, uid, exp_pro_id,
> context=context)[0]
> But, if you search at exp_pro_id, you'll see that it is define in line
> 1319:
>
> exp_pro_id = property_obj.search(cr, uid,
> [('name','=','property_account_expense'),
> 'res_id','=','product.template,'+str(res.product_tmpl_id.id
> )+''),('company_id','=',company_id)])
>
> or 1321:
>
> exp_pro_id = property_obj.search(cr, uid,
>
> [('name','=','property_account_expense_categ'),('res_id','=','product.template,'+str(
> res.categ_id.id)+''),('company_id','=',company_id)])
>
> exp_pro_id is the id of a property (table ir.property), not of an
> account. This causes errors.
>
> To resolve the problem, you should use the same function that the in
> account.
>
> # Get the fields from the ir.property record
> my_value =
> property_obj.read(cr,uid,in_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])
>
> I use OpenERP 6.0.3 (the release we can download from the download
> page in the openerp website)
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/openobject-addons/+bug/900266/+subscriptions
>

Revision history for this message
Amit Parik (amit-parik) wrote : Re: on_change_product search for the property id instead of account_id

Hello Damien,

Thanks for your quick reply!
You are right, we have to use read method rather then browse just like we have used in in_pro_id.

So I am assigning this to OPW team.

Thank you!

Changed in openobject-addons:
assignee: nobody → OpenERP Publisher's Warranty Team (openerp-opw)
importance: Undecided → Low
status: Incomplete → Confirmed
summary: - on_change_product search for the property id instead of account_id
+ [V6]on_change_product search for the property id instead of account_id
tags: added: maintenance
Revision history for this message
Eric Caudal - www.elico-corp.com (elicoidal) wrote :

to be noted that in bug https://bugs.launchpad.net/bugs/909243 there is another problem that affects multi-company behavior

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.