|
@ -259,26 +259,13 @@ class ResPartner(models.Model): |
|
|
partner.cdck_partner_id = partner.local_partner_id.cdck_partner_id |
|
|
partner.cdck_partner_id = partner.local_partner_id.cdck_partner_id |
|
|
todo = self - local_ok |
|
|
todo = self - local_ok |
|
|
if todo: |
|
|
if todo: |
|
|
structures = todo.filtered( |
|
|
|
|
|
lambda rp: rp.is_company |
|
|
|
|
|
and rp.ffck_network |
|
|
|
|
|
and rp.partner_code |
|
|
|
|
|
and len(rp.partner_code) >= 2 |
|
|
|
|
|
and int(rp.partner_scale) == 4 |
|
|
|
|
|
) |
|
|
|
|
|
licensees = todo.filtered( |
|
|
|
|
|
lambda rp: not rp.is_company |
|
|
|
|
|
and rp.ffck_network |
|
|
|
|
|
and int(rp.partner_scale) == 5 |
|
|
|
|
|
and rp.country_department_id |
|
|
|
|
|
) |
|
|
|
|
|
dept_codes = todo.mapped( |
|
|
dept_codes = todo.mapped( |
|
|
lambda rp: rp.ffck_network |
|
|
lambda rp: rp.ffck_network |
|
|
and ( |
|
|
and ( |
|
|
rp.is_company |
|
|
rp.is_company |
|
|
and rp.partner_code |
|
|
and rp.partner_code |
|
|
and len(rp.partner_code) >= 2 |
|
|
and len(rp.partner_code) >= 2 |
|
|
and int(rp.partner_scale) in (3, 4) |
|
|
|
|
|
|
|
|
and int(rp.partner_scale) >= 4 |
|
|
and rp.partner_code[:2] |
|
|
and rp.partner_code[:2] |
|
|
or not rp.is_company |
|
|
or not rp.is_company |
|
|
and rp.country_department_id |
|
|
and rp.country_department_id |
|
@ -298,17 +285,29 @@ class ResPartner(models.Model): |
|
|
] |
|
|
] |
|
|
) |
|
|
) |
|
|
cdck_by_code = {cdck.partner_code[:2]: cdck for cdck in cdck_ok} |
|
|
cdck_by_code = {cdck.partner_code[:2]: cdck for cdck in cdck_ok} |
|
|
|
|
|
cdck_codes = cdck_by_code.keys() |
|
|
|
|
|
structures = todo.filtered( |
|
|
|
|
|
lambda rp: rp.is_company |
|
|
|
|
|
and rp.ffck_network |
|
|
|
|
|
and rp.partner_code |
|
|
|
|
|
and len(rp.partner_code) >= 2 |
|
|
|
|
|
and int(rp.partner_scale) == 4 |
|
|
|
|
|
and rp.partner_code[:2] in cdck_codes |
|
|
|
|
|
) |
|
|
|
|
|
licensees = todo.filtered( |
|
|
|
|
|
lambda rp: not rp.is_company |
|
|
|
|
|
and rp.ffck_network |
|
|
|
|
|
and int(rp.partner_scale) == 5 |
|
|
|
|
|
and rp.country_department_id.code in cdck_codes |
|
|
|
|
|
) |
|
|
# Treat structures |
|
|
# Treat structures |
|
|
for partner in structures: |
|
|
for partner in structures: |
|
|
partner.cdck_partner_id = cdck_by_code[partner.partner_code[:2]] |
|
|
partner.cdck_partner_id = cdck_by_code[partner.partner_code[:2]] |
|
|
# Treat licensees |
|
|
# Treat licensees |
|
|
for partner in licensees: |
|
|
for partner in licensees: |
|
|
dept = partner.country_department_id |
|
|
|
|
|
local = partner.local_partner_id |
|
|
|
|
|
local_cd = local.cdck_partner_id |
|
|
|
|
|
partner.cdck_partner_id = ( |
|
|
|
|
|
local_cd if local and local_cd else cdck_by_code[dept.code] |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
dept = partner.country_department_id.code |
|
|
|
|
|
if dept in cdck_codes: |
|
|
|
|
|
partner.cdck_partner_id = cdck_by_code[dept] |
|
|
# treat others |
|
|
# treat others |
|
|
for partner in todo - (structures | licensees): |
|
|
for partner in todo - (structures | licensees): |
|
|
partner.cdck_partner_id = False |
|
|
partner.cdck_partner_id = False |
|
|