Skip to content
Open
Changes from 1 commit
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 orders from db.pos

Choose a reason for hiding this comment

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

If anything this would be pos.db, but get_order_list does not get from pos.db (=localStorage), but directly from this.orders, which as far as I can see is just a list of all orders that have been touched since this particular browser tab was opened. So the claim that this comment does is false.

Copy link
Author

@gfcapalbo gfcapalbo Nov 7, 2025

Choose a reason for hiding this comment

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

@thomaspaulb
pos.db.. i will correct my typo now. but get_orders is connected to pos.db

You can see that the orders attribute of the pos object is taken from pos.db: https://github.com/odoo/odoo/blob/16.0/addons/point_of_sale/static/src/js/models.js#L246

get_orders fetches pos.orders, pos.orders is taken on session load from pos.db.orders

the comment is true.

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