Я не могу найти ни одного примера того, как вызвать функцию связанной модели в представлении. Вот мой код:
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>
What I am trying to do here is executing a method inside the related model (destination) from a view of the main model (trip). Problem is my code executes the method inside the main model (trip) and not inside the related model (destination). I understand that it is possible to pass some Context to a button... but how to do it? I can't find any working example of it! Thanks to anyone who can help