# -*- coding: utf-8 -*- ############################################################################# # # Cybrosys Technologies Pvt. Ltd. # # Copyright (C) 2021-TODAY Cybrosys Technologies() # Author: Cybrosys Techno Solutions() # # 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 . # ############################################################################# 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()