微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

如何解决操作无法完成: - 创建/更新:未设置必填字段奥多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 举报,一经查实,本站将立刻删除。