odoo:每次刷新页面时执行python函数

时间:2015-06-11 16:00:29

标签: python odoo

我怎样才能执行一个python函数,每次刷新页面时都会从Odoo上的数据库中获取记录,我试过json / rpc,但文档不是那么清楚!请帮忙

这是我的功能:

def _id_facture(self):
    self.env.cr.execute("select max(id) from facturation_facturation")
    id_facture_tuple=self.env.cr.fetchone()
    self.id_facture = id_facture_tuple[0]+1

1 个答案:

答案 0 :(得分:0)

First, on which version of Odoo are you ? After, you want to execute your function when which page is refresh ?

Because, i think I've made something as you want to do.

def _id_facture(self):
    self.env.cr.execute("select max(id) from facturation_facturation")
    id_facture_tuple=self.env.cr.fetchone()
    self.id_facture = id_facture_tuple[0]+1

and, in your XML :

<record id="action_xxxxx" model="ir.actions.server">
    <field name="name">xxxxxx</field>
    <field name="type">ir.actions.server</field>
    <field name="model_id" ref="model_name_of your_model"/>
    <field name="code">action = env['your.table']._id_facture()</field>
</record>

I hope this will help you.