issue with supplier reference and price in purchase order

Bug #1246116 reported by Alexis de Lattre
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Odoo Addons (MOVED TO GITHUB)
Confirmed
Low
OpenERP R&D Addons Team 2

Bug Description

Here is the scenario to reproduce the problem on an up-to-date OpenERP v7.0 :
1. create a new DB with demo data
2. install the "purchase" module
3. Add yourself to the "Purchase pricelist" group
4. Edit the contact "Phillipp Miller" from "Mediapole" and set "supplier" = True
5. Edit the "default purchase pricelist" and, in the first rule, set "Based on" = "Supplier prices on the product form"
6. Edit the product "USB Adapter" : in the procurement tab, open the supplier info with supplier "Mediapole" and set :
- Supplier Product Name : Super USB3 Adapter
- Supplier Product Name SUSB3
- add a price rule : Quantity = 1, Price = 42.0
7. Create a new purchase order with partner = Philipp Miller (from Mediapole). Add a product line and choose product "USB Adapter" :
- the description is set to "[ADPT] USB Adapter" -> that's a bug, the description should be "[SUSB3] Super USB3 Adapter"
- the price is set to 0.0 -> that's a bug, the price should be 42.0.

Cause of the bug :
if you look at the code of purchase/purchase.py line 949, in the function onchange_product_id(), and the code of product/product.py line 624 in the function name_get(), you see that OpenERP looks for an exact match between partner_id of the purchase order and the 'name' field (M2O on res.partner) of product.supplierinfo. This is bad because our beloved OpenERP users may select a contact instead of a company in either a purchase order or a product.supplierinfo (nothing prevents them from doing so). The problem is the same for the supplier price.

I propose the following solution to fix the problem :
- in product.supplierinfo, you can only select a partner with "is_company" = True
- in the function onchange_product_id of the purchase.order.line, it should jump to the parent of the partner_id if it exists before querying the price and the description.
I have implemented the solution in a small module "purchase_fix_partner" that you can find in the branch lp:~akretion-team/+junk/addons-no-fluff-70 (https://code.launchpad.net/~akretion-team/+junk/addons-no-fluff-70)

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

Hi Alexis,

Thanks for reporting. The configuration you describe is a bit unusual because there is little reason to mark a contact as a supplier in most cases. Nevertheless if users do it, then perhaps they actually meant to have that contact always appear as the supplier for a given product. And in that case, they should probably be able to select that supplier on the product form, so the system will automatically select it when a draft PO is created for a procurement.

Based on the above, the fix I would suggest is to correct the supplier matching in purchase.order.line.onchange_product_id() so that it will allow matching any supplier that belongs to the same "commercial entity" (comparing `.commercial_partner_id.id` of both partners, instead of `id`) . This should be a one-line patch and would give maximum flexibility to the users. The first match would be found in the order in which they defined the suppliers. What do you think?

Changed in openobject-addons:
assignee: nobody → OpenERP R&D Addons Team 2 (openerp-dev-addons2)
importance: Undecided → Low
milestone: none → 7.0
status: New → Confirmed
Revision history for this message
Raphaël Valyi - http://www.akretion.com (rvalyi) wrote : Re: [Bug 1246116] Re: issue with supplier reference and price in purchase order
Download full text (4.6 KiB)

That can be done certainly.
Now speaking about "1 line patch", at the time that regression was made by
OpenERP SA, there was a 250 lines patch that was able to fix that instead
of the 2500 lines patch applied by OpenERP SA. It's in the RS-OCB branches
where this problem doesn't occur (still including OpenERP SA 2500 lines
patch for easier compatibility).
And that one was exactly anticipated in the outrageous slides some claimed
I was retracting from: you can read point #4 at slide 7 of
http://www.slideshare.net/RaphalValyi/open-erp-v7-contacts-issue

But now that the mess is done, yes, why not add a one line patch to the
2500 lines crappy patch. Other similar will follow for years...

Cheers

On Wed, Oct 30, 2013 at 3:32 PM, Olivier Dony (OpenERP) <
<email address hidden>> wrote:

> Hi Alexis,
>
> Thanks for reporting. The configuration you describe is a bit unusual
> because there is little reason to mark a contact as a supplier in most
> cases. Nevertheless if users do it, then perhaps they actually meant to
> have that contact always appear as the supplier for a given product. And
> in that case, they should probably be able to select that supplier on
> the product form, so the system will automatically select it when a
> draft PO is created for a procurement.
>
> Based on the above, the fix I would suggest is to correct the supplier
> matching in purchase.order.line.onchange_product_id() so that it will
> allow matching any supplier that belongs to the same "commercial entity"
> (comparing `.commercial_partner_id.id` of both partners, instead of
> `id`) . This should be a one-line patch and would give maximum
> flexibility to the users. The first match would be found in the order in
> which they defined the suppliers. What do you think?
>
> ** Changed in: openobject-addons
> Importance: Undecided => Low
>
> ** Changed in: openobject-addons
> Status: New => Confirmed
>
> ** Changed in: openobject-addons
> Milestone: None => 7.0
>
> ** Changed in: openobject-addons
> Assignee: (unassigned) => OpenERP R&D Addons Team 2
> (openerp-dev-addons2)
>
> --
> You received this bug notification because you are subscribed to OpenERP
> Addons.
> https://bugs.launchpad.net/bugs/1246116
>
> Title:
> issue with supplier reference and price in purchase order
>
> Status in OpenERP Addons (modules):
> Confirmed
>
> Bug description:
> Here is the scenario to reproduce the problem on an up-to-date OpenERP
> v7.0 :
> 1. create a new DB with demo data
> 2. install the "purchase" module
> 3. Add yourself to the "Purchase pricelist" group
> 4. Edit the contact "Phillipp Miller" from "Mediapole" and set
> "supplier" = True
> 5. Edit the "default purchase pricelist" and, in the first rule, set
> "Based on" = "Supplier prices on the product form"
> 6. Edit the product "USB Adapter" : in the procurement tab, open the
> supplier info with supplier "Mediapole" and set :
> - Supplier Product Name : Super USB3 Adapter
> - Supplier Product Name SUSB3
> - add a price rule : Quantity = 1, Price = 42.0
> 7. Create a new purchase order with partner = Philipp Miller (from
> Mediapole). Add a product line and choose product "USB ...

Read more...

Revision history for this message
Raphaël Valyi - http://www.akretion.com (rvalyi) wrote :

Also for a reference this Github bug report may not exactly be the same, but at least it has the same root issue:
https://github.com/odoo/odoo/issues/1219

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.