diff --git a/odex25_ensan/odex_benefit/i18n/ar_001.po b/odex25_ensan/odex_benefit/i18n/ar_001.po
index 565a190fd..6a2ecdff3 100644
--- a/odex25_ensan/odex_benefit/i18n/ar_001.po
+++ b/odex25_ensan/odex_benefit/i18n/ar_001.po
@@ -1475,7 +1475,7 @@ msgstr "موافقة"
#. module: odex_benefit
#: model:ir.model.fields,field_description:odex_benefit.field_grant_benefit__approve_date
msgid "Approve Date"
-msgstr "تاريخ الموافقة"
+msgstr "تاريخ اعتماد الملف"
#. module: odex_benefit
#: model:ir.model.fields.selection,name:odex_benefit.selection__benefit_sms_configuration__state__approve_family
@@ -2685,7 +2685,6 @@ msgstr "المرتد"
#: model:ir.model.fields,field_description:odex_benefit.field_changes_requests__researcher_branch_id
#: model:ir.model.fields,field_description:odex_benefit.field_committees_line__branch_custom_id
#: model:ir.model.fields,field_description:odex_benefit.field_confirm_benefit_expense__branch_custom_id
-#: model:ir.model.fields,field_description:odex_benefit.field_grant_benefit__branch_custom_id
#: model:ir.model.fields,field_description:odex_benefit.field_res_districts__branch_custom_id
#: model:ir.model.fields,field_description:odex_benefit.field_service_request__branch_custom_id
#: model_terms:ir.ui.view,arch_db:odex_benefit.grant_benefit_search
@@ -2693,6 +2692,12 @@ msgstr "المرتد"
msgid "Branch"
msgstr "الفرع"
+#. module: odex_benefit
+#: model:ir.model.fields,field_description:odex_benefit.field_grant_benefit__branch_custom_id
+#: model:ir.model.fields,field_description:odex_benefit.field_researcher_family_wizard__branch_custom_id
+msgid "Branch"
+msgstr "الفرع التشغيلي"
+
#. module: odex_benefit
#: model:res.groups,name:odex_benefit.group_benefit_branch_manager
msgid "Branch Manager"
@@ -3483,6 +3488,7 @@ msgid "Create the Relation"
msgstr "أنشاء ص قرابة"
#. module: odex_benefit
+#: model_terms:ir.actions.act_window,help:odex_benefit.service_request_account_action
#: model_terms:ir.actions.act_window,help:odex_benefit.service_request_action
msgid "Create the Service Request"
msgstr ""
@@ -4181,7 +4187,6 @@ msgstr "تاريخ التوصيل"
#. module: odex_benefit
#: model:ir.model,name:odex_benefit.model_hr_department
-#: model:ir.model.fields,field_description:odex_benefit.field_researcher_family_wizard__branch_custom_id
msgid "Department"
msgstr "القسم"
@@ -10559,8 +10564,10 @@ msgid "Services Attachments Settings"
msgstr "المستندات المطلوبة للخدمة"
#. module: odex_benefit
+#: model:ir.actions.act_window,name:odex_benefit.service_request_account_action
#: model:ir.actions.act_window,name:odex_benefit.service_request_action
#: model:ir.ui.menu,name:odex_benefit.services_requests_menu
+#: model:ir.ui.menu,name:odex_benefit.services_requests_account_menu
#: model_terms:ir.ui.view,arch_db:odex_benefit.seasonal_service_form_view
msgid "Services Requests"
msgstr "طلبات الخدمات"
@@ -16730,7 +16737,7 @@ msgstr "رقم الهوية %s موجود بالفعل في أسرة أخرى (
#. module: odex_benefit
#: model:ir.model.fields,field_description:odex_benefit.field_grant_benefit__branch_family_id
msgid "Family Branch"
-msgstr "فرع الأسرة"
+msgstr "الفرع الأساسي"
#. module: odex_benefit
#: model:ir.model.fields,field_description:odex_benefit.field_grant_benefit__branch_has_employees
@@ -17146,4 +17153,105 @@ msgstr "فاتورة العثيم"
#. module: odex_benefit
#: model_terms:ir.ui.view,arch_db:odex_benefit.view_confirm_benefit_expense_form
msgid "Payment Orders"
-msgstr "أوامر الصرف"
\ No newline at end of file
+msgstr "أوامر الصرف"
+
+#. module: odex_benefit
+#: model_terms:ir.ui.view,arch_db:odex_benefit.view_confirm_benefit_expense_form
+msgid "Othaim Line"
+msgstr "مصروف العثيم"
+
+#. module: odex_benefit
+#: model:ir.model.fields,field_description:odex_benefit.field_confirm_benefit_expense__othaim_line_ids
+msgid "Othaim Lines"
+msgstr "مصروف العثيم"
+
+#. module: odex_benefit
+#: model_terms:ir.ui.view,arch_db:odex_benefit.view_confirm_benefit_expense_form
+msgid ""
+"\n"
+" Total Othaim"
+msgstr ""
+"\n"
+" إجمالي العثيم"
+
+#. module: odex_benefit
+#: model_terms:ir.ui.view,arch_db:odex_benefit.view_confirm_benefit_expense_form
+msgid ""
+"\n"
+" Member Count (Othaim)"
+msgstr ""
+"\n"
+" إجمالي عدد الأفراد للعثيم"
+
+#. module: odex_benefit
+#: model_terms:ir.ui.view,arch_db:odex_benefit.view_confirm_benefit_expense_form
+msgid ""
+"\n"
+" Family Count (Othaim)"
+msgstr ""
+"\n"
+" إجمالي عدد الأسر للعثيم"
+
+#. module: odex_benefit
+#: model_terms:ir.ui.view,arch_db:odex_benefit.view_confirm_benefit_expense_form
+msgid ""
+"\n"
+" Family Count (Monthly Expense)\n"
+" "
+msgstr ""
+"\n"
+" إجمالي عدد الأسر للمصروف الشهري\n"
+" "
+
+#. module: odex_benefit
+#: model_terms:ir.ui.view,arch_db:odex_benefit.view_confirm_benefit_expense_form
+msgid ""
+"\n"
+" Member Count (Monthly Expense)\n"
+" "
+msgstr ""
+"\n"
+" إجمالي عدد الأفراد للمصروف الشهري\n"
+" "
+
+#. module: odex_benefit
+#: model_terms:ir.ui.view,arch_db:odex_benefit.view_confirm_benefit_expense_form
+msgid ""
+"\n"
+" Total Monthly Income\n"
+" "
+msgstr ""
+"\n"
+" إجمالي المصروف النقدي للأسر\n"
+" "
+
+#. module: odex_benefit
+#: model_terms:ir.ui.view,arch_db:odex_benefit.view_confirm_benefit_expense_form
+msgid ""
+"\n"
+" Total Monthly Meals\n"
+" "
+msgstr ""
+"\n"
+" إجمالي مصروف الغذاء للأسر\n"
+" "
+
+#. module: odex_benefit
+#: model_terms:ir.ui.view,arch_db:odex_benefit.view_confirm_benefit_expense_form
+msgid ""
+"\n"
+" Total Monthly Clothing\n"
+" "
+msgstr ""
+"\n"
+" إجمالي مصروف الكساء للأسر\n"
+" "
+
+#. module: odex_benefit
+#: model_terms:ir.ui.view,arch_db:odex_benefit.view_confirm_benefit_expense_form
+msgid ""
+"\n"
+" Total"
+msgstr ""
+"\n"
+" الإجمالي"
diff --git a/odex25_ensan/odex_benefit/models/benefit.py b/odex25_ensan/odex_benefit/models/benefit.py
index 9d4884a98..c43bbe1ea 100644
--- a/odex25_ensan/odex_benefit/models/benefit.py
+++ b/odex25_ensan/odex_benefit/models/benefit.py
@@ -1476,7 +1476,8 @@ class GrantBenefitProfile(models.Model):
rec.user_id.sudo().write({
'groups_id': [(4, self.env.ref('base.group_portal', False).id)],
})
- rec.approve_date = datetime.now()
+ if rec.action_type == 'new':
+ rec.approve_date = datetime.now()
self.sudo().send_approval_benefit_email()
partner_ids = []
for id in self.message_follower_ids.ids:
diff --git a/odex25_ensan/odex_benefit/models/family_expense.py b/odex25_ensan/odex_benefit/models/family_expense.py
index 3e36d2052..bffb50cc2 100644
--- a/odex25_ensan/odex_benefit/models/family_expense.py
+++ b/odex25_ensan/odex_benefit/models/family_expense.py
@@ -47,9 +47,12 @@ class ConfirmBenefitExpense(models.Model):
copy=False)
benefit_expense_line_ids = fields.One2many(comodel_name='benefit.expense.line', inverse_name='confirm_expense_id',
string='Benefit Expense Lines')
- cash_expense = fields.Boolean(string='Include Cash Expense', states={'confirm': [('readonly', True)]})
- meal_expense = fields.Boolean(string='Include Meal Expense', states={'confirm': [('readonly', True)]})
- cloth_expense = fields.Boolean(string='Include Clothing Expense', states={'confirm': [('readonly', True)]})
+ othaim_line_ids = fields.One2many(comodel_name='benefit.expense.line', inverse_name='confirm_expense_id',
+ string='Othaim Lines', domain=[('meal_card', '=', True)])
+ cash_expense = fields.Boolean(string='Include Cash Expense', default=True, states={'confirm': [('readonly', True)]})
+ meal_expense = fields.Boolean(string='Include Meal Expense', default=True, states={'confirm': [('readonly', True)]})
+ cloth_expense = fields.Boolean(string='Include Clothing Expense', default=True,
+ states={'confirm': [('readonly', True)]})
payment_order_id = fields.Many2one('payment.orders', string='Payment Order', ondelete="set null", copy=False)
move_id = fields.Many2one('account.move', ondelete='cascade')
available_payment_method_line_ids = fields.Many2many(comodel_name='account.payment.method.line')
@@ -61,7 +64,8 @@ class ConfirmBenefitExpense(models.Model):
family_monthly_othaime = fields.Float(string="Total Othaim", compute='_get_family_monthly_values', store=True)
family_monthly_total = fields.Float(string="Total", compute='_get_family_monthly_values', store=True)
branch_custom_ids = fields.Many2many(comodel_name='branch.settings', relation='confirm_benefit_expense_branch_rel',
- column1='expense_id', column2='branch_id', string="Branches")
+ column1='expense_id', column2='branch_id', string="Branches",
+ domain="[('has_employees', '=', True)]")
family_domain_ids = fields.Many2many(comodel_name='grant.benefit', compute='_compute_domain_ids')
company_id = fields.Many2one('res.company', default=lambda self: self.env.company)
currency_id = fields.Many2one(comodel_name='res.currency', string="Company Currency",
@@ -118,7 +122,7 @@ class ConfirmBenefitExpense(models.Model):
self.ensure_one()
for line in self.benefit_expense_line_ids:
family = line.family_id
- income, meals, clotting = 0, 0, 0
+ income, meals, clotting, othaim = 0, 0, 0, 0
if not family:
continue
monthly_meals = 0.0 if family.meal_card else family.family_monthly_meals
@@ -127,6 +131,7 @@ class ConfirmBenefitExpense(models.Model):
income = family.family_monthly_income
if self.meal_expense:
meals = monthly_meals
+ othaim = othaime
if self.cloth_expense:
clotting = family.family_monthly_clotting
vals = {
@@ -139,7 +144,7 @@ class ConfirmBenefitExpense(models.Model):
'family_monthly_income': income,
'family_monthly_meals': meals,
'family_monthly_clotting': clotting,
- 'family_monthly_othaime': othaime,
+ 'family_monthly_othaime': othaim,
}
line.write(vals)
@@ -152,7 +157,6 @@ class ConfirmBenefitExpense(models.Model):
if not families:
raise UserError(_("Please select at least one family to calculate."))
- # Todo ask awatif
if not rec.cash_expense and not rec.meal_expense and not rec.cloth_expense:
raise UserError(_("At least one expense type should be selected."))
@@ -239,25 +243,12 @@ class ConfirmBenefitExpense(models.Model):
rec.member_count_othaim = sum(othaim_lines.mapped('benefit_member_count'))
def action_assistant_manager(self):
- # Todo ask awatif
- # if self.expense_type != 'family_expense':
- # self.state = 'assistant_general_manager'
- # return
-
- disbursement_date = False
- # if not disbursement_date:
- last_expense = self.search(
- [("state", "=", "confirm"), ("end_date", "!=", False)],
- order="id desc",
- limit=1
- )
- if last_expense:
- disbursement_date = last_expense.end_date
-
- # Apply the disbursement date to all families
- if disbursement_date:
- for family in self.family_ids:
- family.last_disbursement_date = disbursement_date
+ for family in self.family_ids:
+ if self.end_date and family.last_disbursement_date:
+ if self.end_date > family.last_disbursement_date:
+ family.last_disbursement_date = self.end_date
+ else:
+ family.last_disbursement_date = self.end_date
self.state = 'assistant_general_manager'
diff --git a/odex25_ensan/odex_benefit/models/seasonal_service.py b/odex25_ensan/odex_benefit/models/seasonal_service.py
index a6858470a..ac8e4d140 100644
--- a/odex25_ensan/odex_benefit/models/seasonal_service.py
+++ b/odex25_ensan/odex_benefit/models/seasonal_service.py
@@ -18,7 +18,7 @@ class SeasonalService(models.Model):
string="Seasonal Service Type", required=True)
benefit_type = fields.Selection(string='Benefit Type', related='service_type_id.benefit_type')
branch_ids = fields.Many2many('branch.settings', 'service_branch_rel', 'service_id', 'branch_id', string='Branches',
- required=True)
+ required=True, domain="[('has_employees', '=', True)]")
family_category_ids = fields.Many2many(
'benefit.category',
'service_category_rel',
diff --git a/odex25_ensan/odex_benefit/models/service_request.py b/odex25_ensan/odex_benefit/models/service_request.py
index 66b122e87..b5e618822 100644
--- a/odex25_ensan/odex_benefit/models/service_request.py
+++ b/odex25_ensan/odex_benefit/models/service_request.py
@@ -890,6 +890,7 @@ class ServiceRequest(models.Model):
rec.service_max_amount = rec.service_cat.fatherless_member_amount
if rec.is_orphan:
rec.service_max_amount = rec.service_cat.orphan_member_amount
+ rec.requested_service_amount = rec.service_max_amount
if rec.member_age > rec.service_cat.max_age:
raise ValidationError(_("Member Age should be less than %s ") % rec.service_cat.max_age)
if rec.member_payroll > rec.service_cat.member_max_payroll:
diff --git a/odex25_ensan/odex_benefit/views/actions_and_menus.xml b/odex25_ensan/odex_benefit/views/actions_and_menus.xml
index 7b3f85bc4..143271655 100644
--- a/odex25_ensan/odex_benefit/views/actions_and_menus.xml
+++ b/odex25_ensan/odex_benefit/views/actions_and_menus.xml
@@ -546,6 +546,16 @@
+
+ Services Requests
+ service.request
+ tree,form
+ [('is_seasonal','=',False),('state','=','accounting_approve'),('payment_order_state','=','none')]
+
+ Create the Service Request
+
+
+
Benefit Need
benefit.need
@@ -993,6 +1003,8 @@
parent="odex_benefit.benefit_tools_services_settings_menu" action="services_settings_action" groups="odex_benefit.group_benefit_manager"/>
+
diff --git a/odex25_ensan/odex_benefit/views/benefit_view.xml b/odex25_ensan/odex_benefit/views/benefit_view.xml
index bb901a2ec..ef84f1851 100644
--- a/odex25_ensan/odex_benefit/views/benefit_view.xml
+++ b/odex25_ensan/odex_benefit/views/benefit_view.xml
@@ -520,7 +520,7 @@
force_save="1"/>
+
@@ -1787,7 +1788,7 @@
-
+
diff --git a/odex25_ensan/odex_benefit/views/family_expense_view.xml b/odex25_ensan/odex_benefit/views/family_expense_view.xml
index 32c081c51..be9a0a598 100644
--- a/odex25_ensan/odex_benefit/views/family_expense_view.xml
+++ b/odex25_ensan/odex_benefit/views/family_expense_view.xml
@@ -9,10 +9,11 @@
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+ Family Count (Monthly Expense)
+
+
+
+
+
+
+
+
+
+
+
+ Member Count (Monthly Expense)
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Total Monthly Income
+
+
+
+
+
+
+
+
+
+
+
+ Total Monthly Meals
+
+
+
+
+
+
+
+
+
+
+
+ Total Monthly Clothing
+
+
+
+
+
+
+
+
+
+
+
+
@@ -183,6 +256,64 @@
+
+
+
+
+
+
+
+
+
+
+ Family Count (Othaim)
+
+
+
+
+
+
+
+
+
+
+ Member Count (Othaim)
+
+
+
+
+
+
+
+
+
+
+ Total Othaim
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/odex25_ensan/odex_benefit/wizards/researcher_wizard.py b/odex25_ensan/odex_benefit/wizards/researcher_wizard.py
index ae8716436..c131e0684 100644
--- a/odex25_ensan/odex_benefit/wizards/researcher_wizard.py
+++ b/odex25_ensan/odex_benefit/wizards/researcher_wizard.py
@@ -55,8 +55,10 @@ class ReasearcherFamilyWizard(models.TransientModel):
researcher_team = fields.Many2one("committees.line", string="Researcher Team",
domain="[('branch_custom_id', '=',branch_custom_id)]")
benefit_id = fields.Many2one("grant.benefit", string="Benefit", default=_default_benefit)
- branch_custom_id = fields.Many2one("branch.settings", string="Department", default=_default_branch_custom_id)
- branch_has_employees = fields.Boolean('Has Employees In branch',related="benefit_id.branch_has_employees")
+ branch_custom_id = fields.Many2one("branch.settings", string="Branch",
+ domain="[('has_employees', '=', True)]",
+ default=_default_branch_custom_id)
+ branch_has_employees = fields.Boolean('Has Employees In branch', related="benefit_id.branch_has_employees")
is_submitted = fields.Boolean(string="Submitted", default=False)
def submit_family(self):
@@ -65,7 +67,7 @@ class ReasearcherFamilyWizard(models.TransientModel):
'state': 'complete_info',
'contact_type': 'sms',
'researcher_id': rec.researcher_team.id,
- 'branch_custom_id':rec.branch_custom_id.id,
+ 'branch_custom_id': rec.branch_custom_id.id,
})
visit_record = self.env['visit.location'].create({
'benefit_id': rec.benefit_id.id,
@@ -80,7 +82,8 @@ class ReasearcherFamilyWizard(models.TransientModel):
rec._send_assignment_notification(visit_record)
specialist_name = rec.researcher_team.name or _('Not Specified')
visit_number = visit_record.name or str(visit_record.id)
- message = _('File has been assigned to specialist "%s" and initial visit created with number "%s"') % (specialist_name, visit_number)
+ message = _('File has been assigned to specialist "%s" and initial visit created with number "%s"') % (
+ specialist_name, visit_number)
return {
'type': 'ir.actions.client',
@@ -135,7 +138,8 @@ class ReasearcherFamilyWizard(models.TransientModel):
'email_to': specialist_user.work_email or specialist_user.email,
'email_cc': self.env.user.company_id.hr_email or self.env.user.company_id.email,
})
- template.with_context(lang=self.env.user.lang).send_mail(visit_record.id, force_send=True, raise_exception=False)
+ template.with_context(lang=self.env.user.lang).send_mail(visit_record.id, force_send=True,
+ raise_exception=False)
except Exception as e:
self._send_in_system_notification(specialist_user, visit_record)
diff --git a/odex25_ensan/odex_takaful/models/donation_details_lines.py b/odex25_ensan/odex_takaful/models/donation_details_lines.py
index ca9877efa..a270341c2 100644
--- a/odex25_ensan/odex_takaful/models/donation_details_lines.py
+++ b/odex25_ensan/odex_takaful/models/donation_details_lines.py
@@ -271,6 +271,12 @@ class DonationsDetailsLines(models.Model):
for rec in self:
rec.total_months_amount = rec.donation_amount * rec.payment_month_count
+ @api.onchange('sponsorship_duration')
+ def _onchange_sponsorship_duration(self):
+ for rec in self:
+ if rec.sponsorship_duration == "permanent":
+ rec.direct_debit = False
+
@api.onchange('product_template_id')
def _onchange_product_template_id(self):
for rec in self:
@@ -535,6 +541,7 @@ class DonationsDetailsLines(models.Model):
self._onchange_sponsorship_type()
return res
+
@api.onchange('donation_types', 'donation_type')
def _onchange_sponsorship_type(self):
for rec in self:
@@ -688,6 +695,16 @@ class DonationsDetailsLines(models.Model):
domain = expression.AND([domain, [
('age', '>=', benefit_age_limit)
]])
+ if rec.sponsorship_id or rec.sponsorship_mechanism_id:
+ all_benefit_ids = (
+
+ (
+ rec.sponsorship_mechanism_id.donations_details_lines_mechanism_ids if rec.sponsorship_mechanism_id else
+ self.env['donations.details.lines'])
+ )
+ selected_benefit_ids = all_benefit_ids.mapped('benefit_ids').ids
+ domain = expression.AND([domain, [('id', 'not in', selected_benefit_ids)]])
+
elif rec.record_type == 'donation' and rec.donation_mechanism == "with_conditions" and rec.family_id:
domain = [("benefit_id", "=", rec.family_id.id)]
members = self.env['family.member'].sudo().search(domain)
diff --git a/odex25_ensan/odex_takaful/security/ir.model.access.csv b/odex25_ensan/odex_takaful/security/ir.model.access.csv
index 9f7dfee61..2c2d827b1 100644
--- a/odex25_ensan/odex_takaful/security/ir.model.access.csv
+++ b/odex25_ensan/odex_takaful/security/ir.model.access.csv
@@ -49,7 +49,7 @@ access_donation_extension_wizard_line,donation.extension.wizard.line.access,mode
access_donation_replacement_log,donation.replacement.log.access,model_donation_replacement_log,odex_takaful.group_kufula_user,1,1,1,0
access_replace_sponsor_wizard,replace.sponsor.wizard.access,model_replace_sponsor_wizard,odex_takaful.group_replace_sponsor,1,1,1,1
access_add_benefit_wizard,add.benefit.wizard.access,model_add_benefit_wizard,odex_takaful.group_kufula_user,1,1,1,1
-
+access_extension_payment_wizard_line,extension.payment.wizard.line.access,model_extension_payment_wizard_line,odex_takaful.group_kufula_user,1,1,1,1
access_group_kufula_user_product_template,access_group_kufula_user_product_template,product.model_product_template,odex_takaful.group_kufula_user,1,1,0,0
access_group_kufula_user_account_move,access_group_kufula_user_account_move,account.model_account_move,odex_takaful.group_kufula_user,1,1,1,0
access_group_kufula_user_sale_order,access_group_kufula_user_sale_order,sale.model_sale_order,odex_takaful.group_kufula_user,1,1,1,0
diff --git a/odex25_ensan/odex_takaful/wizards/account_payment_register.py b/odex25_ensan/odex_takaful/wizards/account_payment_register.py
index f71841005..f3dab7a0f 100644
--- a/odex25_ensan/odex_takaful/wizards/account_payment_register.py
+++ b/odex25_ensan/odex_takaful/wizards/account_payment_register.py
@@ -50,7 +50,7 @@ class AccountRegisterPayment(models.TransientModel):
j_type = ""
if payment_method == "cash":
j_type = "cash"
- elif payment_method in ("bank", "check"):
+ elif payment_method in ("bank", "check","network"):
j_type = "bank"
if j_type:
return {"domain": {"journal_id": [("type", "=", j_type)]}}
diff --git a/odex25_ensan/odex_takaful/wizards/account_payment_register.xml b/odex25_ensan/odex_takaful/wizards/account_payment_register.xml
index 442efac7c..1c8d4870a 100644
--- a/odex25_ensan/odex_takaful/wizards/account_payment_register.xml
+++ b/odex25_ensan/odex_takaful/wizards/account_payment_register.xml
@@ -10,15 +10,14 @@
-
-
-
+
+
+
-
- {'readonly': [('is_refund_sponsorship', '=', True)]}
-
+ {'readonly':[('is_refund_sponsorship','=',True)]}
Association Journal
+
context.get('sponsorship_payment')
@@ -26,7 +25,7 @@
context.get('sponsorship_payment')
-
+
context.get('sponsorship_payment')
@@ -36,99 +35,94 @@
-
+
-
+
-
+
-
-
-
+
+
+
+ filename="transaction_attachment_file_name"
+ attrs="{'invisible': ['|', ('sponsorship_payment', '=', False), ('takaful_payment_method','not in',['bank', 'check'])], 'required': [('sponsorship_payment', '=', True), ('takaful_payment_method','=','bank')]}"/>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/odex25_ensan/odex_takaful/wizards/donation_extension_wizard.py b/odex25_ensan/odex_takaful/wizards/donation_extension_wizard.py
index 9bd061fd6..eceab07a5 100644
--- a/odex25_ensan/odex_takaful/wizards/donation_extension_wizard.py
+++ b/odex25_ensan/odex_takaful/wizards/donation_extension_wizard.py
@@ -3,6 +3,8 @@ from odoo import models, fields, api, _
from odoo.exceptions import ValidationError
from dateutil.relativedelta import relativedelta
import logging
+from odoo.tools import float_compare
+
_logger = logging.getLogger(__name__)
@@ -17,6 +19,12 @@ class DonationExtensionWizard(models.TransientModel):
required=True,
default=lambda self: self._compute_line_ids(),
)
+
+ payment_line_ids = fields.One2many(
+ 'extension.payment.wizard.line',
+ 'wizard_id',
+ string='Payments',
+ )
months = fields.Integer(
string='Extension Months',
@@ -25,6 +33,27 @@ class DonationExtensionWizard(models.TransientModel):
help='Number of months to extend'
)
+ is_different_payment = fields.Boolean(string='Is Different Payment')
+ total_extension_amount = fields.Float(
+ string='Total Extension Amount',
+ compute='_compute_total_extension_amount',
+ store=True,
+ )
+
+ @api.depends('line_ids.total_donation_amount')
+ def _compute_total_extension_amount(self):
+ for rec in self:
+ rec.total_extension_amount = sum(line.total_donation_amount for line in rec.line_ids if line.direct_debit == False)
+
+ @api.constrains('is_different_payment', 'payment_line_ids')
+ def _check_payment_sum_when_different(self):
+ for rec in self:
+ if rec.is_different_payment:
+ sum_payments = sum(line.payment_amount for line in rec.payment_line_ids)
+ if float_compare(sum_payments, rec.total_extension_amount, precision_digits=2) != 0:
+ raise ValidationError(_("Total payment amounts (%s) must equal total extension amount (%s).") %
+ (sum_payments, rec.total_extension_amount))
+
def _compute_line_ids(self):
extension_line_ids = [(5,)]
donation_detail_ids = self.env['donations.details.lines'].browse(self.env.context.get('donation_detail_ids'))
@@ -58,8 +87,28 @@ class DonationExtensionWizard(models.TransientModel):
if result:
invoice_ids += result[0]
donation_line_ids += result[1]
-
- if invoice_ids:
+
+ if invoice_ids and self.is_different_payment:
+ for pay_line in self.payment_line_ids:
+ payment_register_vals = {
+ 'payment_type': 'inbound',
+ 'partner_type': 'customer',
+ 'partner_id': pay_line.partner_id.id,
+ 'amount': pay_line.payment_amount,
+ 'journal_id': pay_line.journal_id.id,
+ 'payment_method_id': pay_line.payment_method.id,
+ 'communication': _("Extension Payment"),
+ }
+
+ payment_register = self.env['account.payment.register'].sudo().with_context(
+ active_model='account.move',
+ active_ids=invoice_ids.ids,
+ ).create(payment_register_vals)
+ print('.................',payment_register)
+ payment_register.action_create_payments()
+
+
+ elif invoice_ids and not self.is_different_payment:
return {
'name': _('Register Payment'),
'res_model': 'account.payment.register',
@@ -96,6 +145,70 @@ class DonationExtensionWizard(models.TransientModel):
"""
return {'type': 'ir.actions.act_window_close'}
+class ExtensionPaymentWizardLine(models.TransientModel):
+ _name = 'extension.payment.wizard.line'
+ _description = "Extension Payment Wizard Line"
+
+ @api.model
+ def _default_journal_id(self):
+ journal_id = self.env.company.sponsorship_direct_debit_journal_id.id
+ return journal_id if journal_id else False
+ @api.model
+ def _default_payment_method_id(self):
+ payment_method = self.env['takaful.payment.method'].sudo().search(
+ [('payment_method', '=', 'cash')],
+ limit=1
+ )
+ return payment_method.id if payment_method else False
+
+
+ wizard_id = fields.Many2one('donation.extension.wizard', string='Wizard', required=True)
+ donation_line_ids = fields.Many2many('donations.details.lines')
+ payment_method = fields.Many2one('takaful.payment.method', string="Payment Method", required=True, default=_default_payment_method_id)
+ partner_bank_id = fields.Many2one("res.partner.bank", string="Partner Bank", domain="[('partner_id', '=', partner_id)]")
+ payment_file_attachment = fields.Binary(string='Payment Attachment', attachment=True)
+ journal_id = fields.Many2one('account.journal', string="Journal", domain="[('type','=','bank')]",
+ default=_default_journal_id)
+ check_number = fields.Char(string='Check Number')
+ check_due_date = fields.Date(string='Check Due Date')
+ payment_amount = fields.Float(string='Payment Amount',
+ help="Amount to be paid for this line (when different payments used).",
+ default=0.0)
+ currency_id = fields.Many2one('res.currency', string='Currency',
+ default=lambda self: self.env.company.currency_id, readonly=True)
+ payment_method_type= fields.Selection(related='payment_method.payment_method')
+ partner_id = fields.Many2one(
+ 'res.partner',
+ compute='_compute_partner_id',
+ store=True
+ )
+
+ @api.onchange('payment_method')
+ def _onchange_payment_method(self):
+ if self.wizard_id and not self.donation_line_ids:
+ self.donation_line_ids = self.wizard_id.line_ids.mapped('donation_line_id').ids
+
+ @api.depends('donation_line_ids')
+ def _compute_partner_id(self):
+ for rec in self:
+ first_line = rec.donation_line_ids[:1]
+ rec.partner_id = first_line.sponsor_id.id if first_line else False
+
+ @api.onchange("payment_method")
+ def onchange_payment_method(self):
+ for rec in self:
+ if rec.payment_method and rec.payment_method.journal_id:
+ rec.journal_id = rec.payment_method.journal_id.id
+ payment_method = rec.payment_method.payment_method
+ j_type = ""
+ if payment_method == "cash":
+ j_type = "cash"
+ elif payment_method in ("bank", "check", "network"):
+ j_type = "bank"
+ if j_type:
+ return {"domain": {"journal_id": [("type", "=", j_type)]}}
+
+
class DonationExtensionWizardLine(models.TransientModel):
_name = 'donation.extension.wizard.line'
_description = "Donation Extension Wizard Line"
diff --git a/odex25_ensan/odex_takaful/wizards/donation_extension_wizard.xml b/odex25_ensan/odex_takaful/wizards/donation_extension_wizard.xml
index 637892772..51bea1b4c 100644
--- a/odex25_ensan/odex_takaful/wizards/donation_extension_wizard.xml
+++ b/odex25_ensan/odex_takaful/wizards/donation_extension_wizard.xml
@@ -10,6 +10,7 @@
+
@@ -77,6 +78,68 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+