Reference UoM for category should be checked for uniqueness
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Odoo Addons (MOVED TO GITHUB) |
Fix Released
|
Low
|
OpenERP R&D Addons Team 2 |
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_
Traceback (most recent call last):
File "/usr/local/
result = ExportService.
File "/usr/local/
res = fn(db, uid, *params)
File "/usr/local/
return f(self, dbname, *args, **kwargs)
File "/usr/local/
res = self.execute_cr(cr, uid, obj, method, *args, **kw)
File "/usr/local/
return getattr(object, method)(cr, uid, *args, **kw)
File "/usr/local/
return self._search(cr, user, args, offset=offset, limit=limit, order=order, context=context, count=count)
File "/usr/local/
cr.
File "/usr/local/
result = ExportService.
File "/usr/local/
res = fn(db, uid, *params)
File "/usr/local/
return f(self, dbname, *args, **kwargs)
File "/usr/local/
res = self.execute_cr(cr, uid, obj, method, *args, **kw)
File "/usr/local/
return getattr(object, method)(cr, uid, *args, **kw)
File "/usr/local/
return self._search(cr, user, args, offset=offset, limit=limit, order=order, context=context, count=count)
File "/usr/local/
cr.
File "/usr/local/
return f(self, *args, **kwargs)
File "/usr/local/
res = self._obj.
ProgrammingError: more than one row returned by a subquery used as an expression
File "/usr/local/
return f(self, *args, **kwargs)
File "/usr/local/
res = self._obj.
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.
Related branches
- Fabien (Open ERP): Disapprove
- Rucha (Open ERP) (community): Approve
- Atik Agewan(OpenERP) (community): Needs Resubmitting
- qdp (OpenERP): Pending requested
-
Diff: 37 lines (+2/-3)3 files modifiedproduct/product.py (+0/-1)
purchase/report/purchase_report.py (+1/-1)
sale/report/sale_report.py (+1/-1)
Indeed, the crash of reports due to multiple reference UoM for a category needs to be prevented or fixed.
I guess it is never really necessary to have multiple units in the same UoM category that have the same conversion rate, as that makes them equal to each other. We could add a unique constraint on (category_id, factor) so that only one UoM in each category is allowed to have the same conversion rate. This will also prevent having 2 reference UoMs with factor = 1.0.
I don't agree about the second part where you say that it should be forbidden to delete a reference UoM if there are other UoM. The reference UoM does not need to be explicitly defined, as per definition its factor is 1.0. If you have 2 UoM in the same category, let's say A (factor=0.5) and B (factor=0.1) you can easily convert from one to the other because you know their factor (against the implicit reference 1.0), without needing an explicit reference UoM. For example: 5.0 A = ((5.0/0.5)*0.1) B = 1.0 B
This is more convenient if the reference UoM should never be used directly.