From cda52f2f562b556dec569fdc7a22d7a6193ef473 Mon Sep 17 00:00:00 2001 From: zainab2097 <149927291+zainab2097@users.noreply.github.com> Date: Tue, 3 Sep 2024 13:56:44 +0300 Subject: [PATCH] Update property_management_conf.py --- .../models/property_management_conf.py | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/odex25_realstate/property_management/models/property_management_conf.py b/odex25_realstate/property_management/models/property_management_conf.py index 1b0f096e8..9016d47ee 100644 --- a/odex25_realstate/property_management/models/property_management_conf.py +++ b/odex25_realstate/property_management/models/property_management_conf.py @@ -3,19 +3,23 @@ from odoo import models, fields, api, exceptions, tools, _ +class Company(models.TransientModel): + _inherit = 'res.company' + + commission_percentage = fields.Float(string='Commission Percentage', help="The commission percentage.") + commission_account_id = fields.Many2one('account.account', string='Commission Account', help="The account used to record commissions.") + collecting_company_id = fields.Many2one('res.partner', string='Collecting Company', help="The company responsible for collecting the commission.") + + class ResConfigSettings(models.TransientModel): _inherit = 'res.config.settings' # Add new fields - commission_percentage = fields.Float(string='Commission Percentage', help="The commission percentage.") - commission_account_id = fields.Many2one('account.account', string='Commission Account', help="The account used to record commissions.") - collecting_company_id = fields.Many2one('res.partner', string='Collecting Company', help="The company responsible for collecting the commission.") - def set_values(self): - super(ResConfigSettings, self).set_values() - # Save the values to ir.config_parameter - self.env['ir.config_parameter'].sudo().set_param('property_management.commission_percentage', self.commission_percentage) - self.env['ir.config_parameter'].sudo().set_param('property_management.commission_account_id', self.commission_account_id.id) - self.env['ir.config_parameter'].sudo().set_param('property_management.collecting_company_id', self.collecting_company_id.id) + company_id = fields.Many2one('res.company', default=lambda self: self.env.company) + commission_percentage = fields.Float(string='Commission Percentage', help="The commission percentage.",related='company_id.commission_percentage') + commission_account_id = fields.Many2one('account.account', string='Commission Account', help="The account used to record commissions.",related='company_id.commission_account_id') + collecting_company_id = fields.Many2one('res.partner', string='Collecting Company', help="The company responsible for collecting the commission.",related='company_id.collecting_company_id') + class RentType(models.Model): _name = 'rent.type' _description = 'Rent Type'