-
- آخر زيارة:
+
+ آخر زيارة:
+
@@ -374,7 +408,15 @@
confirm="Are you sure you want to move to black list ?"/>
+
-
+
@@ -849,7 +895,8 @@
name="action_open_related_replacement_mother_families"
type="object"
attrs="{'invisible': [('total_replacement_mother_families', '=', 0)]}">
-
@@ -1654,6 +1701,7 @@
+
diff --git a/odex25_benefit/odex_benefit/views/family_members.xml b/odex25_benefit/odex_benefit/views/family_members.xml
index 48b08d235..ebd418bc1 100644
--- a/odex25_benefit/odex_benefit/views/family_members.xml
+++ b/odex25_benefit/odex_benefit/views/family_members.xml
@@ -233,9 +233,10 @@
+
-
+
diff --git a/odex25_benefit/odex_benefit/wizards/suspend_reason_wizard.py b/odex25_benefit/odex_benefit/wizards/suspend_reason_wizard.py
index 4d279abfe..e16dc7b2c 100644
--- a/odex25_benefit/odex_benefit/wizards/suspend_reason_wizard.py
+++ b/odex25_benefit/odex_benefit/wizards/suspend_reason_wizard.py
@@ -1,8 +1,8 @@
# -*- coding: utf-8 -*-
-from odoo import models, fields, _
+from odoo import models, fields, _, api
from odoo.exceptions import UserError
-
+from datetime import datetime, timedelta
class SuspendReasonWizard(models.TransientModel):
_name = 'suspend.reason.wizard'
@@ -22,12 +22,28 @@ class SuspendReasonWizard(models.TransientModel):
entity_id = fields.Many2one("grant.benefit", string="Entity", default=_default_entity)
member_id = fields.Many2one("family.member", string="Member", default=_default_member)
- suspend_reason = fields.Many2one('suspend.reason',string='Suspend Reason', required=True)
+ suspend_reason = fields.Many2one('suspend.reason', string='Suspend Reason',
+ domain=lambda self: self._get_suspend_reason_domain(), required=True)
suspend_description = fields.Text(string='Suspend Description', required=True)
suspend_attachment = fields.Binary(string='Suspend Attachment', attachment=True, required=True)
- suspend_type = fields.Selection(selection=[('temporarily_suspend', 'Temporarily Suspended'), ('suspend', 'Suspend')], string="Suspend Type", required=True)
+ final_suspend_date = fields.Date(string="Final Suspend Date",default=fields.Date.context_today)
+
+ @api.onchange('suspend_reason')
+ def _onchange_compute_final_suspend_date(self):
+ if self.suspend_reason and self.suspend_reason.suspend_type == 'temporarily_suspend':
+ days = self.suspend_reason.days_before_final_suspend or 0
+ self.final_suspend_date = datetime.today().date() + timedelta(days=days)
+ else:
+ self.final_suspend_date = fields.Date.context_today(self)
+
+ def _get_suspend_reason_domain(self):
+ domain = [('is_stop_reason', '=', True)]
+ if self._context.get('active_model') == 'family.member':
+ domain.append(('entity_type', '=', 'member'))
+ elif self._context.get('active_model') == 'grant.benefit':
+ domain.append(('entity_type', '=', 'family'))
+ return domain
-
def _create_attachment_record_from_binary(self):
self.ensure_one()
@@ -46,23 +62,39 @@ class SuspendReasonWizard(models.TransientModel):
}
return self.env['ir.attachment'].create(attachment_vals)
-
+
def action_submit(self):
for rec in self:
- rec.entity_id.state = 'waiting_approve'
- rec.entity_id.action_type = 'suspended'
- rec.entity_id.suspend_reason = rec.suspend_reason
- rec.entity_id.suspend_description = rec.suspend_description
- rec.entity_id.suspend_type = rec.suspend_type
- rec.entity_id.suspend_attachment = self._create_attachment_record_from_binary()
- rec.entity_id.suspend_method = 'manual'
+ rec.entity_id.member_ids.write({
+ 'is_excluded_suspension': False,
+ 'is_member_workflow': False,
+ 'final_suspend_date': rec.final_suspend_date,
+ })
+ attachment = rec._create_attachment_record_from_binary()
+ rec.entity_id.suspend_attachment = [(4, attachment.id)]
+ rec.entity_id.write({
+ 'state': 'waiting_approve',
+ 'action_type': 'suspended',
+ 'suspend_reason': rec.suspend_reason.id,
+ 'suspend_description': rec.suspend_description,
+ 'suspend_type': rec.suspend_reason.suspend_type,
+ 'suspend_method': 'manual',
+ 'final_suspend_date': rec.final_suspend_date,
+ 'is_excluded_suspension': False,
+ })
def action_member_submit(self):
for rec in self:
- rec.member_id.state_a = 'waiting_approve'
- rec.member_id.action_type = 'suspended'
- rec.member_id.suspend_reason = rec.suspend_reason
- rec.member_id.suspend_description = rec.suspend_description
- rec.member_id.suspend_type = rec.suspend_type
- rec.member_id.suspend_attachment = self._create_attachment_record_from_binary()
- rec.member_id.suspend_method = 'manual'
+ rec.member_id.write({
+ 'state_a': 'waiting_approve',
+ 'action_type': 'suspended',
+ 'suspend_reason': rec.suspend_reason.id,
+ 'suspend_description': rec.suspend_description,
+ 'suspend_type': rec.suspend_reason.suspend_type,
+ 'suspend_method': 'manual',
+ 'final_suspend_date': rec.final_suspend_date,
+ 'is_member_workflow': True,
+ 'is_excluded_suspension': False,
+ })
+ attachment = rec._create_attachment_record_from_binary()
+ rec.member_id.suspend_attachment = [(4, attachment.id)]
diff --git a/odex25_benefit/odex_benefit/wizards/suspend_reason_wizard.xml b/odex25_benefit/odex_benefit/wizards/suspend_reason_wizard.xml
index 716ca2814..160c956d6 100644
--- a/odex25_benefit/odex_benefit/wizards/suspend_reason_wizard.xml
+++ b/odex25_benefit/odex_benefit/wizards/suspend_reason_wizard.xml
@@ -13,8 +13,8 @@
-
+