操作无法完成: - 创建/更新:未设置必填字段奥多14

问题描述

如果某些条件,我需要在“pos.order.line”中创建新记录;在“onchange”函数中。

这是我的代码,我收到此错误

The operation cannot be completed: - Create/update: a mandatory field is not set. - Delete: another model requires the record being deleted. If possible,archive it instead.  Model: Point of Sale Order Lines (pos.order.line),Field: Order Ref (order_id) .

如果我还没有保存它,如何获得order_id?

class PosOrder(models.Model):

    _inherit = "pos.order.line"

    @api.onchange('product_id')

    def onchange_product(self):

        if condition:

            new_pos_order_line = self.create({

                'product_id': ....,'price_unit': ....,'qty':1,})

请问有什么帮助吗? 谢谢。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)