← Back to team overview

openerp-india team mailing list archive

[Bug 1246116] [NEW] issue with supplier reference and price in purchase order

 

Public bug reported:

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)

** Affects: openobject-addons
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of OpenERP
Indian Team, which is 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):
  New

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)

To manage notifications about this bug go to:
https://bugs.launchpad.net/openobject-addons/+bug/1246116/+subscriptions


Follow ups

References