← Back to team overview

c2c-oerpscenario team mailing list archive

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

 

On 05/31/2011 02:12 PM, Eric Caudal - www.elico-corp.com wrote:
> One question is what if you delete the last UoM reference in one
> category? How is the system gonna behave? If it finds a UoM = 1000 x
> reference and there is no reference, what result should expect? 1?

It doesn't matter if you delete the last reference unit, because its
existence is implicit. It would be strange, but if you only have one
"Kg" UoM in a category, and this UoM is not a reference one (e.g it's
1000x bigger), everything will be expressed in terms of Kg.
So all stock moves should record quantities in terms of Kg, all
computations should be done in Kg, etc. The reference UoM does not
matter at all in that case.
It only starts to matter when you have more than one UoM, and you want
to be able to convert between them: in that case you start considering
their size as compared to that virtual "reference UoM".
But this reference is really virtual, it does not need to be defined
explicitly, and it can also be defined multiple times with synonym
names. If I say that Kg is 1000x bigger than my reference unit, I don't
need to define it explicitly, but I know that other UoMs will need to be
defined relatively to 1/1000 of a Kg.


On 05/31/2011 02:38 PM, Marco Dieckhoff wrote:
> I think the simpliest way would be to add reference as required
> many2one to the category, not as marker on the unit.

This would only help if we have multiple units with factor=1.0 in a
category, and if we want to be able to choose the main one, right?
I don't think there are many cases where we need to do that (the report
mentioned in the bug being one). Most of the time the reference unit is
used implicitly, and we probably don't need to make the model more
complicated than it is (the chicken and egg problem being one complication)
Would it really be an issue if we have multiple synonym UoMs in the same
category, all with factor = 1.0? This would not be a common case, but if
they have been defined that way, I guess they all represent the same
concept, and we can choose anyone in the report.

What do you think?

Isn't it more flexible if we are free to define UoMs as we want, as long
as we know they are all expressed relatively to a "virtual reference
UoM" with factor = 1.0. You can have 0, 1, or more "aliases" defined for
that virtual UoM, it doesn't matter.

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