odoo/odoo#158516
Created by Ali Hassan Youssef (alhy)
- label
- odoo-dev:saas-17.1-opw-3796605-don't_clear_order_after_printing_bill-alhy
- head
- e1787261183675507b7e28da10552109b60e0b19
- target
- saas-17.1
- merged
- 2 months ago by POS IoT, Joseph Caburnay (jcb)
- forward-ports
- odoo/odoo#159530 targeting master
- odoo/odoo#159503 targeting saas-17.2
[FIX] pos_restaurant: don't clear order after printing bill
### Steps to reproduce:
- Install **Restaurant** app.
- Go to **Point of Sale** app and open a new **Restaurant** session.
- Add items to the order.
- Click on the **Bill** button, the receipt window appears.
- Click on the **Print** button, the print window appears. Cancel it - U don't have to print it or save it-.
- Close the receipt window.
- Add another item to the order, the older items are removed -the order is cleared-.
### Investigation:
- When the **Print** button is clicked in the Bill Screen, `print()` method is triggered https://github.com/odoo/odoo/blob/c3fe6dfd3c56ae8058d0eb688680bdc627ee611a/addons/pos_restaurant/static/src/app/bill_screen/bill_screen.js#L16-L19
- which do two actions simultaneously:
- calls the `printReceipt()` method https://github.com/odoo/odoo/blob/c3fe6dfd3c56ae8058d0eb688680bdc627ee611a/addons/pos_restaurant/static/src/app/bill_screen/bill_screen.js#L17
- set the order.`_printed` to `false` https://github.com/odoo/odoo/blob/c3fe6dfd3c56ae8058d0eb688680bdc627ee611a/addons/pos_restaurant/static/src/app/bill_screen/bill_screen.js#L18 _NOW order.`_printed` IS FALSE._
- Inside the `printReceipt()` method, we reach this line https://github.com/odoo/odoo/blob/c3fe6dfd3c56ae8058d0eb688680bdc627ee611a/addons/point_of_sale/static/src/app/store/pos_store.js#L1793 which set the order.`_printed` to True. _NOW order.`_printed` IS TRUE_.
- When a new product is added to the order, this if clause https://github.com/odoo/odoo/blob/c3fe6dfd3c56ae8058d0eb688680bdc627ee611a/addons/point_of_sale/static/src/app/store/models.js#L1871-L1875 is activated given that the order.`_printed` is true although it should have been `false`!
opw-3796605