← Back to team overview

c2c-oerpscenario team mailing list archive

[Bug 726831] [NEW] [stable 6.0] product/pricelist.py uses incorrect id when supplier info is set to find uom

 

Public bug reported:

This is going to be hard to describe how to replicate, and it may only
present itself when using multi variants and then intermittently, but
looking at code it is an obvious error.

On line 247 of product/pricelist.py there is a call to get the uom of a
product.  The id it passes to a prod_obj, is a variable called tmpl_id
which is the product template id.  At the very least when using
multivariants, the tmpl_id and the product_id differ, so the call looks
up the product with the template_id as its product_id.  This then causes
an error if and only if the uom of the product erroneously read is
different to the product that should have been read.

Current code line 247
product_default_uom = product_obj.read(cr, uid, [tmpl_id], ['uom_id'])[0]['uom_id'][0]

There are probably 2 ways of fixing this.  I have done and tested both,
but prefer 2, as the supplier pricing uom's work at template level, so
the comparison should, but not sure whether this causes issues if the
product differs from the product template, although it would be highly
unusual to use different categories of uom for variants.

1. Change the variable [tmpl_id] to be [product_id] (already created within the function).
Line 247: product_default_uom = product_obj.read(cr, uid, [product_id], ['uom_id'])[0]['uom_id'][0]
2. Change the product_obj read to a product_tmpl_obj read.  Would require getting a 'product.template' object.  
158 inserted : product_tmpl_obj = self.pool.get('product.template')
Line 247(248 after insert) product_default_uom = product_tmpl_obj.read(cr, uid, [tmpl_id], ['uom_id'])[0]['uom_id'][0]

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

-- 
You received this bug notification because you are a member of C2C
OERPScenario, which is subscribed to the OpenERP Project Group.
https://bugs.launchpad.net/bugs/726831

Title:
  [stable 6.0] product/pricelist.py uses incorrect id when supplier info
  is set to find uom

Status in OpenERP Modules (addons):
  New

Bug description:
  This is going to be hard to describe how to replicate, and it may only
  present itself when using multi variants and then intermittently, but
  looking at code it is an obvious error.

  On line 247 of product/pricelist.py there is a call to get the uom of
  a product.  The id it passes to a prod_obj, is a variable called
  tmpl_id which is the product template id.  At the very least when
  using multivariants, the tmpl_id and the product_id differ, so the
  call looks up the product with the template_id as its product_id.
  This then causes an error if and only if the uom of the product
  erroneously read is different to the product that should have been
  read.

  Current code line 247
  product_default_uom = product_obj.read(cr, uid, [tmpl_id], ['uom_id'])[0]['uom_id'][0]

  There are probably 2 ways of fixing this.  I have done and tested
  both, but prefer 2, as the supplier pricing uom's work at template
  level, so the comparison should, but not sure whether this causes
  issues if the product differs from the product template, although it
  would be highly unusual to use different categories of uom for
  variants.

  1. Change the variable [tmpl_id] to be [product_id] (already created within the function).
  Line 247: product_default_uom = product_obj.read(cr, uid, [product_id], ['uom_id'])[0]['uom_id'][0]
  2. Change the product_obj read to a product_tmpl_obj read.  Would require getting a 'product.template' object.  
  158 inserted : product_tmpl_obj = self.pool.get('product.template')
  Line 247(248 after insert) product_default_uom = product_tmpl_obj.read(cr, uid, [tmpl_id], ['uom_id'])[0]['uom_id'][0]



Follow ups

References