【问题标题】:OpenERP - button action is inserting/updating records in mrp_bom table but it should notOpenERP - 按钮操作正在插入/更新 mrp_bom 表中的记录,但它不应该
【发布时间】:2014-12-12 12:54:35
【问题描述】:

我在自定义的新视图中添加了“搜索”按钮。每当我单击“搜索”时,都会在 mrp_bom 表中插入或更新一条记录。我找不到原因。我希望这个按钮现在什么都不做。

这是py中的代码:

class mrp_bom(osv.Model):
    _inherit = 'mrp.bom'

    def action_search(self, cr, uid, ids, vals, context=None):
        ptemplid = self.browse(cr, uid, ids[0], context=context).product_tmpl_id
        print "\n\n Inside action_search() ptemplid ", ptemplid  

这里是xml:

  <record id="bom_where_use_form" model="ir.ui.view">
        <field name="name">bom.where.use.form</field>
        <field name="model">mrp.bom</field>
        <field name="priority" eval="20"/>
        <field name="type">form</field>
        <field name="arch" type="xml">
            <label for="product_tmpl_id" string="Product Name" />
            <field name="product_tmpl_id" on_change="onchange_product_tmpl_id(product_tmpl_id, 0, context)"/> 
            <button name="action_search" string="Search" type="object" class="oe_highlight"/>
        </field>         
    </record> 

【问题讨论】:

    标签: python xml openerp


    【解决方案1】:

    每当执行按钮操作时,它首先保存记录。因此,如果记录是新的,则将执行 create 方法,否则将为该记录执行 write 函数。然后只执行按钮操作。

    【讨论】:

      猜你喜欢
      • 2013-07-25
      • 2012-07-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多