You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
2.5 KiB
60 lines
2.5 KiB
# -*- coding: utf-8 -*-
|
|
################################################################################
|
|
#
|
|
# Cybrosys Technologies Pvt. Ltd.
|
|
#
|
|
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>).
|
|
# Author: ADVAITH B G (odoo@cybrosys.com)
|
|
#
|
|
# You can modify it under the terms of the GNU AFFERO
|
|
# GENERAL PUBLIC LICENSE (AGPL v3), Version 3.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details.
|
|
#
|
|
# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
|
|
# (AGPL v3) along with this program.
|
|
# If not, see <http://www.gnu.org/licenses/>.
|
|
#
|
|
################################################################################
|
|
from odoo import api, fields, models
|
|
|
|
|
|
class ResConfigSettings(models.TransientModel):
|
|
_inherit = 'res.config.settings'
|
|
|
|
# pos.config fields
|
|
pos_is_service_charges = fields.Boolean(
|
|
related='pos_config_id.is_service_charges', readonly=False)
|
|
pos_visibility_type = fields.Selection([
|
|
('global', 'Global'),
|
|
('session', 'Session')],
|
|
related='pos_config_id.visibility_type',
|
|
readonly=False)
|
|
pos_service_charge = fields.Float(related='pos_config_id.service_charge',
|
|
readonly=False)
|
|
pos_service_product_id = fields.Many2one(
|
|
'product.product',
|
|
compute='_compute_pos_service_product_id', store=True, readonly=False)
|
|
pos_service_charge_type = fields.Selection([
|
|
('amount', 'Amount'),
|
|
('percentage', 'Percentage')],
|
|
related='pos_config_id.service_charge_type',
|
|
readonly=False)
|
|
|
|
@api.depends('company_id', 'pos_is_service_charges', 'pos_config_id')
|
|
def _compute_pos_service_product_id(self):
|
|
default_product = self.env.ref(
|
|
"point_of_sale.product_product_consumable",
|
|
raise_if_not_found=False) or self.env['product.product']
|
|
for res_config in self:
|
|
service_product = res_config.pos_config_id.service_product_id or (
|
|
default_product)
|
|
if (res_config.pos_is_service_charges) and (
|
|
not service_product.company_id or (
|
|
service_product.company_id) == res_config.company_id):
|
|
res_config.pos_service_product_id = service_product
|
|
else:
|
|
res_config.pos_service_product_id = False
|
|
|