← Back to team overview

c2c-oerpscenario team mailing list archive

[Bug 731035] Re: Reference UoM for category should be checked for uniqueness

 

I'm reopening this bug, in light of bug 734686 and on the comments on
the current bug.

I think Graeme has a point in comment #2: we may indeed need multiple
UoM with the same factor, even perhaps multiple ones with factor = 1.0,
i.e multiple reference units. And I don't think this would be an issue.

What is critical here is that we only allow a single "reference
quantity" in each category, which is the quantity that is equivalent to
1 x reference UoM. If you decide to have multiple UoM with factor = 1.0,
they effectively become synonyms for each other, which is fine. As
Graeme says, maybe you want to have 1 PCE = 1 UNIT = 1 ROLL, etc. It
doesn't matter because they all represent the same quantity and can be
compared correctly.

Eric, we do not need and do not want to explicitly specific the UoM that is used as reference for relative UoM, because the reference is always very clear: the quantity represented by factor or ratio = 1.0. So if a category only contains "Kg" of type "bigger than reference" and ratio = 1000, then it is implicit that this category has a reference unit (unnamed) that has ratio = 1.0, i.e 1/1000 of Kg. And if I define a second UoM named "mg" of type "smaller than reference" with ratio = 1000, then I am defining it relatively to that implicit reference UoM, 1 mg will in fact be equal to 1/1,000,000 of a Kg. I cannot define relative UoMs otherwise than that.
I think this gives me maximum flexibility (if I don't want "gram" to be used anywhere in the system, I don't need to define it) without the complexity of conversion tables, etc.
And if I want to define multiple UoMs with ratio = 1 in the same category, I don't think this is an issue, because by definition they are all exactly identical in term of relative quantities. This means that if you have 1 PCE = 1 ROLL, then you will have  BOX-OF-10-PCE = BOX-OF-10-ROLLS, by definition. If you don't want that, then you should put ROLL and PCE in different categories.

Now, in order to avoid confusion, and as bug 734686 mentions, we should
also enforce that UoM names are unique, but that is a separate bug.

My suggestion is therefore to revert the patch mentioned in comment #4, because it removes flexibility, and instead fix the report mentioned in the description, to make it more robust and support all the different cases: no explicit reference UoM, multiple reference UoM, all reference UoM inactive, etc.
A partial fix may have been provided in 6.0 with http://bazaar.launchpad.net/~openerp/openobject-addons/6.0/revision/4512.2.1

** Changed in: openobject-addons
       Status: Fix Released => Confirmed

-- 
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/731035

Title:
  Reference UoM for category should be checked for uniqueness

Status in OpenERP Modules (addons):
  Confirmed

Bug description:
  Currently any UoM can be set as a reference for a given category which
  seems to be wrong (meaning one category can have several UoM
  references). By conception it is dubious and actually it makes some
  reports crashes like account_invoice_report with the following error
  message:

  Traceback (most recent call last):
    File "/usr/local/lib/python2.6/dist-packages/openerp-server_9000/netsvc.py", line 489, in dispatch
      result = ExportService.getService(service_name).dispatch(method, auth, params)
    File "/usr/local/lib/python2.6/dist-packages/openerp-server_9000/service/web_services.py", line 599, in dispatch
      res = fn(db, uid, *params)
    File "/usr/local/lib/python2.6/dist-packages/openerp-server_9000/osv/osv.py", line 122, in wrapper
      return f(self, dbname, *args, **kwargs)
    File "/usr/local/lib/python2.6/dist-packages/openerp-server_9000/osv/osv.py", line 176, in execute
      res = self.execute_cr(cr, uid, obj, method, *args, **kw)
    File "/usr/local/lib/python2.6/dist-packages/openerp-server_9000/osv/osv.py", line 167, in execute_cr
      return getattr(object, method)(cr, uid, *args, **kw)
    File "/usr/local/lib/python2.6/dist-packages/openerp-server_9000/osv/orm.py", line 1735, in search
      return self._search(cr, user, args, offset=offset, limit=limit, order=order, context=context, count=count)
    File "/usr/local/lib/python2.6/dist-packages/openerp-server_9000/osv/orm.py", line 3981, in _search
      cr.execute('SELECT "%s".id FROM ' % self._table + from_clause + where_str + order_by + limit_str + offset_str, where_clause_params)Traceback (most recent call last):
    File "/usr/local/lib/python2.6/dist-packages/openerp-server_9000/netsvc.py", line 489, in dispatch
      result = ExportService.getService(service_name).dispatch(method, auth, params)
    File "/usr/local/lib/python2.6/dist-packages/openerp-server_9000/service/web_services.py", line 599, in dispatch
      res = fn(db, uid, *params)
    File "/usr/local/lib/python2.6/dist-packages/openerp-server_9000/osv/osv.py", line 122, in wrapper
      return f(self, dbname, *args, **kwargs)
    File "/usr/local/lib/python2.6/dist-packages/openerp-server_9000/osv/osv.py", line 176, in execute
      res = self.execute_cr(cr, uid, obj, method, *args, **kw)
    File "/usr/local/lib/python2.6/dist-packages/openerp-server_9000/osv/osv.py", line 167, in execute_cr
      return getattr(object, method)(cr, uid, *args, **kw)
    File "/usr/local/lib/python2.6/dist-packages/openerp-server_9000/osv/orm.py", line 1735, in search
      return self._search(cr, user, args, offset=offset, limit=limit, order=order, context=context, count=count)
    File "/usr/local/lib/python2.6/dist-packages/openerp-server_9000/osv/orm.py", line 3981, in _search
      cr.execute('SELECT "%s".id FROM ' % self._table + from_clause + where_str + order_by + limit_str + offset_str, where_clause_params)
    File "/usr/local/lib/python2.6/dist-packages/openerp-server_9000/sql_db.py", line 78, in wrapper
      return f(self, *args, **kwargs)
    File "/usr/local/lib/python2.6/dist-packages/openerp-server_9000/sql_db.py", line 131, in execute
      res = self._obj.execute(query, params)
  ProgrammingError: more than one row returned by a subquery used as an expression

  
    File "/usr/local/lib/python2.6/dist-packages/openerp-server_9000/sql_db.py", line 78, in wrapper
      return f(self, *args, **kwargs)
    File "/usr/local/lib/python2.6/dist-packages/openerp-server_9000/sql_db.py", line 131, in execute
      res = self._obj.execute(query, params)
  ProgrammingError: more than one row returned by a subquery used as an expression

  
  Uniqueness should be checked when the UoM is created/modified. Even more, you should not be able to delete the reference of a category if other UoM depend on it.


References