Merge pull request #5783 from expsa/youn_dev_odex25_benefit

Youn dev odex25 benefit
This commit is contained in:
kchyounes19 2025-12-21 19:40:00 +01:00 committed by GitHub
commit 5f6b5e1a31
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 458 additions and 57 deletions

View File

@ -2752,6 +2752,7 @@ msgstr "بإمكانه النشر "
#: model_terms:ir.ui.view,arch_db:odex_benefit.view_suspend_reason_wizard_form
#: model_terms:ir.ui.view,arch_db:odex_benefit.view_visit_skip_otp_wizard_form
#: model_terms:ir.ui.view,arch_db:odex_benefit.visit_location_otp_wizard_form
#: model_terms:ir.ui.view,arch_db:odex_benefit.view_resume_reason_wizard_form
#: model_terms:ir.ui.view,arch_db:odex_benefit.view_visit_location_refusal_reason_wizard_form
msgid "Cancel"
msgstr "إلغاء"
@ -8724,6 +8725,7 @@ msgstr "جوار السكن"
#: model:ir.model.fields,field_description:odex_benefit.field_grant_benefit__comment
#: model:ir.model.fields,field_description:odex_benefit.field_service_attachments_settings__notes
#: model:ir.model.fields,field_description:odex_benefit.field_visit_location_refusal_reason_wizard__refusal_notes
#: model_terms:ir.ui.view,arch_db:odex_benefit.view_resume_reason_wizard_form
msgid "Notes"
msgstr "الملاحظات"
@ -10888,6 +10890,7 @@ msgstr "الخدمة الفرعية"
#: model_terms:ir.ui.view,arch_db:odex_benefit.view_resarcher_member_wizard_form
#: model_terms:ir.ui.view,arch_db:odex_benefit.view_suspend_member_reason_wizard_form
#: model_terms:ir.ui.view,arch_db:odex_benefit.view_suspend_reason_wizard_form
#: model_terms:ir.ui.view,arch_db:odex_benefit.view_resume_reason_wizard_form
msgid "Submit"
msgstr "إرسال"
@ -10983,6 +10986,18 @@ msgstr "رابط الاستبيان"
msgid "Suspend"
msgstr "إيقاف نهائي"
#. module: odex_benefit
#: model_terms:ir.ui.view,arch_db:odex_benefit.grant_benefit_form
#: model_terms:ir.ui.view,arch_db:odex_benefit.family_member_form
msgid "Suspend"
msgstr "إيقاف"
#. module: odex_benefit
#: model_terms:ir.ui.view,arch_db:odex_benefit.grant_benefit_form
#: model_terms:ir.ui.view,arch_db:odex_benefit.family_member_form
msgid "Resume"
msgstr "الإعادة للخدمة"
#. module: odex_benefit
#: model:ir.model,name:odex_benefit.model_suspend_reason
msgid "Suspend - Reason"
@ -13290,6 +13305,7 @@ msgstr "خريطة جوجال"
#: model_terms:ir.ui.view,arch_db:odex_benefit.view_exception_wizard_form
#: model_terms:ir.ui.view,arch_db:odex_benefit.view_resarcher_member_wizard_form
#: model_terms:ir.ui.view,arch_db:odex_benefit.view_suspend_member_reason_wizard_form
#: model_terms:ir.ui.view,arch_db:odex_benefit.view_resume_reason_wizard_form
#: model_terms:ir.ui.view,arch_db:odex_benefit.view_suspend_reason_wizard_form
msgid "or"
msgstr "أو"
@ -14638,6 +14654,12 @@ msgstr "سبب الإرجاع"
msgid "Return Reason"
msgstr "سبب إرجاع البنك"
#. module: odex_benefit
#: model:ir.model.fields,field_description:odex_benefit.field_family_member__resume_reason_id
#: model:ir.model.fields,field_description:odex_benefit.field_grant_benefit__resume_reason_id
msgid "Return Reason"
msgstr "سبب الإعادة"
#. module: odex_benefit
#: model_terms:ir.ui.view,arch_db:odex_benefit.view_entity_return_reason_wizard_form
msgid "Retrun"
@ -17751,3 +17773,113 @@ msgstr "التزامات الأم"
#: model_terms:ir.ui.view,arch_db:odex_benefit.grant_benefit_form
msgid "Deduct from Mother Income"
msgstr "يتم الخصم من دخل الأم"
#. module: odex_benefit
#: model:ir.model.fields.selection,name:odex_benefit.selection__family_member__action_type__resume_from_temporary
#: model:ir.model.fields.selection,name:odex_benefit.selection__grant_benefit__action_type__resume_from_temporary
#: model_terms:ir.ui.view,arch_db:odex_benefit.grant_benefit_form
msgid "Resume from Temporary Suspension"
msgstr "إعادة من الإيقاف المؤقت"
#. module: odex_benefit
#: model:ir.model.fields.selection,name:odex_benefit.selection__family_member__action_type__resume_from_final
#: model:ir.model.fields.selection,name:odex_benefit.selection__grant_benefit__action_type__resume_from_final
#: model_terms:ir.ui.view,arch_db:odex_benefit.grant_benefit_form
msgid "Resume from Final Suspension"
msgstr "إعادة من الإيقاف النهائي"
#. module: odex_benefit
#: model:ir.model.fields,field_description:odex_benefit.field_family_member__resume_date
#: model:ir.model.fields,field_description:odex_benefit.field_grant_benefit__resume_date
msgid "Return Date"
msgstr "تاريخ الإعادة"
#. module: odex_benefit
#: model:ir.model.fields,field_description:odex_benefit.field_family_member__resume_notes
#: model:ir.model.fields,field_description:odex_benefit.field_grant_benefit__resume_notes
msgid "Return Notes"
msgstr "ملاحظات الإعادة"
#. module: odex_benefit
#: code:addons/odex_benefit/models/benefit.py:0
#: code:addons/odex_benefit/models/family_members.py:0
#, python-format
msgid "Resume Reason Wizard"
msgstr "سبب الإعادة"
#. module: odex_benefit
#: code:addons/odex_benefit/models/benefit.py:0
#: code:addons/odex_benefit/models/family_members.py:0
#, python-format
msgid ""
"Final suspension cannot be executed until after the specified final "
"suspension date."
msgstr "لا يمكن تنفيذ الإيقاف النهائي حتى بعد تاريخ الإيقاف النهائي المحدد."
#. module: odex_benefit
#: model:ir.model.fields,field_description:odex_benefit.field_suspend_reason__is_resume_reason
msgid "Resume Reason"
msgstr "سبب الإعادة"
#. module: odex_benefit
#: model_terms:ir.ui.view,arch_db:odex_benefit.family_member_form
#: model_terms:ir.ui.view,arch_db:odex_benefit.grant_benefit_form
msgid "Resume Approval by Operations Head"
msgstr "اعتماد رئيس العمليات للإعادة"
#. module: odex_benefit
#: model_terms:ir.ui.view,arch_db:odex_benefit.family_member_form
#: model_terms:ir.ui.view,arch_db:odex_benefit.grant_benefit_form
msgid "Resume Approval by Branch Manager"
msgstr "اعتماد مدير الفرع للإعادة"
#. module: odex_benefit
#: model_terms:ir.ui.view,arch_db:odex_benefit.family_member_form
#: model_terms:ir.ui.view,arch_db:odex_benefit.grant_benefit_form
msgid "Resume Approval by Family Services Manager"
msgstr "اعتماد مديرة خدمات المستفيدين للإعادة"
#. module: odex_benefit
#: model_terms:ir.ui.view,arch_db:odex_benefit.family_member_form
#: model_terms:ir.ui.view,arch_db:odex_benefit.grant_benefit_form
msgid "Resume Family Service"
msgstr "إعادة الأسرة للخدمة"
#. module: odex_benefit
#: model_terms:ir.ui.view,arch_db:odex_benefit.family_member_form
#: model_terms:ir.ui.view,arch_db:odex_benefit.grant_benefit_form
msgid "Final Suspension"
msgstr "الإيقاف النهائي"
#. module: odex_benefit
#: model_terms:ir.ui.view,arch_db:odex_benefit.family_member_form
#: model_terms:ir.ui.view,arch_db:odex_benefit.grant_benefit_form
msgid "Reject Resume"
msgstr "رفض الإعادة"
#. module: odex_benefit
#: model:ir.model.fields,field_description:odex_benefit.field_suspend_reason_wizard__resume_date
msgid "Resume Date"
msgstr "تاريخ الإعادة"
#. module: odex_benefit
#: code:addons/odex_benefit/wizards/suspend_reason_wizard.py:0
#, python-format
msgid "No family record found."
msgstr "لم يتم العثور على سجل الأسرة."
#. module: odex_benefit
#: code:addons/odex_benefit/wizards/suspend_reason_wizard.py:0
#, python-format
msgid "No member record found."
msgstr "لم يتم العثور على سجل الفرد."
#. module: odex_benefit
#: model_terms:ir.ui.view,arch_db:odex_benefit.view_resume_reason_wizard_form
msgid "Reason for return"
msgstr "سبب الإعادة"

View File

@ -608,6 +608,8 @@ class GrantBenefitProfile(models.Model):
('edit_info', 'Edit Information'),
('approved', 'Approved'),
('suspended', 'Suspended'),
('resume_from_temporary', 'Resume from Temporary Suspension'),
('resume_from_final', 'Resume from Final Suspension'),
('exception', 'Exception'),
], string='Action Type', default='new', tracking=True)
contact_type = fields.Selection([
@ -626,6 +628,11 @@ class GrantBenefitProfile(models.Model):
total_mother_families = fields.Integer(string="Mother Families", compute='_compute_total_families')
total_replacement_mother_families = fields.Integer(string="Replacement Mother Families", compute='_compute_total_families')
final_suspend_date = fields.Date(string="Final Suspend Date")
resume_reason_id = fields.Many2one('suspend.reason', string='Return Reason')
resume_date = fields.Date(string="Return Date")
resume_notes = fields.Text(string="Return Notes")
_sql_constraints = [
('unique_code', "unique (code) WHERE state NOT IN ('draft', 'new')", 'This code already exists')
@ -1683,10 +1690,28 @@ class GrantBenefitProfile(models.Model):
'target': 'new',
}
def action_resume_family(self):
ctx = dict(self.env.context or {})
ctx['resume_family'] = True
return {
'name': _('Resume Reason Wizard'),
'view_mode': 'form',
'view_type': 'form',
'type': 'ir.actions.act_window',
'res_model': 'suspend.reason.wizard',
'view_id': self.env.ref('odex_benefit.view_resume_reason_wizard_form').id,
'target': 'new',
'context': ctx,
}
def action_suspend_first_accept(self):
for rec in self:
rec.state = 'first_approve'
def action_resume_first_accept(self):
for rec in self:
rec.state = 'first_approve'
def action_suspend_second_accept(self):
for rec in self:
rec.action_type = 'suspended'
@ -1697,6 +1722,14 @@ class GrantBenefitProfile(models.Model):
else:
rec.state = 'suspended_second_approve'
def action_resume_second_accept(self):
for rec in self:
if rec.suspend_reason.need_service_manager_approval:
rec.state = 'family_services_manager'
else:
rec.state = 'second_approve'
rec.action_type = 'approved'
def action_suspend_third_accept(self):
for rec in self:
if rec.suspend_reason.suspend_type == 'temporarily_suspend':
@ -1704,6 +1737,22 @@ class GrantBenefitProfile(models.Model):
else:
rec.state = 'suspended_second_approve'
def action_resume_third_accept(self):
for rec in self:
rec.state = 'second_approve'
rec.action_type = 'approved'
def action_final_suspend(self):
today = fields.Date.today()
for rec in self:
if rec.final_suspend_date and today >= rec.final_suspend_date:
rec.write({
'state': 'suspended_second_approve',
'suspend_type': 'suspend',
})
else:
raise UserError(_("Final suspension cannot be executed until after the specified final suspension date."))
def action_auto_suspend(self):
# Fetch grants in second approval state that are not excluded from suspension
grants = self.env["grant.benefit"].search(
@ -1743,6 +1792,14 @@ class GrantBenefitProfile(models.Model):
rec.action_type = 'approved'
rec.get_member_income()
def action_reject_resume(self):
for rec in self:
if rec.action_type == 'resume_from_temporary':
rec.state = 'temporary_suspended'
elif rec.action_type == 'resume_from_final':
rec.state = 'suspended_second_approve'
rec.action_type = 'suspended'
#Excption Work flow
def action_exception(self):
return {

View File

@ -723,6 +723,7 @@ class SuspendReason(models.Model):
is_stop_reason = fields.Boolean(string="Stop Reason",default=False)
is_reject_reason = fields.Boolean(string="Reject Reason",default=False)
is_return_reason = fields.Boolean(string="Return Reason",default=False)
is_resume_reason = fields.Boolean(string="Resume Reason", default=False)
is_family_return_reason = fields.Boolean(string="Family Return Reason",default=False)
is_incomplete_visit_reason = fields.Boolean(string="Incomplete Visit Reason",default=False)
active = fields.Boolean(default=True)

View File

@ -239,6 +239,8 @@ class FamilyMemberProfile(models.Model):
('edit_info', 'Edit Information'),
('approved', 'Approved'),
('suspended', 'Suspended'),
('resume_from_temporary', 'Resume from Temporary Suspension'),
('resume_from_final', 'Resume from Final Suspension'),
('exception', 'Exception'),
], string='Action Type', default='new', tracking=True)
member_status = fields.Selection(selection=[
@ -276,6 +278,9 @@ class FamilyMemberProfile(models.Model):
non_benefit_reason = fields.Text(string="Non Benefit Reason", tracking=True)
final_suspend_date = fields.Date(string="Final Suspend Date")
active = fields.Boolean(string='Active', default=True)
resume_reason_id = fields.Many2one('suspend.reason', string='Return Reason')
resume_date = fields.Date(string="Return Date")
resume_notes = fields.Text(string="Return Notes")
# def create(self, vals):
# for line_vals in vals:
@ -828,10 +833,39 @@ class FamilyMemberProfile(models.Model):
'target': 'new',
}
def action_resume_member(self):
ctx = dict(self.env.context or {})
ctx['resume_family'] = True
return {
'name': _('Resume Reason Wizard'),
'view_mode': 'form',
'view_type': 'form',
'type': 'ir.actions.act_window',
'res_model': 'suspend.reason.wizard',
'view_id': self.env.ref('odex_benefit.view_resume_reason_wizard_form').id,
'target': 'new',
'context': ctx,
}
def action_final_suspend(self):
today = fields.Date.today()
for rec in self:
if rec.final_suspend_date and today >= rec.final_suspend_date:
rec.write({
'state': 'suspended_second_approve',
'suspend_type': 'suspend',
})
else:
raise UserError(_("Final suspension cannot be executed until after the specified final suspension date."))
def action_suspend_first_accept(self):
for rec in self:
rec.state_a = 'first_approve'
def action_resume_first_accept(self):
for rec in self:
rec.state_a = 'first_approve'
def action_suspend_second_accept(self):
for rec in self:
if rec.suspend_reason.need_service_manager_approval:
@ -841,6 +875,14 @@ class FamilyMemberProfile(models.Model):
else:
rec.state_a = 'suspended_second_approve'
def action_resume_second_accept(self):
for rec in self:
if rec.suspend_reason.need_service_manager_approval:
rec.state_a = 'family_services_manager'
else:
rec.state_a = 'second_approve'
rec.action_type = 'approved'
def action_suspend_third_accept(self):
for rec in self:
if rec.suspend_reason.suspend_type == 'temporarily_suspend':
@ -848,11 +890,24 @@ class FamilyMemberProfile(models.Model):
else:
rec.state_a = 'suspended_second_approve'
def action_resume_third_accept(self):
for rec in self:
rec.state_a = 'second_approve'
rec.action_type = 'approved'
def action_suspend_refuse(self):
for rec in self:
rec.state_a = 'second_approve'
rec.is_member_workflow = False
def action_reject_resume(self):
for rec in self:
if rec.action_type == 'resume_from_temporary':
rec.state = 'temporary_suspended'
elif rec.action_type == 'resume_from_final':
rec.state = 'suspended_second_approve'
rec.action_type = 'suspended'
# Excption Work flow
def action_exception(self):
for rec in self:

View File

@ -247,7 +247,7 @@ class SeasonalService(models.Model):
'price_unit': request.requested_service_amount,
})
line_ids.append(invoice_line)
vendor_bill = self.env['account.move'].create({
vendor_bill = self.env['account.move'].sudo().create({
'move_type': 'in_invoice',
'partner_id': rec.service_type_id.service_producer_id.id,
'journal_id': validation_setting.journal_id.id,

View File

@ -943,10 +943,11 @@
<group>
<group>
<field name="is_stop_reason" widget="boolean_toggle"/>
<field name="is_resume_reason" widget="boolean_toggle"/>
<field name="need_service_manager_approval" widget="boolean_toggle"
attrs="{'invisible': [('is_stop_reason','=',False)]}"/>
<field name="entity_type"
attrs="{'invisible': [('is_stop_reason','=',False)]}"/>
attrs="{'invisible': [('is_stop_reason','=',False),('is_resume_reason','=',False)]}"/>
<field name="suspend_type"
attrs="{'invisible': [('is_stop_reason','=',False)]}"/>
<field name="days_before_final_suspend"
@ -974,6 +975,7 @@
<field name="is_reject_reason" widget="boolean_toggle"/>
<field name="is_return_reason" widget="boolean_toggle"/>
<field name="is_family_return_reason" widget="boolean_toggle"/>
<field name="is_resume_reason" widget="boolean_toggle"/>
<field name="is_incomplete_visit_reason" widget="boolean_toggle"/>
<field name="allow_service" widget="boolean_toggle"/>
</tree>

View File

@ -431,6 +431,32 @@
string="Third Approve" class="oe_highlight"
groups="odex_benefit.group_benefit_manager"
attrs="{'invisible': ['|',('action_type','!=','suspended'),('state', 'not in', ['family_services_manager'])]}"/>
<!-- Resume from suspension -->
<button name="action_resume_first_accept" type="object"
string="Resume Approval by Operations Head" class="oe_highlight"
attrs="{'invisible': ['|',('action_type','not in',['resume_from_final','resume_from_temporary']),('state', 'not in', ['waiting_approve'])]}"
groups="odex_benefit.group_benefit_woman_commitee,odex_benefit.group_benefit_manager"
/>
<button name="action_resume_second_accept" type="object"
string="Resume Approval by Branch Manager" class="oe_highlight"
groups="odex_benefit.group_benefit_branch_manager,odex_benefit.group_benefit_manager"
attrs="{'invisible': ['|',('action_type','not in',['resume_from_final','resume_from_temporary']),('state', 'not in', ['first_approve'])]}"/>
<button name="action_resume_third_accept" type="object"
string="Resume Approval by Family Services Manager" class="oe_highlight"
groups="odex_benefit.group_benefit_manager"
attrs="{'invisible': ['|',('action_type','not in',['resume_from_final','resume_from_temporary']),('state', 'not in', ['family_services_manager'])]}"/>
<button name="action_resume_family" string="Resume Family Service"
type="object" class="btn btn-success"
attrs="{'invisible': [('state', 'not in', ['temporary_suspended', 'suspended_second_approve'])]}"
groups="odex_benefit.group_benefit_researcher"/>
<button name="action_final_suspend" type="object"
string="Final Suspension" class="btn btn-danger"
attrs="{'invisible': [('state', '!=', 'temporary_suspended')]}"
groups="odex_benefit.group_benefit_manager"/>
<button name="action_reject_resume" type="object"
string="Reject Resume" class="oe_highlight"
attrs="{'invisible': ['|',('action_type','not in',['resume_from_final','resume_from_temporary']),('state', 'not in', ['waiting_approve','first_approve','family_services_manager'])]}"
/>
<button name="action_suspend_refuse" type="object"
string="Suspend Refuse" class="oe_highlight"
attrs="{'invisible': ['|',('action_type','!=','suspended'),('state', 'not in', ['waiting_approve','first_approve','family_services_manager','suspended_second_approve'])]}"
@ -539,6 +565,10 @@
attrs="{'invisible': [('action_type', '!=', 'suspended')]}"/>
<widget name="web_ribbon" title="Exception" bg_color="bg-secondary"
attrs="{'invisible': [('action_type', '!=', 'exception')]}"/>
<widget name="web_ribbon" title="Resume from Temporary Suspension" bg_color="bg-warning"
attrs="{'invisible': [('action_type', '!=', 'resume_from_temporary')]}"/>
<widget name="web_ribbon" title="Resume from Final Suspension" bg_color="bg-warning"
attrs="{'invisible': [('action_type', '!=', 'resume_from_final')]}"/>
<div class="oe_title">
<h1>
<field name="code" readonly="1" class="oe_inline"/>
@ -883,7 +913,8 @@
<field name="note"/>
<field name="currency_id" invisible="1"/>
<field name="state" invisible="1"/>
<field name="deduct_from_family_income" string="Deduct from Mother Income" widget="boolean_toggle"/>
<field name="deduct_from_family_income"
string="Deduct from Mother Income" widget="boolean_toggle"/>
</tree>
</field>
</page>
@ -918,7 +949,8 @@
<field name="mother_benefit_id" invisible="1"/>
<field name="loan_start_date"/>
<field name="loan_end_date"/>
<field name="deduct_from_family_income" string="Deduct from Mother Income"
<field name="deduct_from_family_income"
string="Deduct from Mother Income"
widget="boolean_toggle"/>
</group>
</group>
@ -933,7 +965,8 @@
<field name="currency_id" invisible="1"/>
<field name="state" invisible="1"/>
<field name="loan_attach" widget="binary"/>
<field name="deduct_from_family_income" string="Deduct from Mother Income" widget="boolean_toggle"/>
<field name="deduct_from_family_income"
string="Deduct from Mother Income" widget="boolean_toggle"/>
</tree>
</field>
</page>
@ -1770,9 +1803,9 @@
</group>
</page>
<page string="Suspend Reason"
attrs="{'invisible': [('action_type','not in',['suspended','exception'])]}"
attrs="{'invisible': [('action_type','not in',['suspended','exception','resume_from_temporary','resume_from_final'])]}"
>
<group>
<group string="Suspend">
<group>
<field name="suspend_reason"
options="{'no_create': True, 'no_create_edit': True,'no_quick_create': True, 'no_open': True}"/>
@ -1785,6 +1818,16 @@
<field name="suspend_method" readonly="1" force_save="1"/>
</group>
</group>
<group string="Resume">
<group >
<field name="resume_reason_id"
options="{'no_create': True, 'no_create_edit': True,'no_quick_create': True, 'no_open': True}"/>
<field name="resume_date"/>
</group>
<group>
<field name="resume_notes"/>
</group>
</group>
</page>
<page string="Exception"
attrs="{'invisible': [('action_type', 'not in', ['exception']),('is_excluded_suspension','=',False)]}">

View File

@ -23,6 +23,31 @@
string="Third Approve" class="oe_highlight"
groups="odex_benefit.group_benefit_manager"
attrs="{'invisible': ['|',('action_type','!=','suspended'),('state', 'not in', ['family_services_manager'])]}"/>
<button name="action_resume_first_accept" type="object"
string="Resume Approval by Operations Head" class="oe_highlight"
attrs="{'invisible': ['|',('action_type','not in',['resume_from_final','resume_from_temporary']),('state', 'not in', ['waiting_approve'])]}"
groups="odex_benefit.group_benefit_woman_commitee,odex_benefit.group_benefit_manager"
/>
<button name="action_resume_second_accept" type="object"
string="Resume Approval by Branch Manager" class="oe_highlight"
groups="odex_benefit.group_benefit_branch_manager,odex_benefit.group_benefit_manager"
attrs="{'invisible': ['|',('action_type','not in',['resume_from_final','resume_from_temporary']),('state', 'not in', ['first_approve'])]}"/>
<button name="action_resume_third_accept" type="object"
string="Resume Approval by Family Services Manager" class="oe_highlight"
groups="odex_benefit.group_benefit_manager"
attrs="{'invisible': ['|',('action_type','not in',['resume_from_final','resume_from_temporary']),('state', 'not in', ['family_services_manager'])]}"/>
<button name="action_resume_member" string="Resume Family Service"
type="object" class="btn btn-success"
attrs="{'invisible': [('state', 'not in', ['temporary_suspended', 'suspended_second_approve'])]}"
groups="odex_benefit.group_benefit_researcher"/>
<button name="action_final_suspend" type="object"
string="Final Suspension" class="btn btn-danger"
attrs="{'invisible': [('state', '!=', 'temporary_suspended')]}"
groups="odex_benefit.group_benefit_manager"/>
<button name="action_reject_resume" type="object"
string="Reject Resume" class="oe_highlight"
attrs="{'invisible': ['|',('action_type','not in',['resume_from_final','resume_from_temporary']),('state', 'not in', ['waiting_approve','first_approve','family_services_manager'])]}"
/>
<button name="action_suspend_refuse" type="object"
string="Suspend Refuse" class="oe_highlight"
attrs="{'invisible': ['|',('action_type','!=','suspended'),('state', 'not in', ['waiting_approve','first_approve','family_services_manager','suspended_second_approve'])]}"
@ -238,8 +263,8 @@
</field>
</page>
<page string="Suspend Reason"
attrs="{'invisible': [('action_type','not in',['suspended','exception'])]}">
<group>
attrs="{'invisible': [('action_type','not in',['suspended','exception','resume_from_temporary','resume_from_final'])]}">
<group string="Suspend">
<group>
<field name="suspend_reason"/>
<field name="suspend_description"/>
@ -251,6 +276,16 @@
<field name="suspend_method" readonly="1" force_save="1"/>
</group>
</group>
<group string="Resume">
<group >
<field name="resume_reason_id"
options="{'no_create': True, 'no_create_edit': True,'no_quick_create': True, 'no_open': True}"/>
<field name="resume_date"/>
</group>
<group>
<field name="resume_notes"/>
</group>
</group>
</page>
<page string="Exception"
attrs="{'invisible': [('action_type','not in',['exception'])]}">

View File

@ -4,6 +4,7 @@ from odoo import models, fields, _, api
from odoo.exceptions import UserError
from datetime import datetime, timedelta
class SuspendReasonWizard(models.TransientModel):
_name = 'suspend.reason.wizard'
@ -25,8 +26,9 @@ class SuspendReasonWizard(models.TransientModel):
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_attachment = fields.Binary(string='Suspend Attachment', attachment=True)
final_suspend_date = fields.Date(string="Final Suspend Date", default=fields.Date.context_today)
resume_date = fields.Date(string="Resume Date", default=fields.Date.today)
@api.onchange('suspend_reason')
def _onchange_compute_final_suspend_date(self):
@ -37,11 +39,17 @@ class SuspendReasonWizard(models.TransientModel):
self.final_suspend_date = fields.Date.context_today(self)
def _get_suspend_reason_domain(self):
domain = [('is_stop_reason', '=', True)]
domain = []
if self._context.get('resume_family'):
domain.append(('is_resume_reason', '=', True))
else:
domain.append(('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):
@ -65,14 +73,32 @@ class SuspendReasonWizard(models.TransientModel):
def action_submit(self):
for rec in self:
rec.entity_id.member_ids.write({
benefit = rec.entity_id
if not benefit:
raise UserError(_("No family record found."))
if self._context.get('resume_family'):
action_type = ('resume_from_temporary'
if benefit.state == 'temporary_suspended'
else 'resume_from_final')
vals = {
'state': 'waiting_approve',
'action_type': action_type,
'resume_reason_id': rec.suspend_reason.id,
'resume_date': rec.resume_date,
'resume_notes': rec.suspend_description,
}
else:
benefit.member_ids.write({
'is_excluded_suspension': False,
'is_member_workflow': False,
'final_suspend_date': rec.final_suspend_date,
})
if rec.suspend_attachment:
attachment = rec._create_attachment_record_from_binary()
rec.entity_id.suspend_attachment = [(4, attachment.id)]
rec.entity_id.write({
benefit.suspend_attachment = [(4, attachment.id)]
vals = {
'state': 'waiting_approve',
'action_type': 'suspended',
'suspend_reason': rec.suspend_reason.id,
@ -81,11 +107,29 @@ class SuspendReasonWizard(models.TransientModel):
'suspend_method': 'manual',
'final_suspend_date': rec.final_suspend_date,
'is_excluded_suspension': False,
})
}
benefit.write(vals)
def action_member_submit(self):
for rec in self:
rec.member_id.write({
member = rec.member_id
if not member:
raise UserError(_("No member record found."))
if self._context.get('resume_family'):
action_type = ('resume_from_temporary'
if member.state == 'temporary_suspended'
else 'resume_from_final')
vals = {
'state_a': 'waiting_approve',
'action_type': action_type,
'resume_reason_id': rec.suspend_reason.id,
'resume_date': rec.resume_date,
'resume_notes': rec.suspend_description,
}
else:
vals = {
'state_a': 'waiting_approve',
'action_type': 'suspended',
'suspend_reason': rec.suspend_reason.id,
@ -95,6 +139,9 @@ class SuspendReasonWizard(models.TransientModel):
'final_suspend_date': rec.final_suspend_date,
'is_member_workflow': True,
'is_excluded_suspension': False,
})
}
if rec.suspend_attachment:
attachment = rec._create_attachment_record_from_binary()
rec.member_id.suspend_attachment = [(4, attachment.id)]
member.suspend_attachment = [(4, attachment.id)]
member.write(vals)

View File

@ -13,7 +13,7 @@
<field name="suspend_description"/>
</group>
<group>
<field name="suspend_attachment"/>
<field name="suspend_attachment" required="1"/>
<field name="final_suspend_date" readonly="1" force_save="1"/>
</group>
</group>
@ -39,7 +39,7 @@
<field name="suspend_description"/>
</group>
<group>
<field name="suspend_attachment"/>
<field name="suspend_attachment" required="1"/>
<field name="final_suspend_date" readonly="1" force_save="1"/>
</group>
</group>
@ -50,6 +50,35 @@
</footer>
</sheet>
</form>
</field>
</record>
<record id="view_resume_reason_wizard_form" model="ir.ui.view">
<field name="name">resume.reason.wizard.form</field>
<field name="model">suspend.reason.wizard</field>
<field name="arch" type="xml">
<form>
<sheet>
<group>
<group>
<field name="suspend_reason" string="Reason for return"/>
<field name="suspend_description" string="Notes"/>
</group>
<group>
<field name="resume_date" required="1"/>
</group>
</group>
<footer>
<button name="action_submit"
invisible="not context.get('active_model') == 'grant.benefit'" type="object"
string="Submit" class="oe_highlight"/>
<button name="action_member_submit"
invisible="not context.get('active_model') == 'family.member'" type="object"
string="Submit" class="oe_highlight"/>
or
<button special="cancel" string="Cancel"/>
</footer>
</sheet>
</form>
</field>
</record>