19.0 vanilla

This commit is contained in:
Ernad Husremovic 2026-03-09 09:29:53 +01:00
parent 6e54c1af6c
commit 3ca647e428
1087 changed files with 132065 additions and 108499 deletions

View file

@ -1,7 +1,8 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import fields, models
from odoo import fields, models, api
class PosOrderLine(models.Model):
_inherit = 'pos.order.line'
@ -10,7 +11,7 @@ class PosOrderLine(models.Model):
help="Whether this line is part of a reward or not.")
reward_id = fields.Many2one(
'loyalty.reward', "Reward", ondelete='restrict',
help="The reward associated with this line.")
help="The reward associated with this line.", index='btree_not_null')
coupon_id = fields.Many2one(
'loyalty.card', "Coupon", ondelete='restrict',
help="The coupon used to claim that reward.")
@ -19,18 +20,8 @@ class PosOrderLine(models.Model):
""")
points_cost = fields.Float(help="How many point this reward cost on the coupon.")
def _order_line_fields(self, line, session_id=None):
res = super()._order_line_fields(line, session_id)
# coupon_id may be negative in case of new coupons, they will be added after validating the order.
if 'coupon_id' in res[2] and res[2]['coupon_id'] < 1:
res[2].pop('coupon_id')
return res
def _is_not_sellable_line(self):
return super().is_not_sellable_line() or self.reward_id
def _export_for_ui(self, orderline):
result = super()._export_for_ui(orderline)
result['is_reward_line'] = orderline.is_reward_line
result['reward_id'] = orderline.reward_id.id
return result
@api.model
def _load_pos_data_fields(self, config):
params = super()._load_pos_data_fields(config)
params += ['is_reward_line', 'reward_id', 'reward_identifier_code', 'points_cost', 'coupon_id']
return params