跳至内容
菜单
此问题已终结
1 回复
2204 查看

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?

相关帖文 回复 查看 活动
1
4月 20
2808
1
11月 24
1377
4
10月 24
3610
0
10月 22
5124
0
9月 22
38