Odoo用什么方法自动填充many2many relation table values on select button
Odoo what method is used automatically fill many2many relation table values on select button
我有2个类:
class my_request(models.Model):
_name = 'my.request'
_inherit = ['mail.thread', 'ir.needaction_mixin']
supply_ids = fields.Many2many(comodel_name='supply.conditions',
relation='purchase_supply_rel',
column1='purchase_requests_id', column2='supply_conditions_id',
string='Supply Conditions')
和
class SupplyConditions(models.Model):
_name = 'supply.conditions'
张xml:
<page string="Order">
<field name="supply_ids" domain="[('purchase_id', '=', id)]"/>
</page>
当我打开值列表时:
然后单击 Select 按钮,然后 保存按钮 更新关系 table:
purchase_requests_id 和 supply_conditions_id 值自动插入到 purchase_supply_rel table 中。
我的问题是 单击“保存”按钮 我需要做更多事情(调用用特定值填充其他 table 的函数)。据我了解,我需要知道这个 Save button click
使用的是什么方法,我需要扩展它是吗?
有人可以帮我吗?
取决于初始上下文。如果您正在创建 my.request
的新记录,它将调用 create()
ORM 方法。如果您正在更新记录,它将改为调用 write()
ORM 方法。所以你必须扩展两者。
我有2个类:
class my_request(models.Model):
_name = 'my.request'
_inherit = ['mail.thread', 'ir.needaction_mixin']
supply_ids = fields.Many2many(comodel_name='supply.conditions',
relation='purchase_supply_rel',
column1='purchase_requests_id', column2='supply_conditions_id',
string='Supply Conditions')
和
class SupplyConditions(models.Model):
_name = 'supply.conditions'
张xml:
<page string="Order">
<field name="supply_ids" domain="[('purchase_id', '=', id)]"/>
</page>
当我打开值列表时:
然后单击 Select 按钮,然后 保存按钮 更新关系 table: purchase_requests_id 和 supply_conditions_id 值自动插入到 purchase_supply_rel table 中。
我的问题是 单击“保存”按钮 我需要做更多事情(调用用特定值填充其他 table 的函数)。据我了解,我需要知道这个 Save button click
使用的是什么方法,我需要扩展它是吗?
有人可以帮我吗?
取决于初始上下文。如果您正在创建 my.request
的新记录,它将调用 create()
ORM 方法。如果您正在更新记录,它将改为调用 write()
ORM 方法。所以你必须扩展两者。