From aa778e7e0b91358e8b3d71f2fe446b7a2fd5dd5b Mon Sep 17 00:00:00 2001 From: Suherdy Yacob Date: Sat, 20 Jun 2026 22:27:49 +0700 Subject: [PATCH] fix: add null checks for pos_session references to prevent attribute errors during account and discount calculation --- models/pos_session.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/models/pos_session.py b/models/pos_session.py index 96fa64a..92f171d 100644 --- a/models/pos_session.py +++ b/models/pos_session.py @@ -12,7 +12,7 @@ class PosSession(models.Model): """Override to allow products without income accounts when payment methods have them configured""" def get_income_account(order_line): product = order_line.product_id - income_account = product.with_company(order_line.company_id)._get_product_accounts()['income'] or self.config_id.journal_id.default_account_id + income_account = product.with_company(order_line.company_id)._get_product_accounts()['income'] or (self and self[0].config_id.journal_id.default_account_id or False) # NEW: If no income account is found on the product, check if payment methods have income accounts configured if not income_account: @@ -59,7 +59,7 @@ class PosSession(models.Model): if not sales: return data - discount_product_id = self.config_id.discount_product_id.id if self.config_id.discount_product_id else None + discount_product_id = self[0].config_id.discount_product_id.id if self and self[0].config_id.discount_product_id else None # Build per-order breakdown of sales keyed by (account, sign, tax tuple, tags) order_payment_totals = {}