Skip to Content
Menu
This question has been flagged
1 Reply
1374 Views

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?

Avatar
Discard
Best Answer

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

Avatar
Discard
Author

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 Replies Views Activity
1
Apr 20
1862
1
Nov 24
107
4
Oct 24
1432
0
Oct 22
4147
0
Sep 22
38