[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) <jcb@odoo.com>
This commit is contained in:
Loukas Wets (lowe)
2023-05-16 13:36:56 +02:00
parent f7c61e9412
commit 13de009694
3 changed files with 11 additions and 4 deletions
@@ -36,7 +36,7 @@
<record id="product_product_consumable" model="product.product">
<field name="name">Discount</field>
<field name="available_in_pos">False</field>
<field name="available_in_pos">True</field>
<field name="standard_price">0.00</field>
<field name="list_price">0.00</field>
<field name="weight">0.00</field>
+9 -2
View File
@@ -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 = {
@@ -87,7 +87,7 @@
t-on-click="toggleIsToInvoice">
<i class="fa fa-file-text-o" /> Invoice
</div>
<div t-if="pos.globalState.config.tip_product_id" class="button js_tip"
<div t-if="pos.globalState.config.iface_tipproduct and pos.globalState.config.tip_product_id" class="button js_tip"
t-att-class="{ highlight: currentOrder.get_tip() }"
t-on-click="addTip">
<i class="fa fa-heart" /> Tip <t t-if="currentOrder.get_tip() != 0">(<t t-esc="env.utils.formatCurrency(currentOrder.get_tip())"/>)</t>