[UPD] odex_benefit
This commit is contained in:
parent
959cd42ed8
commit
649f7ab47f
|
|
@ -998,7 +998,7 @@ msgid "Is Family"
|
|||
msgstr "عائلة؟"
|
||||
|
||||
#. module: takaful_core
|
||||
#: model:ir.model.fields,field_description:takaful_core.field_res_partner__is_sponsor
|
||||
#: model:ir.model.fields,field_description:takaful_core.field_res_partner__is_sponsor_portal
|
||||
#: model:ir.model.fields,field_description:takaful_core.field_res_users__is_sponsor
|
||||
msgid "Is Sponsor"
|
||||
msgstr "كافل؟"
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ class Partner(models.Model):
|
|||
('donor', 'Donor')],
|
||||
required=False, )
|
||||
is_family = fields.Boolean()
|
||||
is_sponsor = fields.Boolean()
|
||||
is_sponsor_portal = fields.Boolean(string='Is Sponsor')
|
||||
is_benefit = fields.Boolean()
|
||||
is_vendor = fields.Boolean()
|
||||
is_donor = fields.Boolean()
|
||||
|
|
@ -116,12 +116,18 @@ class Partner(models.Model):
|
|||
def set_partner_account_type(self, acc_type):
|
||||
self.ensure_one()
|
||||
|
||||
target_field = f"is_{acc_type}"
|
||||
# Special mappings for account_type -> boolean field names
|
||||
special_map = {
|
||||
'sponsor': 'is_sponsor_portal',
|
||||
}
|
||||
|
||||
# Determine the target boolean field name
|
||||
target_field = special_map.get(acc_type, f'is_{acc_type}')
|
||||
|
||||
# Validate that acc_type is one of the selection values and field exists
|
||||
valid_types = {key for key, _ in self._fields['account_type'].selection}
|
||||
if acc_type in valid_types and target_field in self._fields:
|
||||
update_vals = {
|
||||
target_field: True,
|
||||
}
|
||||
if target_field in self._fields and (acc_type in valid_types or target_field == 'is_sponsor_portal'):
|
||||
update_vals = {target_field: True}
|
||||
self.write(update_vals)
|
||||
|
||||
def migrate_account_type_to_booleans(self):
|
||||
|
|
@ -133,11 +139,9 @@ class Partner(models.Model):
|
|||
_logger.info(f"-> Starting account type migration for {len(records)} partner(s).")
|
||||
for partner in records:
|
||||
acc_type = partner.account_type
|
||||
if acc_type:
|
||||
target_field = f"is_{acc_type}"
|
||||
if target_field in partner._fields:
|
||||
# Update only the target field, leaving others as they are.
|
||||
partner.write({target_field: True})
|
||||
if not acc_type:
|
||||
continue
|
||||
partner.set_partner_account_type(acc_type)
|
||||
_logger.info("-> Partner account type migration finished.")
|
||||
return True
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
<group>
|
||||
<group>
|
||||
<field name="is_family" />
|
||||
<field name="is_sponsor" />
|
||||
<field name="is_sponsor_portal" />
|
||||
<field name="is_benefit" />
|
||||
</group>
|
||||
<group>
|
||||
|
|
|
|||
Loading…
Reference in New Issue