from odoo import models, api class ResPartner(models.Model): _inherit = "res.partner" _order = "is_company desc, display_name, id" # @api.onchange("state_id") # def _onchange_state_id(self): # state = self.state_id # if state: # if self.partner_scale in ["3", "4"]: # crck = self.search( # [("partner_scale", "=", "2"), ("state_id", "=", state)], limit=1 # ) # if crck and crck != self.crck_partner_id: # main = self.env.ref("base.main_partner") # if self.crck_partner_id != main: # self.crck_partner_id = main # elif self.partner_scale == "2": # self.crck_partner_id = self # @api.onchange("country_department_id") # def _onchange_country_department_id(self): # dept = self.country_department_id # if dept and self.partner_scale == "4": # cdck = self.search( # [("partner_scale", "=", "3"), ("country_department_id", "=", dept)], # limit=1, # ) # if cdck and cdck != self.cdck_partner_id: # main = self.env.ref("base.main_partner") # if self.cdck_partner_id != main: # self.cdck_partner_id = main # elif self.partner_scale == "3": # self.cdck_partner_id = self