Merge lp:~initos.com/sale-reports/7.0-fix_lang_for_draft into lp:~sale-core-editors/sale-reports/7.0

Proposed by Katja Matthes
Status: Merged
Approved by: Yannick Vaucher @ Camptocamp
Approved revision: 28
Merged at revision: 29
Proposed branch: lp:~initos.com/sale-reports/7.0-fix_lang_for_draft
Merge into: lp:~sale-core-editors/sale-reports/7.0
Diff against target: 62 lines (+12/-12)
2 files modified
sale_order_webkit/sale.py (+10/-10)
sale_order_webkit/view/sale_view.xml (+2/-2)
To merge this branch: bzr merge lp:~initos.com/sale-reports/7.0-fix_lang_for_draft
Reviewer Review Type Date Requested Status
Yannick Vaucher @ Camptocamp code review, no test Approve
Markus Schneider (community) review & testing Approve
Pedro Manuel Baeza code review Needs Fixing
Review via email: mp+224106@code.launchpad.net

Description of the change

Steps to reproduce:
1) In sale order tree view klick 'Create' to open draft formular for a new sale order
2) Choose for patner_id a partner with an other language than English
3) Set text_condition{1,2}

Result
English version of condition text is set to note{1,2}.

Expected Result:
Use language of set partner while setting note{1,2}.

Solution:
Add partner_id as parameter to on_change function for text_condition{1,2}

To post a comment you must log in.
Revision history for this message
Pedro Manuel Baeza (pedro.baeza) wrote :

This is the same as the other MP you have made (https://code.launchpad.net/~initos.com/account-invoice-report/7.0-fix_lang_for_draft/+merge/224109), so please change it in the same way.

Regards.

review: Needs Fixing (code review)
Revision history for this message
Markus Schneider (markus-schneider) wrote :

solve the problem with multi language installation

review: Approve (review & testing)
Revision history for this message
Yannick Vaucher @ Camptocamp (yvaucher-c2c) wrote :
review: Approve (code review, no test)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'sale_order_webkit/sale.py'
2--- sale_order_webkit/sale.py 2013-03-14 14:14:24 +0000
3+++ sale_order_webkit/sale.py 2014-06-23 11:09:44 +0000
4@@ -18,8 +18,9 @@
5 # along with this program. If not, see <http://www.gnu.org/licenses/>.
6 #
7 ##############################################################################
8-from openerp.osv import orm, fields
9+from openerp.osv import orm, fields, osv
10 from openerp import netsvc
11+from openerp.tools.translate import _
12
13
14 class SaleConditionText(orm.Model):
15@@ -48,23 +49,22 @@
16 'note1': fields.html('Header'),
17 'note2': fields.html('Footer')}
18
19- def _set_condition(self, cursor, uid, inv_id, commentid, key):
20+ def _set_condition(self, cursor, uid, inv_id, commentid, key, partner_id=False):
21 """Set the text of the notes in invoices"""
22 if not commentid:
23 return {}
24- try:
25- lang = self.browse(cursor, uid, inv_id)[0].partner_id.lang
26- except Exception as exc:
27- lang = 'en_US'
28+ if not partner_id:
29+ raise osv.except_osv(_('No Customer Defined !'), _('Before choosing condition text select a customer.'))
30+ lang = self.pool.get('res.partner').browse(cursor, uid, partner_id).lang or 'en_US'
31 cond = self.pool.get('sale.condition_text').browse(cursor, uid,
32 commentid, {'lang': lang})
33 return {'value': {key: cond.text}}
34
35- def set_header(self, cursor, uid, inv_id, commentid):
36- return self._set_condition(cursor, uid, inv_id, commentid, 'note1')
37+ def set_header(self, cursor, uid, inv_id, commentid, partner_id=False):
38+ return self._set_condition(cursor, uid, inv_id, commentid, 'note1', partner_id)
39
40- def set_footer(self, cursor, uid, inv_id, commentid):
41- return self._set_condition(cursor, uid, inv_id, commentid, 'note2')
42+ def set_footer(self, cursor, uid, inv_id, commentid, partner_id=False):
43+ return self._set_condition(cursor, uid, inv_id, commentid, 'note2', partner_id)
44
45 def print_quotation(self, cursor, uid, ids, context=None):
46 '''
47
48=== modified file 'sale_order_webkit/view/sale_view.xml'
49--- sale_order_webkit/view/sale_view.xml 2013-03-12 12:33:46 +0000
50+++ sale_order_webkit/view/sale_view.xml 2014-06-23 11:09:44 +0000
51@@ -68,9 +68,9 @@
52 <page string="Conditions">
53 <group>
54 <field name="text_condition1" domain="[('type','=','header')]"
55- on_change="set_header(text_condition1)" colspan="2"/>
56+ on_change="set_header(text_condition1, partner_id)" colspan="2"/>
57 <field name="text_condition2" domain="[('type','=','footer')]"
58- on_change="set_footer(text_condition2)" colspan="2"/>
59+ on_change="set_footer(text_condition2, partner_id)" colspan="2"/>
60 <field name="note1" colspan="4" nolabel="1" placeholder="Your top conditions here"/>
61 <field name="note2" colspan="4" nolabel="1" placeholder="Your bottom conditions here"/>
62 </group>

Subscribers

People subscribed via source and target branches