[IMP] product: simplify further product_product.copy()
bzr revid: rco@openerp.com-20140127101957-1ywu40m081uo79nl
This commit is contained in:
parent
31d4a2cc6f
commit
17616e08ef
|
@ -833,28 +833,19 @@ class product_product(osv.osv):
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def copy(self, cr, uid, id, default=None, context=None):
|
def copy(self, cr, uid, id, default=None, context=None):
|
||||||
if context is None:
|
context = context or {}
|
||||||
context = {}
|
default = dict(default or {})
|
||||||
|
|
||||||
if not default:
|
|
||||||
default = {}
|
|
||||||
|
|
||||||
# Craft our own `<name> (copy)` in en_US (self.copy_translation()
|
# Craft our own `<name> (copy)` in en_US (self.copy_translation()
|
||||||
# will do the other languages).
|
# will do the other languages).
|
||||||
context_wo_lang = dict(context)
|
context_wo_lang = dict(context or {})
|
||||||
context_wo_lang.pop('lang', None)
|
context_wo_lang.pop('lang', None)
|
||||||
product = self.read(cr, uid, id, ['name', 'variants', 'product_tmpl_id'], context=context_wo_lang)
|
product = self.browse(cr, uid, id, context_wo_lang)
|
||||||
default = dict(default)
|
if context.get('variant'):
|
||||||
if product['variants'] or context.get('variant'):
|
|
||||||
# if we copy a variant or create one, we keep the same template
|
# if we copy a variant or create one, we keep the same template
|
||||||
name = default.pop('name', None)
|
default['product_tmpl_id'] = product.product_tmpl_id.id
|
||||||
variant = product['variants'] or name or product['name']
|
|
||||||
default.update({
|
|
||||||
'variants': _("%s (copy)") % (variant,),
|
|
||||||
'product_tmpl_id': product['product_tmpl_id'][0],
|
|
||||||
})
|
|
||||||
elif 'name' not in default:
|
elif 'name' not in default:
|
||||||
default['name'] = _("%s (copy)") % (product['name'],)
|
default['name'] = _("%s (copy)") % (product.name,)
|
||||||
|
|
||||||
return super(product_product, self).copy(cr, uid, id, default=default, context=context)
|
return super(product_product, self).copy(cr, uid, id, default=default, context=context)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue