Browse Source

[FIX] cdck compute + partner form

16.0
RemiFr82 7 months ago
parent
commit
d8edca9c5b
  1. 39
      ffck_commons/models/res_partner.py
  2. 2
      ffck_commons/views/res_partner.xml

39
ffck_commons/models/res_partner.py

@ -259,26 +259,13 @@ class ResPartner(models.Model):
partner.cdck_partner_id = partner.local_partner_id.cdck_partner_id
todo = self - local_ok
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(
lambda rp: rp.ffck_network
and (
rp.is_company
and rp.partner_code
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]
or not rp.is_company
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_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
for partner in structures:
partner.cdck_partner_id = cdck_by_code[partner.partner_code[:2]]
# Treat 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
for partner in todo - (structures | licensees):
partner.cdck_partner_id = False

2
ffck_commons/views/res_partner.xml

@ -34,7 +34,7 @@
attrs="{'invisible': [('is_company','=',False)]}" />
<field name="age_range" invisible="1" />
<field name="ffck_membership_type_id" domain="[('age_range','=',age_range)]"
attrs="{'invisible': [('is_company','=',True)]}" />
attrs="{'invisible': ['|',('is_company','=',True),'|',('birthdate_date','=',False), ('nationality_id','=',False)]}" />
<separator string="Structure dates" colspan="2" />
<field name="first_membership_date" />
<field name="last_membership_date" />

Loading…
Cancel
Save