[UPD] odex_takaful
This commit is contained in:
parent
0b5a6552b7
commit
d00864166a
|
|
@ -83,6 +83,7 @@
|
||||||
'views/product_views.xml',
|
'views/product_views.xml',
|
||||||
'views/payment_machine_views.xml',
|
'views/payment_machine_views.xml',
|
||||||
'views/takaful_menus_actions.xml',
|
'views/takaful_menus_actions.xml',
|
||||||
|
'views/benefit_category_views.xml',
|
||||||
'data/message_template_data.xml',
|
'data/message_template_data.xml',
|
||||||
|
|
||||||
'wizards/transfer_deduction_wizard_views.xml',
|
'wizards/transfer_deduction_wizard_views.xml',
|
||||||
|
|
|
||||||
|
|
@ -81,6 +81,22 @@
|
||||||
<field name="active" eval="True"/>
|
<field name="active" eval="True"/>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
<!-- Scheduler for Closing Active Sponsorships that have exceed the end date -->
|
||||||
|
<record id="scheduler_process_closing_sponsorship_action" forcecreate='True' model="ir.cron">
|
||||||
|
<field name="name">Process Closing Active Sponsorships</field>
|
||||||
|
<field name="user_id" ref="base.user_root"/>
|
||||||
|
<field name="interval_number">1</field>
|
||||||
|
<field name="interval_type">days</field>
|
||||||
|
<field name="nextcall" eval="(DateTime.now() + timedelta(days=1)).strftime('%Y-%m-%d 03:00:00')"/>
|
||||||
|
<field name="numbercall">-1</field>
|
||||||
|
<field name="doall" eval="False"/>
|
||||||
|
<field name="model_id" ref="model_donations_details_lines"/>
|
||||||
|
<field name="state">code</field>
|
||||||
|
<field name="code">model.cron_process_closing_ended_sponsorships()</field>
|
||||||
|
<field name="priority" eval="1"/>
|
||||||
|
<field name="active" eval="True"/>
|
||||||
|
</record>
|
||||||
|
|
||||||
<record id="ir_cron_family_member_restriction" model="ir.cron">
|
<record id="ir_cron_family_member_restriction" model="ir.cron">
|
||||||
<field name="name">Family Member Restriction</field>
|
<field name="name">Family Member Restriction</field>
|
||||||
<field name="model_id" ref="odex_benefit.model_family_member"/>
|
<field name="model_id" ref="odex_benefit.model_family_member"/>
|
||||||
|
|
|
||||||
|
|
@ -29,3 +29,5 @@ from . import family_member
|
||||||
from . import sponsorship_scheduling_line
|
from . import sponsorship_scheduling_line
|
||||||
from . import donation_replacement_log
|
from . import donation_replacement_log
|
||||||
from . import payment_machine
|
from . import payment_machine
|
||||||
|
|
||||||
|
from . import benefit_category
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
from odoo import models, fields
|
||||||
|
|
||||||
|
|
||||||
|
class BenefitCategory(models.Model):
|
||||||
|
_inherit = 'benefit.category'
|
||||||
|
|
||||||
|
allowed_sponsorship = fields.Boolean()
|
||||||
|
|
@ -352,11 +352,10 @@ class DonationsDetailsLines(models.Model):
|
||||||
for rec in self:
|
for rec in self:
|
||||||
show_extend_button = (
|
show_extend_button = (
|
||||||
rec.record_type == 'sponsorship' and
|
rec.record_type == 'sponsorship' and
|
||||||
rec.sponsorship_duration != "permanent" and
|
rec.sponsorship_duration == 'temporary' and
|
||||||
rec.end_date and
|
rec.end_date and
|
||||||
rec.end_date >= today and
|
rec.end_date >= today and
|
||||||
rec.state == 'active'
|
rec.state in ['active', 'replace']
|
||||||
and rec.sponsorship_id.state not in ['canceled' , 'closed']
|
|
||||||
)
|
)
|
||||||
rec.show_extend_button = show_extend_button
|
rec.show_extend_button = show_extend_button
|
||||||
|
|
||||||
|
|
@ -1250,6 +1249,21 @@ class DonationsDetailsLines(models.Model):
|
||||||
self.product_template_id._quantity = 0
|
self.product_template_id._quantity = 0
|
||||||
return super().unlink()
|
return super().unlink()
|
||||||
|
|
||||||
|
@api.model
|
||||||
|
def cron_process_closing_ended_sponsorships(self):
|
||||||
|
records = self.search([
|
||||||
|
'record_type', '=', 'sponsorship',
|
||||||
|
'sponsorship_duration', '=', 'temporary',
|
||||||
|
'state', 'in', ['active', 'replace'],
|
||||||
|
'end_date', '<', fields.Date.today()
|
||||||
|
])
|
||||||
|
|
||||||
|
for record in records:
|
||||||
|
record.state = 'closed'
|
||||||
|
for benefit_id in record.benefit_ids:
|
||||||
|
benefit_id.kafala_status = 'have_not_kafala'
|
||||||
|
benefit_id.sponsor_related_id = False
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def cron_send_direct_debit_end_date_reminders(self):
|
def cron_send_direct_debit_end_date_reminders(self):
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,8 @@ class FamilyMember(models.Model):
|
||||||
compute='_compute_benefit_group',
|
compute='_compute_benefit_group',
|
||||||
store=True
|
store=True
|
||||||
)
|
)
|
||||||
|
allowed_sponsorship = fields.Boolean(related='benefit_id.benefit_category_id.allowed_sponsorship')
|
||||||
|
|
||||||
|
|
||||||
def name_get(self):
|
def name_get(self):
|
||||||
result = []
|
result = []
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<odoo>
|
||||||
|
|
||||||
|
<record id="view_benefit_category_form_odex_benefit" model="ir.ui.view">
|
||||||
|
<field name="name">benefit.category.view.form.inherit</field>
|
||||||
|
<field name="model">benefit.category</field>
|
||||||
|
<field name="inherit_id" ref="odex_benefit.view_benefit_category_form"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
|
||||||
|
<xpath expr="//field[@name='is_benefit']" position="after">
|
||||||
|
<field name="allowed_sponsorship" widget="boolean_toggle"/>
|
||||||
|
</xpath>
|
||||||
|
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="view_benefit_category_tree_odex_benefit" model="ir.ui.view">
|
||||||
|
<field name="name">benefit.category.view.tree.inherit</field>
|
||||||
|
<field name="model">benefit.category</field>
|
||||||
|
<field name="inherit_id" ref="odex_benefit.view_benefit_category_tree"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
|
||||||
|
<xpath expr="//field[@name='is_benefit']" position="after">
|
||||||
|
<field name="allowed_sponsorship" widget="boolean_toggle"/>
|
||||||
|
</xpath>
|
||||||
|
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
</odoo>
|
||||||
|
|
@ -676,7 +676,7 @@
|
||||||
<page string="Orphans and Widows List"
|
<page string="Orphans and Widows List"
|
||||||
attrs="{'invisible': ['|',('sponsorship_type', '!=', 'group'), ('hide_beneficiary_group', '=', True)]}">
|
attrs="{'invisible': ['|',('sponsorship_type', '!=', 'group'), ('hide_beneficiary_group', '=', True)]}">
|
||||||
<!-- attrs="{'invisible': ['|', '|', '|', ('hide_beneficiary_group','=', True), ('parent.record_type','!=','sponsorship'), ('sponsorship_type', '!=', 'group'), ('benefit_type', '!=', 'both')]}">-->
|
<!-- attrs="{'invisible': ['|', '|', '|', ('hide_beneficiary_group','=', True), ('parent.record_type','!=','sponsorship'), ('sponsorship_type', '!=', 'group'), ('benefit_type', '!=', 'both')]}">-->
|
||||||
<field name="benefit_ids" nolabel="1" options="{'no_create': True}" context="{'group_by': 'benefit_group', 'members_domain_force_all': True}">
|
<field name="benefit_ids" nolabel="1" options="{'no_create': True}" domain="[('allowed_sponsorship', '=', True)]" context="{'group_by': 'benefit_group', 'members_domain_force_all': True}">
|
||||||
<tree editable="bottom">
|
<tree editable="bottom">
|
||||||
<field name="benefit_group" invisible="1"/>
|
<field name="benefit_group" invisible="1"/>
|
||||||
<field name="name"/>
|
<field name="name"/>
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,10 @@
|
||||||
<field name="members_domain_ids" invisible="1"/>
|
<field name="members_domain_ids" invisible="1"/>
|
||||||
<group>
|
<group>
|
||||||
<group string="Benefit Information">
|
<group string="Benefit Information">
|
||||||
<field name="benefit_id" context="{'group_by': 'benefit_group', 'show_age_in_kafalat': True}" options="{'no_create': True, 'no_create_edit':True,'no_open': True}"/>
|
<field name="benefit_id"
|
||||||
|
context="{'group_by': 'benefit_group', 'show_age_in_kafalat': True}"
|
||||||
|
options="{'no_create': True, 'no_create_edit':True,'no_open': True}"
|
||||||
|
domain="[('allowed_sponsorship', '=', True)]"/>
|
||||||
</group>
|
</group>
|
||||||
</group>
|
</group>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -69,13 +69,12 @@ class DonationExtensionWizard(models.TransientModel):
|
||||||
extension_line_ids = [(5,)]
|
extension_line_ids = [(5,)]
|
||||||
donation_detail_ids = self.env['donations.details.lines'].browse(self.env.context.get('donation_detail_ids'))
|
donation_detail_ids = self.env['donations.details.lines'].browse(self.env.context.get('donation_detail_ids'))
|
||||||
for line in donation_detail_ids:
|
for line in donation_detail_ids:
|
||||||
line_ref = line.sequence_no or str(line.id)
|
if line.record_type == 'donation' or line.sponsorship_duration == 'permanent':
|
||||||
if not (line.record_type == 'donation' and line.direct_debit) and line.record_type != 'sponsorship':
|
raise ValidationError(_("Only donation with direct debit or sponsorship can be extended. Line: %s") % line.name)
|
||||||
raise ValidationError(_("Only donation with direct debit or sponsorship can be extended. Line: {}").format(line_ref))
|
|
||||||
if line.end_date and line.end_date < fields.Date.context_today(line):
|
if line.end_date and line.end_date < fields.Date.context_today(line):
|
||||||
raise ValidationError(_("Only active donations with end date in the future can be extended. Line: {}").format(line_ref))
|
raise ValidationError(_("Only active donations with end date in the future can be extended. Line: %s") % line.name)
|
||||||
if line.state != 'active':
|
if line.state not in ['active', 'replace']:
|
||||||
raise ValidationError(_("Only active donations can be extended. Line: {}").format(line_ref))
|
raise ValidationError(_("Only active donations can be extended. Line: %s") % line.name)
|
||||||
extension_line_ids.append((0, 0, {
|
extension_line_ids.append((0, 0, {
|
||||||
'donation_line_id': line.id,
|
'donation_line_id': line.id,
|
||||||
'current_end_date': line.end_date,
|
'current_end_date': line.end_date,
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,11 @@
|
||||||
<group>
|
<group>
|
||||||
<group string="Replacement Information">
|
<group string="Replacement Information">
|
||||||
<field name="old_members_id" attrs="{'invisible': [('record_type', '=', 'donation')]}"/>
|
<field name="old_members_id" attrs="{'invisible': [('record_type', '=', 'donation')]}"/>
|
||||||
<field name="new_members_id" attrs="{'invisible': [('record_type', '=', 'donation')], 'required': [('record_type', '=', 'sponsorship')]}" options="{'no_create': True, 'no_create_edit':True,'no_open': True}" context="{'group_by': 'benefit_group', 'show_age_in_kafalat': True}"/>
|
<field name="new_members_id"
|
||||||
|
attrs="{'invisible': [('record_type', '=', 'donation')], 'required': [('record_type', '=', 'sponsorship')]}"
|
||||||
|
options="{'no_create': True, 'no_create_edit':True,'no_open': True}"
|
||||||
|
context="{'group_by': 'benefit_group', 'show_age_in_kafalat': True}"
|
||||||
|
domain="[('allowed_sponsorship', '=', True)]"/>
|
||||||
</group>
|
</group>
|
||||||
</group>
|
</group>
|
||||||
<group string="Replacement Reason">
|
<group string="Replacement Reason">
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue