[FIX] product.copy(): do it in en_US:
authorVo Minh Thu <vmt@openerp.com>
Tue, 14 Feb 2012 14:34:20 +0000 (15:34 +0100)
committerVo Minh Thu <vmt@openerp.com>
Tue, 14 Feb 2012 14:34:20 +0000 (15:34 +0100)
when implementing our own copy() method, and thus part
of the copy_data() method, we should do it in a consistent
way: copy_data() copy the name in en_US, so we should do
it in en_US too. Otherwise we end up writing the name of
the new product with a user-translated name.

lp bug: https://launchpad.net/bugs/799655 fixed

bzr revid: vmt@openerp.com-20120214143420-7c16betfwlwblgjo

addons/product/product.py

index 38c4d82..0d5fa31 100644 (file)
@@ -661,11 +661,16 @@ class product_product(osv.osv):
         if context is None:
             context={}
 
-        product = self.read(cr, uid, id, ['name'], context=context)
         if not default:
             default = {}
+
+        # Craft our own `<name> (copy)` in en_US (self.copy_translation()
+        # will do the other languages).
+        context_wo_lang = context.copy()
+        context_wo_lang.pop('lang', None)
+        product = self.read(cr, uid, id, ['name'], context=context_wo_lang)
         default = default.copy()
-        default['name'] = product['name'] + _(' (copy)')
+        default['name'] = product['name'] + ' (copy)'
 
         if context.get('variant',False):
             fields = ['product_tmpl_id', 'active', 'variants', 'default_code',