Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
11513 มุมมอง

Hi, 

I need to create new record in 'pos.order.line' if some conditions; in 'onchange' function.

Here is my code , I got this error : 

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) .

How can get the order_id if I don't save it yet ?


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,

              

            })

Any help please?
Thanks.
อวตาร
ละทิ้ง
ผู้เขียน

@Niyas Raphy, In my case how to set order_id : ... in the dict from pos.order.line , and the record is not created yet.

After saving , the id will be generated , but I need to get it into onchange function.

Related Posts ตอบกลับ มุมมอง กิจกรรม
0
ม.ค. 25
1302
1
มี.ค. 25
652
1
ก.ย. 23
2507
Favorite filter Odoo 10 แก้ไขแล้ว
2
ส.ค. 22
7695
[Odoo 8]How to use ref on domain xml แก้ไขแล้ว
8
มิ.ย. 20
21725