Debasish
Debasish

Reputation: 322

how to call the python method inside xml template using odoo 9 module

i have a piece of code having variable in .py file but i don't know how to call the varibale inside xml template

.xml file

 <?xml version="1.0" encoding="utf-8"?>
 <openerp>
  <data>
  <template id="menu_secondary" name="group_js menu" inherit_id="web.menu_secondary">
    <xpath expr="." position="inside">
      <span t-field="o.test"></span>
   </xpath>
  </template>
  </data>
  </openerp>

.py file

 from openerp.osv import fields,osv,  expression

 class group_js(osv.osv):
_name = "group_js"
_description = "Group JS"

def test(self):
   temp_var = "HELLO"
   return temp_var

so , any one have any idea please share with me

Thanks

Upvotes: 0

Views: 3106

Answers (1)

Sebin
Sebin

Reputation: 31

If it is in the same model then you can replace your template using the following code.

  <template id="menu_secondary" name="group_js menu" inherit_id="web.menu_secondary">
    <xpath expr="." position="inside">
      <span t-esc="o.test()" />
    </xpath>
  </template>

Try it, and it may be work for you.

Upvotes: 1

Related Questions