fix: add null checks for pos_session references to prevent attribute errors during account and discount calculation
This commit is contained in:
parent
33ba3bef1d
commit
aa778e7e0b
@ -12,7 +12,7 @@ class PosSession(models.Model):
|
|||||||
"""Override to allow products without income accounts when payment methods have them configured"""
|
"""Override to allow products without income accounts when payment methods have them configured"""
|
||||||
def get_income_account(order_line):
|
def get_income_account(order_line):
|
||||||
product = order_line.product_id
|
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
|
# NEW: If no income account is found on the product, check if payment methods have income accounts configured
|
||||||
if not income_account:
|
if not income_account:
|
||||||
@ -59,7 +59,7 @@ class PosSession(models.Model):
|
|||||||
if not sales:
|
if not sales:
|
||||||
return data
|
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)
|
# Build per-order breakdown of sales keyed by (account, sign, tax tuple, tags)
|
||||||
order_payment_totals = {}
|
order_payment_totals = {}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user