0
我找不到任何示例來說明如何在視圖中觸發相關模型的功能。 這裏是我的代碼:Odoo 10:按鈕觸發相關模型中的功能
class Trip(models.Model):
_name = 'trip'
_description = 'Trip'
destinations = fields.One2many('destination', 'trip_id', string='destinations')
class Destination(models.Model):
_name = 'destination'
_description = 'Trip'
trip_id = fields.Many2one('trip', 'Trip')
def generate_doc:
# code to generate report
基本上有2種型號(行程和目的地)與One2many關係。這是我的看法代碼:
<record model="ir.ui.view" id="trip_form">
<field name="name">trip.form</field>
<field name="model">trip</field>
<field name="arch" type="xml">
<field name="destinations" readonly="True">
<tree>
<button name="generate_doc" type="object" string="DOC"/>
</tree>
</field>
我想在這裏做的是執行與主型(旅)的視圖相關模型(目標)內的方法。問題是我的代碼在主模型(行程)內執行方法,而不是在相關模型(目的地)內執行。我明白,有可能將一些上下文傳遞給按鈕......但怎麼做呢?我找不到任何有效的例子! 謝謝任何人誰可以幫助