[英]How can I override the create method of a record created from another model in Odoo?
Basically I have a model for hospital appointments, inside that model I have a many-to-one field to another model for patients.基本上我有一个 model 用于医院预约,在 model 里面我有一个多对一字段到另一个 model 用于患者。 What I want is to make that every time I use the "Create and Edit" option in my appointments model to create a record in the patient model this record gets automatically set with state equal to validated (contrary to draft, that is originally set as default), but when I create a patient record from the patient model it saves the record normally, with draft as default我想要的是,每次我在我的约会 model 中使用“创建和编辑”选项在患者 model 中创建记录时,此记录会自动设置为 Z9ED39E2EA931586B6A985A6942EF573默认),但是当我从患者 model 创建患者记录时,它会正常保存记录,默认为草稿
You can use context in xml with field definition for example:您可以在 xml 中使用上下文与字段定义,例如:
<field name="partner_id" widget="res_partner_many2one" context="{'search_default_supplier':1, 'default_supplier':1, 'default_customer':0, 'show_vat': True}" domain="[('supplier','=',True)]" placeholder="Name, TIN, Email, or Reference" />
Hope this'll help.希望这会有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.