From 13de00969434c002e9112dec217625b051d1502b Mon Sep 17 00:00:00 2001 From: "Loukas Wets (lowe)" Date: Fri, 21 Apr 2023 08:20:44 +0000 Subject: [PATCH] [IMP] point_of_sale: change default parameters Tips Discount products - Unable to do global discounts because the `Discount` product isn't `Available in PoS`. The available in pos paramater of the `Discount` product in the data has then been set to true. - The attribute `tip_product_id` gets as default the product of default_code TIPS. - The condition of the display of tips option in pos payement has been changed to the boolean corresponding to the tick box of the settings and the `tip_product_id`. - Before, if a tip product was set and the tips option in the setting unselected the tips was still availible in the pos payement since it was based on the tip product id and not on the tick box. However, the `tip_product_id` still remains in the condition since it can be possible to check the option and not select a tip product. Task-3283007 closes odoo/odoo#119324 Signed-off-by: Joseph Caburnay (jcb) --- addons/point_of_sale/data/point_of_sale_data.xml | 2 +- addons/point_of_sale/models/pos_config.py | 11 +++++++++-- .../src/xml/Screens/PaymentScreen/PaymentScreen.xml | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/addons/point_of_sale/data/point_of_sale_data.xml b/addons/point_of_sale/data/point_of_sale_data.xml index 245e8e316b3..a061cd6585c 100644 --- a/addons/point_of_sale/data/point_of_sale_data.xml +++ b/addons/point_of_sale/data/point_of_sale_data.xml @@ -36,7 +36,7 @@ Discount - False + True 0.00 0.00 0.00 diff --git a/addons/point_of_sale/models/pos_config.py b/addons/point_of_sale/models/pos_config.py index 9374d3f0274..856df9889f7 100644 --- a/addons/point_of_sale/models/pos_config.py +++ b/addons/point_of_sale/models/pos_config.py @@ -125,7 +125,7 @@ class PosConfig(models.Model): group_pos_user_id = fields.Many2one('res.groups', string='Point of Sale User Group', default=_get_group_pos_user, help='This field is there to pass the id of the pos user group to the point of sale client.') iface_tipproduct = fields.Boolean(string="Product tips") - tip_product_id = fields.Many2one('product.product', string='Tip Product', + tip_product_id = fields.Many2one('product.product', string='Tip Product', compute='_compute_tip_product_id', store=True, help="This product is used as reference on customer receipts.") fiscal_position_ids = fields.Many2many('account.fiscal.position', string='Fiscal Positions', help='This is useful for restaurants with onsite and take-away services that imply specific tax rates.') default_fiscal_position_id = fields.Many2one('account.fiscal.position', string='Default Fiscal Position') @@ -252,6 +252,13 @@ class PosConfig(models.Model): for config in self: config.iface_customer_facing_display = config.iface_customer_facing_display_via_proxy or config.iface_customer_facing_display_local + @api.depends('iface_tipproduct') + def _compute_tip_product_id(self): + for pos_config in self: + pos_config.tip_product_id = self.env.ref("point_of_sale.product_product_tip") + if not pos_config.tip_product_id: + pos_config.tip_product_id = self.env['product.product'].search([('default_code', '=', 'TIPS')], limit=1) + @api.constrains('rounding_method') def _check_rounding_method_strategy(self): for config in self: @@ -650,7 +657,7 @@ class PosConfig(models.Model): ) OR p.id=%(tip_product_id)s ORDER BY t.priority DESC, t.detailed_type DESC, - COALESCE(pm.date,p.write_date) DESC + COALESCE(pm.date,p.write_date) DESC LIMIT %(limit)s """ params = { diff --git a/addons/point_of_sale/static/src/xml/Screens/PaymentScreen/PaymentScreen.xml b/addons/point_of_sale/static/src/xml/Screens/PaymentScreen/PaymentScreen.xml index 37810285077..9c5d3891649 100644 --- a/addons/point_of_sale/static/src/xml/Screens/PaymentScreen/PaymentScreen.xml +++ b/addons/point_of_sale/static/src/xml/Screens/PaymentScreen/PaymentScreen.xml @@ -87,7 +87,7 @@ t-on-click="toggleIsToInvoice"> Invoice -
Tip ()