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

I'm trying to add an unique numbering in Odoo's POS order without depending in the backend. I want this number to add 1 only when the order is confirmed. I inherited the PaymentScreenWidget's validate_order button and tried to add the export to JSON function as appreciated in the following code:

```

screens.PaymentScreenWidget.include({

        validate_order: function (force_validation) {

            let order = this.pos.get_order();

            let next_number = order.next_number

            next_number += 1

            export_as_JSON: function f() {

                var json = _super_order_model.export_as_JSON(this, arguments);

                json.next_number = next_number

            }

            console.log('number is ' + next_number);

            this._super(force_validation)

        }

    })

```

But I get errors, Is this the correct way to do this? how should I call the export to JSON function with the validate_order button?

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

you have to override  export_as_JSON  of `Order`model

export_as_JSON: function f() {

                var json = _super_order_model.export_as_JSON(this, arguments);

                json.next_number = next_number

   }
Above part should be move to Order model

อวตาร
ละทิ้ง
ผู้เขียน

I have changed the code like you adviced but the numbering is restarting to 1 every time I refresh the POS session. Is there something else that I have to do so the numbering doesn't restart?

Related Posts ตอบกลับ มุมมอง กิจกรรม
1
เม.ย. 20
2830
1
พ.ย. 24
1428
4
ต.ค. 24
3674
0
ต.ค. 22
5132
0
ก.ย. 22
38