odoo/odoo#159530

Created by fw-bot
label
odoo-dev:master-saas-17.1-opw-3796605-don't_clear_order_after_printing_bill-alhy-tt4R-fw
head
566dd5375b419bf59d3198c52db4ff235afd9479
target
master
merged
1 month ago by Ali Hassan Youssef (alhy)
forward-port of
odoo/odoo#158516 DETACHED (Head updated from ea7fff7e4285b0e6af3ed23de7cc58e9a9e0356b to 2b278d5eed0cdb62c3ddbd1f59d2b2776a5f189b)

[FW][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

Forward-Port-Of: odoo/odoo#158516