Se rendre au contenu
Menu
Cette question a été signalée
1 Répondre
2210 Vues

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
Ignorer
Meilleure réponse

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
Ignorer
Auteur

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?

Publications associées Réponses Vues Activité
1
avr. 20
2816
1
nov. 24
1398
4
oct. 24
3634
0
oct. 22
5125
0
sept. 22
38