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.
62 lines
2.6 KiB
62 lines
2.6 KiB
# -*- coding: utf-8 -*-
|
|
#############################################################################
|
|
#
|
|
# Cybrosys Technologies Pvt. Ltd.
|
|
#
|
|
# Copyright (C) 2021-TODAY Cybrosys Technologies(<https://www.cybrosys.com>)
|
|
# Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>)
|
|
#
|
|
# You can modify it under the terms of the GNU LESSER
|
|
# GENERAL PUBLIC LICENSE (LGPL 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 LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details.
|
|
#
|
|
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE
|
|
# (LGPL v3) along with this program.
|
|
# If not, see <http://www.gnu.org/licenses/>.
|
|
#
|
|
#############################################################################
|
|
from odoo import fields, models
|
|
|
|
|
|
class ResConfigSettings(models.TransientModel):
|
|
"""
|
|
ResConfigSettings class for add methods and field for generate qr code
|
|
options in general settings,
|
|
Methods:
|
|
get_values(self):
|
|
For getting values from ResConfigSettings Transient model
|
|
set_values(self):
|
|
For setting values for ResConfigSettings Transient model, ie saving
|
|
the changes that made from general settings.
|
|
"""
|
|
_inherit = 'res.config.settings'
|
|
|
|
customer_prefix = fields.Char(string="Customer QR Prefix")
|
|
product_prefix = fields.Char(string="Product QR Prefix")
|
|
|
|
def get_values(self):
|
|
""" For getting values from ResConfigSettings Transient model """
|
|
res = super(ResConfigSettings, self).get_values()
|
|
customer_prefix = self.env["ir.config_parameter"].get_param(
|
|
"customer_product_qr.config.customer_prefix")
|
|
product_prefix = self.env["ir.config_parameter"].get_param(
|
|
"customer_product_qr.config.product_prefix")
|
|
res.update({
|
|
'customer_prefix': customer_prefix if type(
|
|
customer_prefix) else False,
|
|
'product_prefix': product_prefix if type(product_prefix) else False
|
|
}
|
|
)
|
|
return res
|
|
|
|
def set_values(self):
|
|
""" Saving the changes made from general settings """
|
|
self.env['ir.config_parameter'].sudo().set_param(
|
|
'customer_product_qr.config.customer_prefix', self.customer_prefix)
|
|
self.env['ir.config_parameter'].sudo().set_param(
|
|
'customer_product_qr.config.product_prefix', self.product_prefix)
|
|
super(ResConfigSettings, self).set_values()
|
|
|