Commit 4c4adf472453de65e45e fixed the `pos_discount` installation in case of a session is already opened. However, this breaks the following condition: https://github.com/odoo/odoo/blob/8aa952d18acca5a0ac3b32579e812158e641c13c/addons/point_of_sale/views/point_of_sale_dashboard.xml#L67 The `current_session_id` is always filled in for any user, so the badge is not shown anymore. We can keep the same logic than the mentioned commit but without impacting the computation of `current_session_id`. closes odoo/odoo#53412 closes odoo/odoo#53858 X-original-commit: 7e0e89cbf5d09c106936a582e27af527535103f6 Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
31 lines
1.4 KiB
Python
31 lines
1.4 KiB
Python
# -*- coding: utf-8 -*-
|
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
|
|
from odoo import api, fields, models
|
|
|
|
|
|
class PosConfig(models.Model):
|
|
_inherit = 'pos.config'
|
|
|
|
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', default=10.0)
|
|
discount_product_id = fields.Many2one('product.product', string='Discount Product',
|
|
domain="[('sale_ok', '=', True)]", help='The product used to model the discount.')
|
|
|
|
@api.onchange('company_id','module_pos_discount')
|
|
def _default_discount_product_id(self):
|
|
product = self.env.ref("point_of_sale.product_product_consumable", raise_if_not_found=False)
|
|
self.discount_product_id = product if self.module_pos_discount and product and (not product.company_id or product.company_id == self.company_id) else False
|
|
|
|
@api.model
|
|
def _default_discount_value_on_module_install(self):
|
|
configs = self.env['pos.config'].search([])
|
|
open_configs = (
|
|
self.env['pos.session']
|
|
.search(['|', ('state', '!=', 'closed'), ('rescue', '=', True)])
|
|
.mapped('config_id')
|
|
)
|
|
# Do not modify configs where an opened session exists.
|
|
for conf in (configs - open_configs):
|
|
conf._default_discount_product_id()
|