[FIX] point_of_sale: discount product as special

closes odoo/odoo#141001

Related: odoo/enterprise#50282
Signed-off-by: Adrien Guilliams (adgu) <adgu@odoo.com>
This commit is contained in:
Joseph Caburnay
2023-11-06 16:55:38 +00:00
parent f0ac47845d
commit f4e9dd9ec3
4 changed files with 11 additions and 12 deletions
+2 -2
View File
@@ -798,5 +798,5 @@ class PosConfig(models.Model):
return pm
return False
def _get_special_products_ids(self):
return [self.env.ref('point_of_sale.product_product_tip').id]
def _get_special_products(self):
return self.env.ref('point_of_sale.product_product_tip', raise_if_not_found=False) or self.env['product.product']
+2 -2
View File
@@ -1681,7 +1681,7 @@ class PosSession(models.Model):
loaded_data['attributes_by_ptal_id'] = self._get_attributes_by_ptal_id()
loaded_data['base_url'] = self.get_base_url()
loaded_data['pos_has_valid_product'] = self._pos_has_valid_product()
loaded_data['pos_special_products_ids'] = self.env['pos.config']._get_special_products_ids()
loaded_data['pos_special_products_ids'] = self.env['pos.config']._get_special_products().ids
loaded_data['open_orders'] = self.env['pos.order'].search([('session_id', '=', self.id), ('state', '=', 'draft')]).export_for_ui()
@api.model
@@ -2215,7 +2215,7 @@ class PosSession(models.Model):
self.message_post(body=body, author_id=partner_id)
def _pos_has_valid_product(self):
return self.env['product.product'].sudo().search_count([('available_in_pos', '=', True), ('list_price', '>=', 0), ('id', 'not in', self.env['pos.config']._get_special_products_ids()), '|', ('active', '=', False), ('active', '=', True)], limit=1) > 0
return self.env['product.product'].sudo().search_count([('available_in_pos', '=', True), ('list_price', '>=', 0), ('id', 'not in', self.env['pos.config']._get_special_products().ids), '|', ('active', '=', False), ('active', '=', True)], limit=1) > 0
@api.model
def _load_onboarding_data(self):
+4 -4
View File
@@ -32,7 +32,7 @@ class PosConfig(models.Model):
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_ids(self):
res = super()._get_special_products_ids()
res += self.env['pos.config'].search([]).mapped('discount_product_id').ids
return res
def _get_special_products(self):
res = super()._get_special_products()
default_discount_product = self.env.ref('point_of_sale.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
+3 -4
View File
@@ -14,7 +14,6 @@ class PosConfig(models.Model):
string="Down Payment Product",
help="This product will be used as down payment on a sale order.")
def _get_special_products_ids(self):
res = super()._get_special_products_ids()
res += self.env['pos.config'].search([]).mapped('down_payment_product_id').ids
return res
def _get_special_products(self):
res = super()._get_special_products()
return res | self.env['pos.config'].search([]).mapped('down_payment_product_id')