[Openerp-community] get partner language in Qweb reports

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

[Openerp-community] get partner language in Qweb reports

Mohamed M. Hagag

Dears,


I'm trying to get the partner language in the qweb reports like sales orders using this code:


<p t-field="o.partner_id.lang"></p> #this line prints Arabic

<div t-if="o.partner_id.lang == 'Arabic'"><p>Current language is Arabic</p></div> # this line never interpreted

 

Any solution ?



Regards,


_______________________________________________
Mailing list: https://launchpad.net/~openerp-community
Post to     : [hidden email]
Unsubscribe : https://launchpad.net/~openerp-community
More help   : https://help.launchpad.net/ListHelp
Reply | Threaded
Open this post in threaded view
|

Re: [Openerp-community] get partner language in Qweb reports

Antony Lesuisse (OpenERP)
The condition should be

o.partner_id.lang.code.startswith('ar')

On 11/18/2014 10:21 AM, Mohamed M. Hagag wrote:

> Dears,
>
>
> I'm trying to get the partner language in the qweb reports like sales orders
> using this code:
>
>
> <p t-field="o.partner_id.lang"></p> #this line prints Arabic
>
> <div t-if="o.partner_id.lang == 'Arabic'"><p>Current language is
> Arabic</p></div> # this line never interpreted
>
> Any solution ?
>
>
>
> Regards,
>
>
>
> _______________________________________________
> Mailing list: https://launchpad.net/~openerp-community
> Post to     : [hidden email]
> Unsubscribe : https://launchpad.net/~openerp-community
> More help   : https://help.launchpad.net/ListHelp
>

_______________________________________________
Mailing list: https://launchpad.net/~openerp-community
Post to     : [hidden email]
Unsubscribe : https://launchpad.net/~openerp-community
More help   : https://help.launchpad.net/ListHelp
Reply | Threaded
Open this post in threaded view
|

Re: [Openerp-community] get partner language in Qweb reports

Mohamed M. Hagag

Dear Antony,


Thank you for your fast response and kind help , but trying this code results in the below error:


Code:    <div t-if="o.partner_id.lang.code.startswith('ar')"><p>Current language is Arabic</p></div>


Error:

  File "/opt/odoo/openerp/addons/base/ir/ir_ui_view.py", line 1007, in render
    return self.pool[engine].render(cr, uid, id_or_xml_id, qcontext, loader=loader, context=context)
  File "/opt/odoo/openerp/api.py", line 237, in wrapper
    return old_api(self, *args, **kwargs)
  File "/opt/odoo/openerp/addons/base/ir/ir_qweb.py", line 253, in render
    return self.render_node(self.get_template(id_or_xml_id, qwebcontext), qwebcontext)
  File "/opt/odoo/openerp/addons/base/ir/ir_qweb.py", line 294, in render_node
    result = self.render_element(element, template_attributes, generated_attributes, qwebcontext)
  File "/opt/odoo/openerp/addons/base/ir/ir_qweb.py", line 315, in render_element
    g_inner.append(self.render_node(current_node, qwebcontext))
  File "/opt/odoo/openerp/addons/base/ir/ir_qweb.py", line 292, in render_node
    result = self._render_tag[t_render](self, element, template_attributes, generated_attributes, qwebcontext)
  File "/opt/odoo/openerp/addons/base/ir/ir_qweb.py", line 426, in render_tag_call
    d[0] = self.render_element(element, template_attributes, generated_attributes, d)
  File "/opt/odoo/openerp/addons/base/ir/ir_qweb.py", line 315, in render_element
    g_inner.append(self.render_node(current_node, qwebcontext))
  File "/opt/odoo/openerp/addons/base/ir/ir_qweb.py", line 294, in render_node
    result = self.render_element(element, template_attributes, generated_attributes, qwebcontext)
  File "/opt/odoo/openerp/addons/base/ir/ir_qweb.py", line 315, in render_element
    g_inner.append(self.render_node(current_node, qwebcontext))
  File "/opt/odoo/openerp/addons/base/ir/ir_qweb.py", line 292, in render_node
    result = self._render_tag[t_render](self, element, template_attributes, generated_attributes, qwebcontext)
  File "/opt/odoo/openerp/addons/base/ir/ir_qweb.py", line 420, in render_tag_if
    if self.eval_bool(template_attributes["if"], qwebcontext):
  File "/opt/odoo/openerp/addons/base/ir/ir_qweb.py", line 228, in eval_bool
    return int(bool(self.eval(expr, qwebcontext)))
  File "/opt/odoo/openerp/addons/base/ir/ir_qweb.py", line 197, in eval
    raise_qweb_exception(message="Could not evaluate expression %r" % expr, expression=expr, template=template)
  File "/opt/odoo/openerp/addons/base/ir/ir_qweb.py", line 194, in eval
    return qwebcontext.safe_eval(expr)
  File "/opt/odoo/openerp/addons/base/ir/ir_qweb.py", line 80, in safe_eval
    return eval(expr, None, locals_dict, nocopy=True, locals_builtins=True)
  File "/opt/odoo/openerp/tools/safe_eval.py", line 313, in safe_eval
    return eval(c, globals_dict, locals_dict)
  File "", line 1, in <module>
   
QWebException: ""'unicode' object has no attribute 'code'" while evaluating
"o.partner_id.lang.code.startswith('ar')"" while evaluating
"translate_doc(doc_id, doc_model, 'partner_id.lang', 'sale.report_saleorder_document')"

Am I putting the code in the wrong place or did a mistake ?


Also I found that the lang field under partner model is of type selection and not a m2o field to res.lang object - is it ok ?


Regards,


On 11/18/2014 01:55 PM, Antony Lesuisse wrote:
The condition should be

o.partner_id.lang.code.startswith('ar')

On 11/18/2014 10:21 AM, Mohamed M. Hagag wrote:
Dears,


I'm trying to get the partner language in the qweb reports like sales orders
using this code:


<p t-field="o.partner_id.lang"></p> #this line prints Arabic

<div t-if="o.partner_id.lang == 'Arabic'"><p>Current language is
Arabic</p></div> # this line never interpreted

Any solution ?



Regards,



_______________________________________________
Mailing list: https://launchpad.net/~openerp-community
Post to     : [hidden email]
Unsubscribe : https://launchpad.net/~openerp-community
More help   : https://help.launchpad.net/ListHelp


_______________________________________________
Mailing list: https://launchpad.net/~openerp-community
Post to     : [hidden email]
Unsubscribe : https://launchpad.net/~openerp-community
More help   : https://help.launchpad.net/ListHelp


_______________________________________________
Mailing list: https://launchpad.net/~openerp-community
Post to     : [hidden email]
Unsubscribe : https://launchpad.net/~openerp-community
More help   : https://help.launchpad.net/ListHelp
Reply | Threaded
Open this post in threaded view
|

Re: [Openerp-community] get partner language in Qweb reports

Holger Brunn
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

> Code:    <div
> t-if="o.partner_id.lang.code.startswith('ar')"><p>Current language
> is Arabic</p></div>

use o.partner_id.lang.startswith('ar')

- --
Therp - Maatwerk in open ontwikkeling

Holger Brunn - Ontwerp en implementatie

mail: [hidden email]
web: http://therp.nl
phone: +31 (0)20 3093096
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1

iF4EAREIAAYFAlRrN78ACgkQAcl2D+yjrhgCeQD9GNLyUHRMIT3/RYXtYJop9b0x
/Z1zTFOm5Y5+4cPQ9WEBAKNiH0OmGMO+X3XEWkzMnnJYwhChHMRu1/6BHEQh4JFL
=mBMh
-----END PGP SIGNATURE-----

_______________________________________________
Mailing list: https://launchpad.net/~openerp-community
Post to     : [hidden email]
Unsubscribe : https://launchpad.net/~openerp-community
More help   : https://help.launchpad.net/ListHelp
Reply | Threaded
Open this post in threaded view
|

Re: [Openerp-community] get partner language in Qweb reports

Mohamed M. Hagag
Dear Holger,

Thanks for your reply - it's not showing error now - but it still doesn't print the code result
<p>Current language is Arabic</p>
Any idea ?

Regards,


On 11/18/2014 02:12 PM, Holger Brunn wrote:
<div
> t-if="o.partner_id.lang.code.startswith('ar')"><p>Current language
> is Arabic</p></div>


_______________________________________________
Mailing list: https://launchpad.net/~openerp-community
Post to     : [hidden email]
Unsubscribe : https://launchpad.net/~openerp-community
More help   : https://help.launchpad.net/ListHelp