0
我有一個模型:UI爭創建
class MyModel:
name = ...
field1 = fields.Many2one(comodel_name='sale.order')
@staticmethod
def _do_some(env, inst):
...
env['stock.picking'].create(vals={
'move_type': 'direct',
'company_id': delivery_order.company_id.id,
'picking_type_id': pick_type_id
}) # UI Scrambles when this happens
...
@onchange('field1')
def field1_changed(self):
# self.id is a NewId ... which makes no sense
# this_inst is a replacement for self (because of NewId)
this_inst = ... I search this instance by name
MyModel._do_some(self.env, this_inst)
我有了一個下拉字段爲MyModel.field1
,當我改變自然要求MyModel.field1_changed
視圖,進而調用MyModel._do_some
。
create
後正在呼籲stock.picking
模型,我的UI擾碼,以及我的意思是,該MyModel
實例的所有字段值從視圖中刪除,也似乎驗證阻止我拯救,因爲「缺少必填字段」。