Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion pos_container_deposit/static/src/js/models.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,14 @@ odoo.define("pos_container_deposit.models", function (require) {
* When adding a product with container deposit, add its container deposit product
**/
super.add_orderline(...arguments);
if (line.container_deposit_product && !line.container_deposit_line) {
// Get unpayed orders from pos.orders wich comes from pos.db.orders
const all_unpaid = this.pos.get_order_list().map((x) => x.cid);
const is_unpaid = all_unpaid.includes(line.order.cid);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like it is a good criterium, I tested on Runboat and it seems like this is indeed a measure of which orders are open in the current session and not paid yet.

if (
line.container_deposit_product &&
!line.container_deposit_line &&
is_unpaid
) {
this.add_product(line.container_deposit_product, {
quantity: line.get_quantity(),
});
Expand Down