|
|
@ -9,28 +9,28 @@ class ResPartner(models.Model): |
|
|
|
def _onchange_state_id(self): |
|
|
|
state = self.state_id |
|
|
|
if state: |
|
|
|
if self.partner_scale in ["dept", "loc"]: |
|
|
|
if self.partner_scale in ["3", "4"]: |
|
|
|
crck = self.search( |
|
|
|
[("partner_scale", "=", "reg"), ("state_id", "=", state)], limit=1 |
|
|
|
[("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 == "reg": |
|
|
|
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 == "loc": |
|
|
|
if dept and self.partner_scale == "4": |
|
|
|
cdck = self.search( |
|
|
|
[("partner_scale", "=", "dep"), ("country_department_id", "=", dept)], |
|
|
|
[("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 == "dep": |
|
|
|
elif self.partner_scale == "3": |
|
|
|
self.cdck_partner_id = self |