Merge lp:~openerp-dev/openobject-addons/7.0-opw-607044-rgo into lp:openobject-addons/7.0

Proposed by Ravi Gohil (OpenERP)
Status: Rejected
Rejected by: Martin Trigaux (OpenERP)
Proposed branch: lp:~openerp-dev/openobject-addons/7.0-opw-607044-rgo
Merge into: lp:openobject-addons/7.0
Diff against target: 44 lines (+18/-2)
1 file modified
product/product.py (+18/-2)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/7.0-opw-607044-rgo
Reviewer Review Type Date Requested Status
Martin Trigaux (OpenERP) Pending
Review via email: mp+218376@code.launchpad.net

Description of the change

Steps to reproduce the issue:
1. Create a db and load the "French(BE)" lang for the admin user
2. Open the product "[CARD] Carte graphique" in form view
3. duplicate the product "Carte graphique"

Issue1: you will have "Graphics Card (copie)" as the name for duplicated product instead of "Carte graphique (copie)"

4. change the name of the duplicated product in step "3" to eg. "Graphics Card2" and save
5. duplicate the product created in step "4"

Issue2: the new suggested name for product created in step "5" will be the same like on the first duplicate("Graphics Card (copie)") instead of "Graphics Card2 (copie)"

This is because the wrong values are set for product_template's name field in the ir.translation table when duplicating the product.

I have fixed this issue by managing this case for product object by overriding the copy_translations(...), kindly review the fix and share your views on it.

Thanks.

To post a comment you must log in.
Revision history for this message
Martin Trigaux (OpenERP) (mat-openerp) wrote :

Hello,

The expected behaviour is the following

If my user is in english when duplicating
[en] Graphic Card -> Graphic Card (copy)
[fr] Carte Graphique -> Carte Graphique
We keep the same translation in french as we want to avoid people with lots of translation to manually reenter the translation

If my user is in french when duplicating
[fr] Carte Graphique -> Carte Graphique (copie)
[en] Graphic Card -> Graphic Card

There was indeed an issue in case of product which had a different behaviour. It is now fixed in 7.0 at revision 10041.
I reject this one them.

Unmerged revisions

10035. By Ravi Gohil (OpenERP)

[FIX] product: Duplicating product in other than en_US lang sets wrong translation for product template name, courtesy: Jay Vora (Serpent Consulting Services), referenced lp bug# 734191. (Maintenance Case: 607044)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'product/product.py'
2--- product/product.py 2014-04-25 12:55:07 +0000
3+++ product/product.py 2014-05-06 10:15:13 +0000
4@@ -721,6 +721,22 @@
5
6 return res
7
8+ def copy_translations(self, cr, uid, old_id, new_id, context=None):
9+ if context is None:
10+ context = {}
11+ super(product_product, self).copy_translations(cr, uid, old_id, new_id, context=context)
12+ trans_obj = self.pool.get('ir.translation')
13+ template_id = self.browse(cr, uid, new_id, context=context).product_tmpl_id.id
14+ trans_ids = trans_obj.search(cr, uid, [('res_id','=',template_id), ('name','=','product.template,name')])
15+ trans_records = trans_obj.read(cr, uid, trans_ids, ['src','value','lang'])
16+ for trans_rec in trans_records:
17+ context['lang'] = trans_rec['lang']
18+ trans_rec['src'] += ' (copy)'
19+ trans_rec['value'] += _(' (copy)')
20+ tr_id = trans_rec['id']
21+ del trans_rec['id']
22+ trans_obj.write(cr, uid, [tr_id], trans_rec)
23+
24 def copy(self, cr, uid, id, default=None, context=None):
25 if context is None:
26 context={}
27@@ -734,7 +750,7 @@
28 context_wo_lang.pop('lang', None)
29 product = self.read(cr, uid, id, ['name'], context=context_wo_lang)
30 default = default.copy()
31- default.update(name=_("%s (copy)") % (product['name']))
32+ default.update(name=("%s (copy)") % (product['name']))
33
34 if context.get('variant',False):
35 fields = ['product_tmpl_id', 'active', 'variants', 'default_code',
36@@ -749,7 +765,7 @@
37 return self.create(cr, uid, data)
38 else:
39 return super(product_product, self).copy(cr, uid, id, default=default,
40- context=context)
41+ context=context_wo_lang)
42
43 def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False):
44 if context is None: