[5.0] stock module contains references to purchase (but does not depend on it)

Bug #596202 reported by Dukai Gábor
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Odoo Addons (MOVED TO GITHUB)
Fix Released
Low
Jay Vora (Serpent Consulting Services)
Odoo Server (MOVED TO GITHUB)
Won't Fix
Low
Unassigned

Bug Description

Hi!
5.0 latest bzr.
Checking for a field with hasattr() doesn't work because browse_record intercepts that call and always returns True. If the field doesn't exist, it prints a 'Programming Error' message in the log but still returns True.

The stock module is affected by this problem. How to check: install only the stock module and use the partial picking wizard with average price products.
This code in stock/wizard/wizard_partial_picking.py gives a 'Programming Error':
            if hasattr(m, 'purchase_line_id') and m.purchase_line_id:

Tags: maintenance
Revision history for this message
Olivier Dony (Odoo) (odo-openerp) wrote :

Regardless of the behavior of browse_record (which at first look in the code should not have hasattr() always returning True), this code is not correct as it break modularity. Installing stock without purchase is a valid case, and 'stock' should simply not have any reference to 'purchase' stuff *at all*.
This has been fixed in 6.0, and we should look into backporting it to stable (code related to purchase_line_id should move to purchase module)

Jay, do you think this qualifies for stable?

Changed in openobject-server:
assignee: nobody → Jay (OpenERP) (jvo-openerp)
importance: Undecided → Low
milestone: none → 5.0.16
status: New → Confirmed
summary: - hasattr() doesn't work with browse_record (5.0)
+ [5.0] stock module contains references to purchase (but does not depend
+ on it)
Revision history for this message
Olivier Dony (Odoo) (odo-openerp) wrote :

We can't touch such things in the server in a stable version, so closing the server side (from the original bug description) - this can be fixed in addons only

Changed in openobject-server:
assignee: Jay (OpenERP) (jvo-openerp) → nobody
status: Confirmed → Won't Fix
Changed in openobject-addons:
assignee: nobody → Jay (OpenERP) (jvo-openerp)
importance: Undecided → Low
milestone: none → 5.0.16
status: New → Confirmed
tags: added: maintenance
Changed in openobject-addons:
status: Confirmed → In Progress
Revision history for this message
Jay Vora (Serpent Consulting Services) (jayvora) wrote :

Hello,

Backporting all the changes in stable is not really advisable here.
However, blocking the ugly traceback of Programming error is one the preferred solutions here.

Thanks.

Revision history for this message
Dhruti Shastri(OpenERP) (dhs-openerp) wrote :

Hello Dukai Gábor,

I followed your steps and met with an error.

Actually,it is an unreliability of hasattr.

Here I am attaching patch.

Would you please check with the attached patch and notify me?

Thanks.

Revision history for this message
Olivier Dony (Odoo) (odo-openerp) wrote :

@Jay: you're right, fixing it that way is probably safer for stable. Go for it!

Revision history for this message
Olivier Dony (Odoo) (odo-openerp) wrote :

@DHS: your patch is ok for me, forgot to mention it :-)

Revision history for this message
Jay Vora (Serpent Consulting Services) (jayvora) wrote :

Thanks Olivier and DHS,
The fix has been applied by revision 2886 <email address hidden>.

Changed in openobject-addons:
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

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