← Back to team overview

c2c-oerpscenario team mailing list archive

[Bug 768430] Re: [6.0.2] Error when creating new product

 

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

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

Title:
  [6.0.2] Error when creating new product

Status in OpenERP Modules (addons):
  Fix Released

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

To manage notifications about this bug go to:
https://bugs.launchpad.net/openobject-addons/+bug/768430/+subscriptions


References