openerp-community-reviewer team mailing list archive
-
openerp-community-reviewer team
-
Mailing list archive
-
Message #07372
[Merge] lp:~initos.com/account-invoice-report/7.0-fix_lang_for_draft into lp:account-invoice-report
Katja Matthes has proposed merging lp:~initos.com/account-invoice-report/7.0-fix_lang_for_draft into lp:account-invoice-report.
Requested reviews:
Account Core Editors (account-core-editors)
For more details, see:
https://code.launchpad.net/~initos.com/account-invoice-report/7.0-fix_lang_for_draft/+merge/224109
Steps to reproduce:
1) In invoice tree view klick 'Create' to open draft formular for a new invoice
2) Choose for partner_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}
--
https://code.launchpad.net/~initos.com/account-invoice-report/7.0-fix_lang_for_draft/+merge/224109
Your team OpenERP Community Reviewer/Maintainer is subscribed to branch lp:account-invoice-report.
=== modified file 'invoice_webkit/invoice.py'
--- invoice_webkit/invoice.py 2013-02-01 08:46:04 +0000
+++ invoice_webkit/invoice.py 2014-06-23 11:29:29 +0000
@@ -18,6 +18,8 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
##############################################################################
from openerp.osv.orm import Model, fields
+from openerp.osv import osv
+from openerp.tools.translate import _
class InvoiceConditionText(Model):
@@ -38,22 +40,21 @@
_inherit = "account.invoice"
- def _set_condition(self, cr, uid, inv_id, commentid, key):
+ def _set_condition(self, cr, uid, inv_id, commentid, key, partner_id=False):
"""Set the text of the notes in invoices"""
if not commentid:
return {}
- try :
- lang = self.browse(cr, uid, inv_id)[0].partner_id.lang
- except :
- lang = 'en_US'
+ if not partner_id:
+ raise osv.except_osv(_('No Customer Defined !'), _('Before choosing condition text select a customer.'))
+ lang = self.pool.get('res.partner').browse(cr, uid, partner_id).lang or 'en_US'
cond = self.pool.get('account.condition_text').browse(cr, uid, commentid, {'lang': lang})
return {'value': {key: cond.text}}
- def set_header(self, cr, uid, inv_id, commentid):
- return self._set_condition(cr, uid, inv_id, commentid, 'note1')
+ def set_header(self, cursor, uid, inv_id, commentid, partner_id=False):
+ return self._set_condition(cursor, uid, inv_id, commentid, 'note1', partner_id)
- def set_footer(self, cr, uid, inv_id, commentid):
- return self._set_condition(cr, uid, inv_id, commentid, 'note2')
+ def set_footer(self, cursor, uid, inv_id, commentid, partner_id=False):
+ return self._set_condition(cursor, uid, inv_id, commentid, 'note2', partner_id)
_columns = {'text_condition1': fields.many2one('account.condition_text', 'Header condition',
domain=[('type', '=', 'header')]),
=== modified file 'invoice_webkit/view/invoice_view.xml'
--- invoice_webkit/view/invoice_view.xml 2013-03-04 06:52:00 +0000
+++ invoice_webkit/view/invoice_view.xml 2014-06-23 11:29:29 +0000
@@ -53,9 +53,9 @@
<page string="Conditions">
<group>
<field name="text_condition1" domain="[('type','=','header')]"
- on_change="set_header(text_condition1)" colspan="2"/>
+ on_change="set_header(text_condition1, partner_id)" colspan="2"/>
<field name="text_condition2" domain="[('type','=','footer')]"
- on_change="set_footer(text_condition2)" colspan="2"/>
+ on_change="set_footer(text_condition2, partner_id)" colspan="2"/>
<field name="note1" colspan="4" nolabel="1" placeholder="Your top conditions here"/>
<field name="note2" colspan="4" nolabel="1" placeholder="Your bottom conditions here"/>
</group>
Follow ups