Comment 1 for bug 942699

Revision history for this message
Graeme Gellatly (gdgellatly) wrote : Re: [Bug 942699] [NEW] Unable to set a new default name for product.product via copy() call

What about using copy_data?

On Wed, Feb 29, 2012 at 4:59 AM, Niels Huylebroeck <
<email address hidden>> wrote:

> Public bug reported:
>
> 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
>
> ** Affects: openobject-addons
> Importance: Undecided
> Status: New
>
> --
> You received this bug notification because you are 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):
> New
>
> 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
>