Python OpenERP V7-如何在widget=";one2many“列表”;

Python OpenERP V7-如何在widget=";one2many“列表”;,python,openerp,openerp-7,openerp-8,Python,Openerp,Openerp 7,Openerp 8,我正在OpenERPv7中编写一个自定义实验室测试模块。这个粗略的想法在文章中有描述 如何实现步骤2,即one2many_列表字段的任何字段中的任何更改都将触发一个函数,以清除父字段“更改原因”(ROC)字段中的文本 以下是我的例子: 'note_change':fields.text('更改原因',required=True), 'lab_line':fields.one2many('test.lab','lab_id','lab line'), “实验室id”:fields.manyOne(

我正在OpenERPv7中编写一个自定义实验室测试模块。这个粗略的想法在文章中有描述

如何实现步骤2,即one2many_列表字段的任何字段中的任何更改都将触发一个函数,以清除父字段“更改原因”(ROC)字段中的文本

以下是我的例子:

'note_change':fields.text('更改原因',required=True),
'lab_line':fields.one2many('test.lab','lab_id','lab line'),
“实验室id”:fields.manyOne('test.lab','Parent lab',ondelete='cascade',select=True),
“产品名称”:fields.char('product name',size=64),
'product_id':fields.manyOne('product.product','product'),
py中的相关功能为:

def onchange_product_id(self、cr、uid、id、product_id、name、context=None):
b_标志=False
如果产品标识为:
prod=self.pool.get('product.product').browse(cr、uid、product\u id、context=context)
res_id=context.get('test',False)
如果资源id:
"""
@触发函数将更改原因设置为空
"""
b_标志=真
self.fnct\u触发器\u onchange(cr、uid、res\u id、b\u标志、上下文)
其他:
#这里还有其他代码
警告={'title':'warning!',
“消息”:“请输入更改原因。”,
}
返回{'value':{'product_name':prod.name,'product_uom':prod.uom_id.id,'product_std_cost':prod.standard_price},
“警告”:警告,
}
返回{}
我的写入对象函数如下:

def-fnct\u-trigger\u-onchange(self、cr、uid、ids、b\u标志,context=None):
"""
@如果b_flags为true,则表示触发了此对象中的onchange函数
@如果b_flags为false,则表示未触发此对象中的onchange函数
"""
res={}
"""
@如果b_标志为真,则将便笺更改字段重置为空
"""
如果b_标志:
lab_obj=self.pool.get('test.lab')
strResetEmpty=“”
如果不存在(ID,列表):
ids=[ids]
res\u vals={'note\u change':strResetEmpty
}
实验室对象写入(cr、uid、ID、res\u vals、context=context)
返回res
我的XML在这里:

    <?xml version="1.0" encoding="utf-8"?>
   <form string="lab_form_view" version="7.0">    
   <notebook>
   <page string="Lab Products">
          <field name="lab_lines" widget="one2many_list" context="{'test':active_id}" >
             <tree string="Components" editable="bottom">                                            
                    <field name="product_id" required="1" context="{'default_supply_method':'produce'}" on_change="onchange_product_id(product_id, product_name, context)" />
                    <field name="product_name" invisible="1"/>                                    
              </tree>
          </field>                                                  
     </page>
     </notebook>

     <group colspan="4" string= "Remark Notes">
               <field name="note_change" />                   
     </group>
     </form> 

通过此操作,当在one2many列表中选择新产品时,我可以触发fnct_trigger_onchange中的write object函数,以清除ROC字段中的明文内容。然而,这还不是我想要的,我当前代码的问题是文本(在ROC字段中)在后台被清除,但在用户视图中不存在/反映。用户仍然看到旧文本,即使它实际上已被清除

我希望实现当用户选择产品时,ROC字段将立即为空的on_change方法。我该怎么做?有人能帮我吗?谢谢