Browse Source

Jan 27: [FIX] Bug Fixed 'crm_check_approve_limiter'

pull/309/head
Cybrosys Technologies 3 months ago
parent
commit
662421c987
  1. 2
      crm_check_approve_limiter/__manifest__.py
  2. 5
      crm_check_approve_limiter/doc/RELEASE_NOTES.md
  3. 63
      crm_check_approve_limiter/models/crm_lead.py

2
crm_check_approve_limiter/__manifest__.py

@ -21,7 +21,7 @@
#############################################################################
{
'name': 'CheckList & Approval Process in CRM',
'version': '17.0.1.0.0',
'version': '17.0.1.1.0',
'category': 'CRM',
'summary': 'Manage CRM based on CheckList and Team/Stage and'
'Approval Process to Make Sure Everything Completed In '

5
crm_check_approve_limiter/doc/RELEASE_NOTES.md

@ -4,3 +4,8 @@
#### Version 17.0.1.0.0
#### ADD
- Initial commit for CheckList & Approval Process in CRM
#### 20.01.2025
#### Version 17.0.1.1.0
#### UPDT
- Fixed bugs in checklist history tracking functionality

63
crm_check_approve_limiter/models/crm_lead.py

@ -96,15 +96,18 @@ class CrmLead(models.Model):
and item not in self.check_list_ids:
self.check_list_ids += item
if 'check_list_ids' in vals_set.keys():
group_check = self.env.user. \
has_group('crm_check_approve_limiter.'
'crm_check_approve_manager')
group_check = self.env.user.has_group('crm_check_approve_limiter.crm_check_approve_manager')
user_groups = self.env.user.groups_id
new_ids = self.env['stage.check.list']. \
search([('id', 'in', vals_set['check_list_ids'][-1])])
check_item_id = (self.check_list_ids - new_ids)
check_item2 = (new_ids - self.check_list_ids)
for ch_lst in check_item2:
complete_operations = []
notcomplete_operations = []
for operation in vals_set['check_list_ids']:
if operation[0] == 4: # Add operation
complete_operations.append(operation[1])
elif operation[0] == 3: # Remove operation
notcomplete_operations.append(operation[1])
new_complete_ids = self.env['stage.check.list'].search([('id', 'in', complete_operations)])
new_notcomplete_ids = self.env['stage.check.list'].search([('id', 'in', notcomplete_operations)])
for ch_lst in new_complete_ids:
if (ch_lst.approve_groups_ids and not ch_lst.approve_groups_ids
.filtered(lambda f: f in user_groups) and
not group_check):
@ -114,37 +117,37 @@ class CrmLead(models.Model):
raise ValidationError(f'Only the below specified group'
f' members can complete this task'
f' : {grp_string_t}')
for ch_lst in check_item_id:
for ch_lst in new_notcomplete_ids:
if (ch_lst.approve_groups_ids and not ch_lst.approve_groups_ids
.filtered(
lambda f: f in user_groups) and not group_check):
.filtered(lambda f: f in user_groups) and
not group_check):
grp_string_t = '\n'.join(
map(str, ch_lst.approve_groups_ids.
mapped('full_name')))
raise ValidationError(f'Only the below specified group'
f' members can undo this task'
f' members can complete this task'
f' : {grp_string_t}')
if 'stage_id' not in vals_set.keys() and check_item_id:
for c_item in check_item_id:
if 'stage_id' not in vals_set.keys() and new_complete_ids:
for c_item in new_complete_ids:
vals = {
'lead_id': self.id,
'check_item_id': c_item.id,
'list_action': 'not_complete',
'change_date': datetime.now(),
'user_id': self.env.user.id,
'stage_id': self.stage_id.id
}
'lead_id': self.id,
'check_item_id': c_item.id,
'list_action': 'complete',
'change_date': datetime.now(),
'user_id': self.env.user.id,
'stage_id': self.stage_id.id
}
self.env['crm.lead.check.history'].sudo().create(vals)
elif 'stage_id' not in vals_set.keys() and check_item2:
for c_item in check_item2:
if 'stage_id' not in vals_set.keys() and new_notcomplete_ids:
for c_item in new_notcomplete_ids:
vals = {
'lead_id': self.id,
'check_item_id': c_item.id,
'list_action': 'complete',
'change_date': datetime.now(),
'user_id': self.env.user.id,
'stage_id': self.stage_id.id
}
'lead_id': self.id,
'check_item_id': c_item.id,
'list_action': 'not_complete',
'change_date': datetime.now(),
'user_id': self.env.user.id,
'stage_id': self.stage_id.id
}
self.env['crm.lead.check.history'].sudo().create(vals)
res = super().write(vals_set)
return res

Loading…
Cancel
Save