删除订单行按钮

时间:2018-06-08 06:58:33

标签: odoo-8 odoo

我尝试删除名称为"服务"用这种方法,但没有运气。

    @api.multi
    def remove_line(self):
         for line in self.order_line:
            if line.name == 'Services':
                self.order_line.write({
                       'line': [(3, self.product_id.id)]
                    })

2 个答案:

答案 0 :(得分:3)

试试这个

@api.multi
def remove_line(self):
    for rec in self:
        for line in rec.order_line:
            if line.name == 'Services':
                line.unlink()

答案 1 :(得分:1)

如果你想使用cammand这样做,就这样做:

      # update the record it self
      self.write({
                   # update the one2many field and remove the current line in for loop
                   'order_line': [(3, line.id)]
                })

只有one2many或many2many接受cammand线