|
@ -3,7 +3,7 @@ from odoo import models, api |
|
|
|
|
|
|
|
|
class ResPartner(models.Model): |
|
|
class ResPartner(models.Model): |
|
|
_inherit = "res.partner" |
|
|
_inherit = "res.partner" |
|
|
_order = "is_company desc, country_id, department_id, display_name, id" |
|
|
|
|
|
|
|
|
_order = "is_company desc, country_id, country_department_id, display_name, id" |
|
|
|
|
|
|
|
|
@api.onchange("state_id") |
|
|
@api.onchange("state_id") |
|
|
def _onchange_state_id(self): |
|
|
def _onchange_state_id(self): |
|
@ -20,12 +20,13 @@ class ResPartner(models.Model): |
|
|
elif self.partner_scale == "reg": |
|
|
elif self.partner_scale == "reg": |
|
|
self.crck_partner_id = self |
|
|
self.crck_partner_id = self |
|
|
|
|
|
|
|
|
@api.onchange("department_id") |
|
|
|
|
|
def _onchange_department_id(self): |
|
|
|
|
|
dept = self.department_id |
|
|
|
|
|
|
|
|
@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 == "loc": |
|
|
cdck = self.search( |
|
|
cdck = self.search( |
|
|
[("partner_scale", "=", "dep"), ("department_id", "=", dept)], limit=1 |
|
|
|
|
|
|
|
|
[("partner_scale", "=", "dep"), ("country_department_id", "=", dept)], |
|
|
|
|
|
limit=1, |
|
|
) |
|
|
) |
|
|
if cdck and cdck != self.cdck_partner_id: |
|
|
if cdck and cdck != self.cdck_partner_id: |
|
|
main = self.env.ref("base.main_partner") |
|
|
main = self.env.ref("base.main_partner") |
|
|