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

@ -11,7 +11,7 @@ class PosConfig(models.Model):
iface_discount = fields.Boolean(string='Order Discounts', help='Allow the cashier to give discounts on the whole order.')
discount_pc = fields.Float(string='Discount Percentage', help='The default discount percentage when clicking on the Discount button', default=10.0)
discount_product_id = fields.Many2one('product.product', string='Discount Product',
domain="[('sale_ok', '=', True)]", help='The product used to apply the discount on the ticket.')
domain=[('sale_ok', '=', True)], help='The product used to apply the discount on the ticket.')
@api.model
def _default_discount_value_on_module_install(self):
@ -22,7 +22,7 @@ class PosConfig(models.Model):
.mapped('config_id')
)
# Do not modify configs where an opened session exists.
product = self.env.ref("point_of_sale.product_product_consumable", raise_if_not_found=False)
product = self.env.ref("pos_discount.product_product_consumable", raise_if_not_found=False)
for conf in (configs - open_configs):
conf.discount_product_id = product if conf.module_pos_discount and product and (not product.company_id or product.company_id == conf.company_id) else False
@ -31,3 +31,8 @@ class PosConfig(models.Model):
if not self.current_session_id and config.module_pos_discount and not config.discount_product_id:
raise UserError(_('A discount product is needed to use the Global Discount feature. Go to Point of Sale > Configuration > Settings to set it.'))
return super().open_ui()
def _get_special_products(self):
res = super()._get_special_products()
default_discount_product = self.env.ref('pos_discount.product_product_consumable', raise_if_not_found=False) or self.env['product.product']
return res | self.env['pos.config'].search([]).mapped('discount_product_id') | default_discount_product