← Back to team overview

openerp-india team mailing list archive

[Bug 942699] Re: Unable to set a new default name for product.product via copy() call

 

I created a wizard which creates a product by searching for a correct
template then copying that and altering certain aspects while copying.

This might not be a use that was thought of when it was coded, but like
I showed you this fix would never change the original behavior and is a
nice improvement for future developers to use copy() with a proper
defaults dictionary instead of having to do a write afterwards.

It also makes the copy() method more predictable whereas now *only* for
product.product model you cannot pass a default['name'] = "My desired
new name" which is what anyone who is learning the copy() method will
expect.

Or as PEP20 states it: Special cases aren't special enough to break the
rules.

-- 
You received this bug notification because you are a member of OpenERP
Indian Team, which is subscribed to OpenERP Addons.
https://bugs.launchpad.net/bugs/942699

Title:
  Unable to set a new default name for product.product via copy() call

Status in OpenERP Addons (modules):
  Incomplete

Bug description:
  Due to how  the code is written in product.product method copy[1] we
  cannot call copy method with default['name'] = 'My New product name'
  because the value in default['name'] is unconditionally overwritten
  with the product name + '(copy)'.

  A workaround is to do copy() and then a write to update the name to
  the calculated name.

  However I would find it a lot more logical if you would just do a
  simple test like:

  if 'name' not in default or default['name'] == product['name']:
      default['name'] = product['name'] + _(' (copy)')

  Which would then enable people to properly copy products and replace the name at the same time.
  I checked also the trunk version (r6646) and it seems the same issue is still there[2] as well as on the 6.1 r6637 [3]

  [1] http://bazaar.launchpad.net/~openerp/openobject-addons/6.0/view/head:/product/product.py#L617
  [2] http://bazaar.launchpad.net/~openerp/openobject-addons/trunk/view/head:/product/product.py#L660
  [3] http://bazaar.launchpad.net/~openerp/openobject-addons/6.1/view/head:/product/product.py#L673

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


References