简体   繁体   English

如何覆盖从 Odoo 中的另一个 model 创建的记录的 create 方法?

[英]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.

相关问题 创建帐户时为另一个模型创建记录? - Create record for another model when account is created? 如何使用变量的 ID 创建记录? - How can I create a record with an ID from a variable? 如何在存储过程中创建记录和该记录的表? - How Can I Create Record and Table of That Record Within a Stored Procedure? 我创建了 oneToMany 关系,但我如何获得单条记录属于 Sequalize 中的多条记录 - I created oneToMany relation but how I can get the single record belongs to the many record in Sequalize Odoo使用self.env从另一个模型获取数据 - Odoo get data from another model with self.env 如何在同一个表中将一条记录与另一条记录关联起来? - How can I associate one record with another in the same table? asp.net如何使用此方法删除当前记录? - asp.net how can i delete the current record with this method? 我可以从纯sql CREATE创建SQLALCHEMY模型吗? - Can I create a SQLALCHEMY model from the pure sql CREATE? 如何检索和使用在RSpec / Capybara测试中创建的记录的ID? - How can I retrieve and use the ID of a record I've created inside an RSpec/Capybara test? 从另一个表中为每条记录创建一条记录并将id设置为该字段 - Create a record for each record from another table and set the id to the field
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM