[6.0.2] Error when creating new product

Bug #768430 reported by Paulius Sladkevičius @ hbee
24
This bug affects 4 people
Affects Status Importance Assigned to Milestone
Odoo Addons (MOVED TO GITHUB)
Fix Released
Low
OpenERP R&D Addons Team 2

Bug Description

I deleted product category which was by default "All products" and now I can't create new product. Problem is - "/bin/addons/product/product.py", line 319, in _default_category" method.

Environment Information :
System : Linux-2.6.32-31-generic-i686-with-Ubuntu-10.04-lucid
OS Name : posix
Distributor ID: Ubuntu
Description: Ubuntu 10.04.2 LTS
Release: 10.04
Codename: lucid
Operating System Release : 2.6.32-31-generic
Operating System Version : #61-Ubuntu SMP Fri Apr 8 18:24:35 UTC 2011
Operating System Architecture : 32bit
Operating System Locale : lt_LT.UTF8
Python Version : 2.6.5
OpenERP-Client Version : 6.0.1
Last revision No. & ID :Bazaar Package not Found !Traceback (most recent call last):
  File "/home/komsas/openerp/server/bin/netsvc.py", line 489, in dispatch
    result = ExportService.getService(service_name).dispatch(method, auth, params)
  File "/home/komsas/openerp/server/bin/service/web_services.py", line 599, in dispatch
    res = fn(db, uid, *params)
  File "/home/komsas/openerp/server/bin/osv/osv.py", line 122, in wrapper
    return f(self, dbname, *args, **kwargs)
  File "/home/komsas/openerp/server/bin/osv/osv.py", line 176, in execute
    res = self.execute_cr(cr, uid, obj, method, *args, **kw)
  File "/home/komsas/openerp/server/bin/osv/osv.py", line 167, in execute_cr
    return getattr(object, method)(cr, uid, *args, **kw)
  File "/home/komsas/openerp/server/bin/osv/orm.py", line 975, in default_get
    context))
  File "/home/komsas/openerp/server/bin/osv/orm.py", line 981, in default_get
    defaults[f] = self._defaults[f](self, cr, uid, context)
  File "/home/komsas/openerp/server/bin/addons/product/product.py", line 319, in _default_category
    res = md.get_object_reference(cr, uid, 'product', 'cat0') or False
  File "/home/komsas/openerp/server/bin/tools/misc.py", line 823, in cached_result
    result2 = fn(self2, cr, *args[:self.skiparg-2], **kwargs2)
  File "/home/komsas/openerp/server/bin/addons/base/ir/ir_model.py", line 609, in get_object_reference
    data_id = self._get_id(cr, uid, module, xml_id)
  File "/home/komsas/openerp/server/bin/tools/misc.py", line 823, in cached_result
    result2 = fn(self2, cr, *args[:self.skiparg-2], **kwargs2)
  File "/home/komsas/openerp/server/bin/addons/base/ir/ir_model.py", line 602, in _get_id
    raise ValueError('No references to %s.%s' % (module, xml_id))
ValueError: No references to product.cat0

Related branches

Revision history for this message
Paulius Sladkevičius @ hbee (komsas) wrote :

After updating product module I get back this deleted category, but I don't think it is good to prevent user to delete category which can make an error like this.

Amit Parik (amit-parik)
Changed in openobject-addons:
assignee: nobody → OpenERP R&D Addons Team 2 (openerp-dev-addons2)
importance: Undecided → Low
status: New → Confirmed
Changed in openobject-addons:
status: Confirmed → In Progress
Revision history for this message
Rohan Nayani(Open ERP) (ron-tinyerp) wrote :

Hello,

Thanks for Reporting.
It has been fixed in lp:~openerp-dev/openobject-addons/trunk-bug-768430-ron
Revision ID: <email address hidden>
Revision num:4668.

It will be available in trunk soon,

Changed in openobject-addons:
status: In Progress → Fix Committed
qdp (OpenERP) (qdp)
Changed in openobject-addons:
status: Fix Committed → Fix Released
Revision history for this message
Leigh Willard (leigh) wrote :

Does this fix address the problem that I have?

OpenERP REQUIRES that there is a DEFAULT product category. I do NOT want a default product category, I want the field to remain empty (and blue, because it is required) to force my users to select their product category.

This is the only place that we have found where a default is required (the default is hard-coded to be the ALL PRODUCTS category), and this behavior is not consistent with the rest of OpenERP.

The fix requires a re-write of the following function. The code containing 'cat0' should not exist at all - it sets the default category to be (the reference to) cat0 if no default exists - it should return nothing if no default exists.

 _default_category(self, cr, uid, context=None):
        if context is None:
            context = {}
        if 'categ_id' in context and context['categ_id']:
            return context['categ_id']
        md = self.pool.get('ir.model.data')
        res = False
        try:
            res = md.get_object_reference(cr, uid, 'product', 'cat0')[1]
        except ValueError:
            res = False
        return res

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.