Merge branch 'dev_odex25_ensan' into ii_dev_odex25_ensan
This commit is contained in:
commit
87a3531094
|
|
@ -1,4 +1,3 @@
|
|||
# Author: Ahmad Samir <a.atta@exp-sa.com>
|
||||
name: Block Reserved Branches
|
||||
|
||||
on:
|
||||
|
|
@ -9,13 +8,54 @@ on:
|
|||
jobs:
|
||||
block-reserved-branches:
|
||||
runs-on: app-sever-project-runner
|
||||
|
||||
steps:
|
||||
- name: Check for reserved or pattern-matching branch names
|
||||
- name: Validate branch creator + reserved names
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GH_TOKEN }}
|
||||
REPO: ${{ github.repository }}
|
||||
BRANCH_NAME: ${{ github.ref_name }}
|
||||
CREATOR: ${{ github.actor }}
|
||||
run: |
|
||||
echo "Branch: $BRANCH_NAME"
|
||||
echo "Creator: $CREATOR"
|
||||
|
||||
#######################################################
|
||||
# 🟦 1) Allowed Users List
|
||||
#######################################################
|
||||
ALLOWED_USERS=(
|
||||
"expsa"
|
||||
"moutazmuhammad"
|
||||
"ronozoro"
|
||||
"Abubaker-Altaib"
|
||||
"altexp"
|
||||
"the5abir"
|
||||
"ahmadaking"
|
||||
"kchyounes19"
|
||||
"abdurrahman-saber"
|
||||
)
|
||||
|
||||
IS_ALLOWED="false"
|
||||
for user in "${ALLOWED_USERS[@]}"; do
|
||||
if [[ "$CREATOR" == "$user" ]]; then
|
||||
IS_ALLOWED="true"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ "$IS_ALLOWED" == "false" ]]; then
|
||||
echo "❌ User '$CREATOR' is NOT allowed to create branches. Deleting..."
|
||||
curl -s -X DELETE \
|
||||
-H "Authorization: token $GH_TOKEN" \
|
||||
https://api.github.com/repos/$REPO/git/refs/heads/$BRANCH_NAME
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "✔ User '$CREATOR' is allowed."
|
||||
|
||||
#######################################################
|
||||
# 🟦 2) Reserved Branch Names (Your Existing List)
|
||||
#######################################################
|
||||
RESERVED_NAMES=(
|
||||
master
|
||||
dev_odex25_accounting
|
||||
|
|
@ -82,18 +122,27 @@ jobs:
|
|||
preprod_odex-event
|
||||
preprod_openeducat_erp-14.0.1.0
|
||||
)
|
||||
# Check if branch is an exact reserved name
|
||||
|
||||
# Exact match
|
||||
for reserved in "${RESERVED_NAMES[@]}"; do
|
||||
if [[ "$BRANCH_NAME" == "$reserved" ]]; then
|
||||
echo "❌ Branch name '$BRANCH_NAME' is reserved. Deleting..."
|
||||
curl -s -X DELETE -H "Authorization: token $GH_TOKEN" https://api.github.com/repos/$REPO/git/refs/heads/$BRANCH_NAME
|
||||
curl -s -X DELETE \
|
||||
-H "Authorization: token $GH_TOKEN" \
|
||||
https://api.github.com/repos/$REPO/git/refs/heads/$BRANCH_NAME
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
# Check if branch name matches restricted patterns
|
||||
|
||||
#######################################################
|
||||
# 🟦 3) Pattern-based Restriction
|
||||
#######################################################
|
||||
if [[ "$BRANCH_NAME" == master_* || "$BRANCH_NAME" == preprod_* || "$BRANCH_NAME" == dev_* ]]; then
|
||||
echo "❌ Branch name '$BRANCH_NAME' matches restricted pattern. Deleting..."
|
||||
curl -s -X DELETE -H "Authorization: token $GH_TOKEN" https://api.github.com/repos/$REPO/git/refs/heads/$BRANCH_NAME
|
||||
curl -s -X DELETE \
|
||||
-H "Authorization: token $GH_TOKEN" \
|
||||
https://api.github.com/repos/$REPO/git/refs/heads/$BRANCH_NAME
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "✅ Branch '$BRANCH_NAME' is allowed."
|
||||
|
|
@ -0,0 +1,98 @@
|
|||
name: Restrict PR Authors & Committers
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: write
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types: [opened, reopened, synchronize]
|
||||
branches:
|
||||
- dev_odex-event
|
||||
- dev_odex25_accounting
|
||||
- dev_odex25_base
|
||||
- dev_odex25_dms
|
||||
- dev_odex25_fleet
|
||||
- dev_odex25_hr
|
||||
- dev_odex25_inventory
|
||||
- dev_odex25_maintenance
|
||||
- dev_odex25_mobile
|
||||
- dev_odex25_pos
|
||||
- dev_odex25_project
|
||||
- dev_odex25_purchase
|
||||
- dev_odex25_realstate
|
||||
- dev_odex25_sales
|
||||
- dev_odex25_survey
|
||||
- dev_odex25_transactions
|
||||
- dev_odex25_website
|
||||
- dev_openeducat_erp-14.0.1.0
|
||||
- dev_odex25_ensan
|
||||
- dev_odex25_helpdesk
|
||||
- dev_odex25_donation
|
||||
|
||||
jobs:
|
||||
check_pr_author:
|
||||
runs-on: linting_odex25-standard-modules_runner
|
||||
|
||||
steps:
|
||||
- name: Validate PR Author & Commit Authors
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
github-token: ${{ secrets.GH_TOKEN }}
|
||||
script: |
|
||||
const allowed = [
|
||||
"expsa",
|
||||
"moutazmuhammad",
|
||||
"ronozoro",
|
||||
"Abubaker-Altaib",
|
||||
"altexp",
|
||||
"the5abir",
|
||||
"ahmadaking",
|
||||
"kchyounes19",
|
||||
"abdurrahman-saber"
|
||||
];
|
||||
|
||||
const pr = context.payload.pull_request;
|
||||
const prAuthor = pr.user.login;
|
||||
const owner = context.repo.owner;
|
||||
const repo = context.repo.repo;
|
||||
|
||||
core.info(`PR author: ${prAuthor}`);
|
||||
|
||||
// Check PR author
|
||||
if (!allowed.includes(prAuthor)) {
|
||||
core.error(`Unauthorized PR author: ${prAuthor}. Closing PR...`);
|
||||
await github.rest.pulls.update({
|
||||
owner,
|
||||
repo,
|
||||
pull_number: pr.number,
|
||||
state: "closed"
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
// Check commit authors
|
||||
const commitList = await github.rest.pulls.listCommits({
|
||||
owner,
|
||||
repo,
|
||||
pull_number: pr.number
|
||||
});
|
||||
|
||||
for (const commit of commitList.data) {
|
||||
const commitAuthor = commit.author ? commit.author.login : null;
|
||||
|
||||
if (commitAuthor && !allowed.includes(commitAuthor)) {
|
||||
core.error(`Unauthorized commit author: ${commitAuthor}. Closing PR...`);
|
||||
|
||||
await github.rest.pulls.update({
|
||||
owner,
|
||||
repo,
|
||||
pull_number: pr.number,
|
||||
state: "closed"
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
core.info("All PR authors and committers are allowed.");
|
||||
|
|
@ -27,7 +27,7 @@ on:
|
|||
|
||||
|
||||
jobs:
|
||||
sonar:
|
||||
sonarqube_check:
|
||||
runs-on: sonarqube
|
||||
steps:
|
||||
- name: Checkout code
|
||||
|
|
|
|||
|
|
@ -243,6 +243,11 @@ msgstr "<strong>تاريخ الدفع:</strong>"
|
|||
msgid "<strong>Payment Method:</strong>"
|
||||
msgstr "<strong>طريقة الدفع:</strong>"
|
||||
|
||||
#. module: enasan_geidea_sponsorship
|
||||
#: model_terms:ir.ui.view,arch_db:enasan_geidea_sponsorship.view_account_payment_register_form_geidea
|
||||
msgid "Process on Terminal"
|
||||
msgstr "الدفع على المنصة"
|
||||
|
||||
#. module: odex_takaful
|
||||
#: model_terms:ir.ui.view,arch_db:odex_takaful.report_transfer_deduction_document
|
||||
msgid "<strong>Payment Method</strong>"
|
||||
|
|
@ -2234,7 +2239,7 @@ msgstr "تمديد"
|
|||
#: model_terms:ir.ui.view,arch_db:odex_takaful.donations_details_lines_view_form
|
||||
#, python-format
|
||||
msgid "Extend Donation"
|
||||
msgstr "تمديد التبرع"
|
||||
msgstr "تمديد الكفالة"
|
||||
|
||||
#. module: odex_takaful
|
||||
#: model:ir.model.fields.selection,name:odex_takaful.selection__donations_details_lines__state__extended
|
||||
|
|
@ -7504,4 +7509,57 @@ msgstr "سجل الإستبدال"
|
|||
msgid "Paid"
|
||||
msgstr "منتهي"
|
||||
|
||||
#. module: odex_takaful
|
||||
#: model:ir.model.fields,field_description:odex_takaful.field_extension_payment_wizard_line__check_number
|
||||
msgid "Check Number"
|
||||
msgstr "رقم الشيك"
|
||||
|
||||
#. module: odex_takaful
|
||||
#: model:ir.model.fields,field_description:odex_takaful.field_extension_payment_wizard_line__journal_id
|
||||
msgid "Journal"
|
||||
msgstr "حساب الجمعية"
|
||||
|
||||
#. module: odex_takaful
|
||||
#: model:ir.model.fields,field_description:odex_takaful.field_extension_payment_wizard_line__partner_bank_id
|
||||
msgid "Partner Bank"
|
||||
msgstr "بنك المتبرع"
|
||||
|
||||
#. module: odex_takaful
|
||||
#: model:ir.model.fields,field_description:odex_takaful.field_extension_payment_wizard_line__payment_amount
|
||||
msgid "Payment Amount"
|
||||
msgstr "المبلغ"
|
||||
|
||||
#. module: odex_takaful
|
||||
#: model:ir.model.fields,field_description:odex_takaful.field_extension_payment_wizard_line__payment_file_attachment
|
||||
msgid "Payment Attachment"
|
||||
msgstr "مرفق الدفع"
|
||||
|
||||
#. module: odex_takaful
|
||||
#: model:ir.model.fields,field_description:odex_takaful.field_extension_payment_wizard_line__payment_method
|
||||
msgid "Payment Method"
|
||||
msgstr "طريقة الدفع"
|
||||
|
||||
#. module: odex_takaful
|
||||
#: model:ir.model.fields,field_description:odex_takaful.field_extension_payment_wizard_line__check_due_date
|
||||
msgid "Check Due Date"
|
||||
msgstr "تاريخ الإستحقاق"
|
||||
|
||||
#. module: odex_takaful
|
||||
#: model:ir.model.fields,field_description:odex_takaful.field_extension_payment_wizard_line__check_number
|
||||
msgid "Check Number"
|
||||
msgstr "رقم الشيك"
|
||||
|
||||
#. module: odex_takaful
|
||||
#: model:ir.model.fields,field_description:odex_takaful.field_donation_extension_wizard__is_different_payment
|
||||
msgid "Is Different Payment"
|
||||
msgstr "طرف دفع متعددة"
|
||||
|
||||
#. module: odex_takaful
|
||||
#: model_terms:ir.ui.view,arch_db:odex_takaful.view_account_payment_register_form
|
||||
msgid "Association Journal"
|
||||
msgstr "حساب الجمعية"
|
||||
|
||||
#. module: odex_takaful
|
||||
#: model_terms:ir.ui.view,arch_db:odex_takaful.donation_extension_wizard_form
|
||||
msgid "Sub Payments"
|
||||
msgstr "دفع متعدد"
|
||||
|
|
@ -99,6 +99,83 @@ class DonationsDetailsLines(models.Model):
|
|||
journal_id = fields.Many2one('account.journal', string="Journal",domain="[('type','=','bank')]",default=_default_journal_id)
|
||||
benefit_status = fields.Selection(related='benefit_id.member_status')
|
||||
ages = fields.Integer(compute='_compute_get_age_range' , store=True)
|
||||
waiting_date = fields.Date(
|
||||
string="تاريخ الانتظار",
|
||||
)
|
||||
actual_end_date = fields.Date(string="مدة الانتظار", compute='_compute_actual_end_date', store=True)
|
||||
period_display = fields.Char(
|
||||
string="Period",
|
||||
compute="_compute_period_display" )
|
||||
|
||||
age_category = fields.Selection([
|
||||
('18', '+18'),
|
||||
('16', '+16'),
|
||||
('all', 'جميع الأعمار'),
|
||||
], string="الفئة العمرية", compute="_compute_age_category")
|
||||
|
||||
@api.depends('sponsorship_duration', 'payment_month_count', 'direct_debit')
|
||||
def _compute_age_category(self):
|
||||
for rec in self:
|
||||
print( rec.sponsorship_duration , ' ' ,rec.direct_debit , ' ' , rec.payment_month_count)
|
||||
if rec.sponsorship_duration == 'permanent':
|
||||
rec.age_category = 'all'
|
||||
elif rec.sponsorship_duration != 'permanent' :
|
||||
if rec.direct_debit:
|
||||
rec.age_category = '16'
|
||||
elif rec.sponsorship_duration != 'permanent' and rec.payment_month_count >= 6:
|
||||
rec.age_category = 'all'
|
||||
elif rec.sponsorship_duration != 'permanent' and rec.payment_month_count < 6:
|
||||
rec.age_category = '18'
|
||||
else:
|
||||
rec.age_category = 'all'
|
||||
|
||||
@api.depends('benefit_ids.end_date')
|
||||
def _compute_actual_end_date(self):
|
||||
for rec in self:
|
||||
if rec.benefit_ids:
|
||||
# take the first benefit record
|
||||
first_benefit = rec.benefit_ids[0]
|
||||
rec.actual_end_date = first_benefit.end_date
|
||||
else:
|
||||
rec.actual_end_date = False
|
||||
@api.depends('end_date', 'waiting_date')
|
||||
def _compute_period_display(self):
|
||||
today = date.today()
|
||||
for rec in self:
|
||||
|
||||
# pick whichever date is set
|
||||
if rec.state == 'replace' :
|
||||
base_date = rec.end_date
|
||||
elif rec.state == 'waiting':
|
||||
base_date = rec.waiting_date
|
||||
else:
|
||||
base_date = False
|
||||
if base_date:
|
||||
delta = relativedelta(today, base_date)
|
||||
# build human-readable string
|
||||
if delta.years > 0:
|
||||
rec.period_display = f"{delta.years} year(s)"
|
||||
elif delta.months > 0:
|
||||
rec.period_display = f"{delta.months} month(s)"
|
||||
elif delta.days > 0:
|
||||
rec.period_display = f"{delta.days} day(s)"
|
||||
else:
|
||||
rec.period_display = "Today"
|
||||
else:
|
||||
rec.period_display = "No date"
|
||||
|
||||
|
||||
|
||||
@api.constrains('state')
|
||||
def _compute_dates(self):
|
||||
"""Automatically set waiting_date or replace_date based on state."""
|
||||
for rec in self:
|
||||
if rec.state == 'waiting':
|
||||
rec.waiting_date = date.today()
|
||||
else:
|
||||
rec.waiting_date = False
|
||||
|
||||
|
||||
# cheque_number = fields.Integer(string="Cheque Number")
|
||||
# cheque_due_date = fields.Date(string="Cheque Due Date")
|
||||
# cheque_file_attachment = fields.Binary(string='Cheque Attachment', attachment=True)
|
||||
|
|
@ -157,7 +234,7 @@ class DonationsDetailsLines(models.Model):
|
|||
today = fields.Date.today()
|
||||
for rec in self:
|
||||
show_extend_button = (
|
||||
((rec.record_type == 'donation' and rec.direct_debit) or rec.record_type == 'sponsorship') and
|
||||
rec.record_type == 'sponsorship' and
|
||||
rec.end_date and
|
||||
rec.end_date >= today and
|
||||
rec.state == 'active'
|
||||
|
|
@ -168,9 +245,9 @@ class DonationsDetailsLines(models.Model):
|
|||
def _compute_show_replaced_button(self):
|
||||
for rec in self:
|
||||
show_replaced_button = (
|
||||
((rec.record_type == 'donation' and rec.donation_mechanism == 'with_conditions') or rec.record_type == 'sponsorship') and
|
||||
rec.state in ('active', 'paid','replace') and
|
||||
(rec.benefit_id or rec.benefit_ids or rec.family_id)
|
||||
rec.record_type == 'sponsorship' and
|
||||
rec.state in ('active','replace') and
|
||||
(rec.benefit_id or rec.benefit_ids)
|
||||
|
||||
)
|
||||
rec.show_replaced_button = show_replaced_button
|
||||
|
|
@ -243,6 +320,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:
|
||||
|
|
@ -507,6 +590,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:
|
||||
|
|
@ -660,6 +744,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)
|
||||
|
|
@ -816,7 +910,7 @@ class DonationsDetailsLines(models.Model):
|
|||
record = super(DonationsDetailsLines, self).create(vals)
|
||||
if record.benefit_ids == 1:
|
||||
record.benefit_id = record.benefit_ids[0].id
|
||||
|
||||
print('Vals >>> ' , vals)
|
||||
return record
|
||||
|
||||
def write(self, vals):
|
||||
|
|
@ -864,6 +958,20 @@ class DonationsDetailsLines(models.Model):
|
|||
if sponsorship and len(sponsorship) == 1:
|
||||
message = _("Benefit IDs changed in a donation item:<br/>%s") % "<br/>".join(changes)
|
||||
sponsorship.message_post(body=message)
|
||||
|
||||
# if 'state' in vals:
|
||||
# print('In Vals')
|
||||
# print("vals['state'] >>> " , vals['state'])
|
||||
# if vals['state'] == 'waiting':
|
||||
# vals['waiting_date'] = date.today()
|
||||
# print("vals['waiting_date'] >>> " , vals['waiting_date'])
|
||||
# vals['replace_date'] = False
|
||||
# elif vals['state'] == 'replace':
|
||||
# vals['replace_date'] = date.today()
|
||||
# vals['waiting_date'] = False
|
||||
# else:
|
||||
# vals['waiting_date'] = False
|
||||
# vals['replace_date'] = False
|
||||
self.onset_benefit_id()
|
||||
|
||||
return res
|
||||
|
|
|
|||
|
|
@ -281,6 +281,14 @@ class ResPartner(models.Model):
|
|||
if 'mobile' in vals:
|
||||
self._check_phone_numbers(vals['mobile'])
|
||||
vals['mobile'] = self.phone_format(vals['mobile'])
|
||||
if 'name' in vals :
|
||||
if self.kafel_id:
|
||||
self.kafel_id.name = vals['name']
|
||||
|
||||
if 'mobile' in vals :
|
||||
if self.kafel_id:
|
||||
self.kafel_id.login = vals['mobile']
|
||||
|
||||
res = super(ResPartner, self).write(vals)
|
||||
return res
|
||||
|
||||
|
|
|
|||
|
|
@ -148,7 +148,9 @@ class SchedulingLine(models.Model):
|
|||
line.sudo().write({'status': 'paid'})
|
||||
if line.donation_detail_linked_id.state == 'waiting' or (not line.donation_detail_linked_id.benefit_id and line.donation_detail_linked_id.record_type == 'sponsorship'):
|
||||
line.donation_detail_linked_id.sudo().write({'state': 'waiting'})
|
||||
else:
|
||||
elif line.donation_detail_linked_id.record_type == 'donation':
|
||||
line.donation_detail_linked_id.sudo().write({'state': 'paid'})
|
||||
elif line.donation_detail_linked_id.state != 'waiting' and line.donation_detail_linked_id.record_type != 'donation' and line.donation_detail_linked_id.record_type == 'sponsorship':
|
||||
line.donation_detail_linked_id.sudo().write({'state': 'active'})
|
||||
line.donation_detail_linked_id.sponsorship_id.sudo().write({'state': 'wait_pay'})
|
||||
|
||||
|
|
|
|||
|
|
@ -810,7 +810,7 @@ class TakafulSponsorship(models.Model):
|
|||
sponsor_donor_type = vals.get('sponsor_donor_type')
|
||||
sponsor_id = vals.get('sponsor_id')
|
||||
state = vals.get('state', 'draft')
|
||||
|
||||
print('Vals >>> ' , vals)
|
||||
# Only validate when state is draft and saving (not during onchange)
|
||||
if state == 'draft':
|
||||
# Check for donation with new_sponsor
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
|
@ -61,11 +61,12 @@
|
|||
<field name="name">donations.details.lines.view.tree</field>
|
||||
<field name="model">donations.details.lines</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree default_order="create_date asc" create="0" edit="0">
|
||||
<tree default_order="create_date asc , waiting_date asc " create="0" edit="0" >
|
||||
<field name="sponsorship_scheduling_line_ids" invisible="1" />
|
||||
<field name="direct_debit" invisible="1" />
|
||||
<field name="sequence_no" />
|
||||
<field name="sponsor_id" />
|
||||
|
||||
<field name="sponsor_phone" widget="phone"/>
|
||||
<field name="donation_type" optional="show"/>
|
||||
<field name="sponsorship_duration" optional="hide"/>
|
||||
|
|
@ -82,15 +83,16 @@
|
|||
<field name="branch_custom_id" optional="hide" />
|
||||
<field name="benefit_family_code" optional="hide" />
|
||||
<field name="benefit_id" optional="hide" />
|
||||
<field name="sponsorship_creation_date" />
|
||||
<!-- <field name="sponsorship_creation_date" />-->
|
||||
<field name="create_date" optional="hide"/>
|
||||
<field name="waiting_date" widget="date" optional="hide"/>
|
||||
<field name="state" widget="badge"
|
||||
decoration-muted="state == 'draft'"
|
||||
decoration-warning="state == 'waiting'"
|
||||
decoration-success="state in ['active', 'paid','confirmed']"
|
||||
decoration-danger="state == 'closed'"
|
||||
decoration-info="state == 'extended'" />
|
||||
|
||||
<field name="age_category" widget="state" />
|
||||
<button name="action_view_scheduling_lines"
|
||||
string="View Scheduling Lines"
|
||||
type="object"
|
||||
|
|
@ -179,6 +181,8 @@
|
|||
<group>
|
||||
<group string="Donation Information">
|
||||
<field name="ages" invisible="1" />
|
||||
<field name="period_display" invisible="0" />
|
||||
<field name="waiting_date" widget="date" invisible="1"/>
|
||||
<field name="donation_type" invisible="1"/>
|
||||
<field name="donation_types"
|
||||
attrs="{'invisible': [('donation_type', '!=', 'donation')], 'readonly': [('parent_state', '!=', 'draft')]}" />
|
||||
|
|
@ -227,6 +231,7 @@
|
|||
<field name="donation_type"
|
||||
attrs="{'invisible': [('record_type', '!=', 'sponsorship')], 'readonly': ['|', ('record_type', '=', 'sponsorship'), ('parent_state', '!=', 'draft')]}"
|
||||
force_save="1" />
|
||||
<field name="age_category" widget="state" />
|
||||
<field name="direct_debit" invisible="1" />
|
||||
<field name="donation_types"
|
||||
attrs="{
|
||||
|
|
@ -350,6 +355,101 @@
|
|||
</field>
|
||||
</record>
|
||||
|
||||
<record id="donations_details_lines_view_tree_waiting" model="ir.ui.view">
|
||||
<field name="name">donations.details.lines.view.tree.waiting</field>
|
||||
<field name="model">donations.details.lines</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree default_order="waiting_date asc" create="0" edit="0" >
|
||||
<field name="sponsorship_scheduling_line_ids" invisible="1" />
|
||||
<field name="direct_debit" invisible="1" />
|
||||
<field name="sequence_no" />
|
||||
<field name="sponsor_id" />
|
||||
<field name="sponsor_phone" widget="phone"/>
|
||||
<field name="donation_type" optional="show"/>
|
||||
<field name="sponsorship_duration" optional="hide"/>
|
||||
<field name="donation_mechanism" optional="hide"/>
|
||||
<field name="product_template_id" />
|
||||
<field name="benefit_status" widget="badge"
|
||||
decoration-success="benefit_status == 'benefit'"
|
||||
decoration-danger="benefit_status == 'non_benefit'"/>
|
||||
<field name="start_date" widget="date"/>
|
||||
<field name="end_date" widget="date"/>
|
||||
<field name="donation_amount" widget="monetary" options="{'currency_field': 'currency_id'}"/>
|
||||
<field name="total_donation_amount" widget="monetary" options="{'currency_field': 'currency_id'}"/>
|
||||
<field name="currency_id" invisible="1"/>
|
||||
<field name="branch_custom_id" optional="hide" />
|
||||
<field name="benefit_family_code" optional="hide" />
|
||||
<field name="benefit_id" optional="hide" />
|
||||
<!-- <field name="sponsorship_creation_date" />-->
|
||||
<field name="create_date" optional="hide"/>
|
||||
<field name="waiting_date" />
|
||||
<field name="waiting_date" string='مدة الانتظار' widget="remaining_days" />
|
||||
<!-- <field name="period_display" />-->
|
||||
<field name="state" widget="badge"
|
||||
decoration-muted="state == 'draft'"
|
||||
decoration-warning="state == 'waiting'"
|
||||
decoration-success="state in ['active', 'paid','confirmed']"
|
||||
decoration-danger="state == 'closed'"
|
||||
decoration-info="state == 'extended'" />
|
||||
<field name="age_category" widget="state" />
|
||||
|
||||
|
||||
<button name="action_view_scheduling_lines"
|
||||
string="View Scheduling Lines"
|
||||
type="object"
|
||||
attrs="{'invisible': ['|', ('direct_debit', '=', False), ('sponsorship_scheduling_line_ids', '=', [])]}"
|
||||
class="btn-secondary"
|
||||
icon="fa-calendar" />
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="donations_details_lines_view_tree_replace" model="ir.ui.view">
|
||||
<field name="name">donations.details.lines.view.tree.replace</field>
|
||||
<field name="model">donations.details.lines</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree default_order="end_date asc" create="0" edit="0" >
|
||||
<field name="sponsorship_scheduling_line_ids" invisible="1" />
|
||||
<field name="direct_debit" invisible="1" />
|
||||
<field name="sequence_no" />
|
||||
<field name="sponsor_id" />
|
||||
<field name="sponsor_phone" widget="phone"/>
|
||||
<field name="donation_type" optional="show"/>
|
||||
<field name="sponsorship_duration" optional="hide"/>
|
||||
<field name="donation_mechanism" optional="hide"/>
|
||||
<field name="product_template_id" />
|
||||
<field name="benefit_status" widget="badge"
|
||||
decoration-success="benefit_status == 'benefit'"
|
||||
decoration-danger="benefit_status == 'non_benefit'"/>
|
||||
<field name="start_date" widget="date"/>
|
||||
<field name="end_date" widget="date"/>
|
||||
<field name="donation_amount" widget="monetary" options="{'currency_field': 'currency_id'}"/>
|
||||
<field name="total_donation_amount" widget="monetary" options="{'currency_field': 'currency_id'}"/>
|
||||
<field name="currency_id" invisible="1"/>
|
||||
<field name="branch_custom_id" optional="hide" />
|
||||
<field name="benefit_family_code" optional="hide" />
|
||||
<field name="benefit_id" optional="hide" />
|
||||
<!-- <field name="sponsorship_creation_date" />-->
|
||||
<field name="create_date" optional="hide"/>
|
||||
<field name="actual_end_date" widget="date" string="تاريخ خروج المستفيد" />
|
||||
<field name="actual_end_date" widget="remaining_days" string="فترة الخروج" />
|
||||
<field name="state" widget="badge"
|
||||
decoration-muted="state == 'draft'"
|
||||
decoration-warning="state == 'waiting'"
|
||||
decoration-success="state in ['active', 'paid','confirmed']"
|
||||
decoration-danger="state == 'closed'"
|
||||
decoration-info="state == 'extended'" />
|
||||
<field name="age_category" widget="state" />
|
||||
<button name="action_view_scheduling_lines"
|
||||
string="View Scheduling Lines"
|
||||
type="object"
|
||||
attrs="{'invisible': ['|', ('direct_debit', '=', False), ('sponsorship_scheduling_line_ids', '=', [])]}"
|
||||
class="btn-secondary"
|
||||
icon="fa-calendar" />
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="donations_details_lines_action" model="ir.actions.act_window">
|
||||
<field name="name">Donations Details Lines</field>
|
||||
<field name="res_model">donations.details.lines</field>
|
||||
|
|
@ -362,16 +462,24 @@
|
|||
<field name="name">Donations Details Lines waiting</field>
|
||||
<field name="res_model">donations.details.lines</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="domain">[('state', '=', 'waiting')]</field>
|
||||
<field name="search_view_id" ref="donations_details_lines_view_search"/>
|
||||
<field name="context">{'create': False, 'delete': False, 'search_default_filter_waiting': 1}</field>
|
||||
<field name="view_ids" eval="[(5, 0, 0),
|
||||
(0, 0, {'view_mode': 'tree', 'view_id': ref('donations_details_lines_view_tree_waiting')}),
|
||||
(0, 0, {'view_mode': 'form', 'view_id': ref('donations_details_lines_view_form')})]"/>
|
||||
<field name="context">{'create': False, 'delete': False}</field>
|
||||
</record>
|
||||
|
||||
<record id="donations_details_lines_replace_action" model="ir.actions.act_window">
|
||||
<field name="name">Donations Details Lines Replacement</field>
|
||||
<field name="res_model">donations.details.lines</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="domain">[('state', '=', 'replace')]</field>
|
||||
<field name="view_ids" eval="[(5, 0, 0),
|
||||
(0, 0, {'view_mode': 'tree', 'view_id': ref('donations_details_lines_view_tree_replace')}),
|
||||
(0, 0, {'view_mode': 'form', 'view_id': ref('donations_details_lines_view_form')})]"/>
|
||||
<field name="search_view_id" ref="donations_details_lines_view_search"/>
|
||||
<field name="context">{'create': False, 'delete': False, 'search_default_filter_replace': 1}</field>
|
||||
<field name="context">{'create': False, 'delete': False}</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
|
|
|
|||
|
|
@ -13,11 +13,13 @@
|
|||
<menuitem id="donations_details_lines_app_menu" parent="kafalat_main_menu"
|
||||
name="Donations Details Lines" action="donations_details_lines_action" sequence="2"/>
|
||||
|
||||
<menuitem id="donations_details_lines_waiting_app_menu" parent="menu_replacement_root"
|
||||
name="Donations Details Lines Waiting Benefit" action="donations_details_lines_waiting_action" sequence="3"/>
|
||||
|
||||
<menuitem id="donations_details_lines_to_replace_app_menu" parent="menu_replacement_root"
|
||||
name="Donations Details Lines To Replace Benefit" action="donations_details_lines_replace_action" sequence="4"/>
|
||||
name="Donations Details Lines To Replace Benefit" action="donations_details_lines_replace_action" sequence="3"/>
|
||||
|
||||
<menuitem id="donations_details_lines_waiting_app_menu" parent="menu_replacement_root"
|
||||
name="Donations Details Lines Waiting Benefit" action="donations_details_lines_waiting_action" sequence="4"/>
|
||||
|
||||
|
||||
|
||||
<!-- TODO WE WILL USE IT LATER DON'T REMOVE THIS -->
|
||||
<!-- START OF THE BLOCK -->
|
||||
|
|
|
|||
|
|
@ -514,6 +514,7 @@
|
|||
<group>
|
||||
<group>
|
||||
<field name="ages" invisible="1"/>
|
||||
<field name="waiting_date" invisible="1" widget="date"/>
|
||||
<field name="family_id"
|
||||
attrs="{'invisible': [('sponsorship_type','=','group'), ('parent.record_type','=','sponsorship')],
|
||||
'readonly': ['|', ('sponsorship_type', '!=', 'group'), ('parent.record_type','!=','donation')],
|
||||
|
|
|
|||
|
|
@ -90,11 +90,11 @@
|
|||
</div>
|
||||
</group>
|
||||
<group>
|
||||
<field name="kafel_id" readonly="1"/>
|
||||
<field name="kafel_id" readonly="1" invisible="1"/>
|
||||
</group>
|
||||
<group name="group_top">
|
||||
<group name="group_main" colspan="2">
|
||||
<field name="mobile" string="رقم الجوال" widget="phone" placeholder="05xxxxxxxx" attrs="{'required': [('parent_id', '=', False)]}"/>
|
||||
<field name="mobile" string="رقم الجوال" widget="phone" placeholder="05xxxxxxxx" attrs="{'required': [('parent_id', '=', False)]}" />
|
||||
<field name="preferred_communication" string="طريقة التواصل المفضلة" required="1"/>
|
||||
<field name="gender" attrs="{'required': [('company_type', '=', 'person')],'invisible': [('company_type', '!=', 'person')]}"/>
|
||||
<field name="street" attrs="{'invisible': [('company_type', '=', 'person')]}"/>
|
||||
|
|
|
|||
|
|
@ -30,11 +30,17 @@ class AccountRegisterPayment(models.TransientModel):
|
|||
transaction_file_attachment = fields.Binary(string='Transaction Attachment', attachment=False)
|
||||
transaction_attachment_file_name = fields.Char('Transaction File Name', required=False)
|
||||
payment_method = fields.Selection(selection=[("cash", "Cash"), ("bank", "Bank Transfer"), ("check", "Check")], string="Payment Method", required=True, default="cash")
|
||||
|
||||
machine_id = fields.Many2one('geidea.terminals' , 'الماكينة')
|
||||
check_number = fields.Char(string='Check Number')
|
||||
check_due_date = fields.Date(string='Check Due Date')
|
||||
sponsorship_payment = fields.Boolean(string='Sponsorship Payment', default=False)
|
||||
|
||||
|
||||
@api.onchange("machine_id")
|
||||
def onchange_machine_id(self):
|
||||
for rec in self:
|
||||
if rec.machine_id:
|
||||
rec.journal_id = rec.machine_id.journal_id
|
||||
@api.onchange("takaful_payment_method_id")
|
||||
def onchange_takaful_payment_method_id(self):
|
||||
for rec in self:
|
||||
|
|
@ -44,11 +50,12 @@ 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)]}}
|
||||
|
||||
|
||||
@api.depends('source_amount', 'source_amount_currency', 'source_currency_id', 'company_id', 'currency_id', 'payment_date')
|
||||
def _compute_amount(self):
|
||||
if self.env.context.get('sponsorship_payment_skip_compute_amount'):
|
||||
|
|
@ -67,6 +74,7 @@ class AccountRegisterPayment(models.TransientModel):
|
|||
else:
|
||||
rec.takaful_payment_method = "cash"
|
||||
|
||||
|
||||
def _create_payments(self):
|
||||
sponsorship_line_ids = self.env.context.get('sponsorship_line_ids')
|
||||
sponsorship_lines = self.env['donations.details.lines'].browse(sponsorship_line_ids).filtered(lambda r: r.display_type == False)
|
||||
|
|
|
|||
|
|
@ -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__)
|
||||
|
||||
|
|
@ -18,6 +20,12 @@ class DonationExtensionWizard(models.TransientModel):
|
|||
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',
|
||||
required=True,
|
||||
|
|
@ -25,6 +33,29 @@ 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 not 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'))
|
||||
|
|
@ -47,6 +78,19 @@ class DonationExtensionWizard(models.TransientModel):
|
|||
if rec.months <= 0:
|
||||
raise ValidationError(_("Extension months must be greater than 0."))
|
||||
|
||||
@api.onchange('payment_line_ids', 'total_extension_amount')
|
||||
def _compute_lines(self):
|
||||
remaining = self.total_extension_amount
|
||||
|
||||
for line in self.payment_line_ids:
|
||||
|
||||
if not line.payment_amount:
|
||||
line.payment_amount = remaining
|
||||
|
||||
remaining -= line.payment_amount
|
||||
|
||||
line.remaining = remaining if remaining > 0 else 0
|
||||
|
||||
def action_extend(self):
|
||||
"""
|
||||
Extend the donation detail line with new amount and months
|
||||
|
|
@ -59,22 +103,69 @@ class DonationExtensionWizard(models.TransientModel):
|
|||
invoice_ids += result[0]
|
||||
donation_line_ids += result[1]
|
||||
|
||||
if invoice_ids:
|
||||
return {
|
||||
'name': _('Register Payment'),
|
||||
'res_model': 'account.payment.register',
|
||||
'view_mode': 'form',
|
||||
'context': {
|
||||
'active_model': 'account.move',
|
||||
'active_ids': invoice_ids.ids,
|
||||
'dont_redirect_to_payments': True,
|
||||
'sponsorship_line_ids': donation_line_ids.ids,
|
||||
'sponsorship_payment': True,
|
||||
'default_sponsorship_payment': True,
|
||||
},
|
||||
'target': 'new',
|
||||
'type': 'ir.actions.act_window',
|
||||
}
|
||||
if invoice_ids and not self.is_different_payment:
|
||||
invoices = invoice_ids.filtered(
|
||||
lambda inv: inv.state == 'posted' and inv.move_type in ('out_invoice', 'out_refund'))
|
||||
if not invoices:
|
||||
return
|
||||
|
||||
residual_map = {inv.id: float(inv.amount_residual) for inv in invoices}
|
||||
|
||||
invoices = invoices.sorted(key=lambda r: r.invoice_date or r.date or fields.Date.context_today(self))
|
||||
|
||||
for pay_line in self.payment_line_ids:
|
||||
remaining = float(pay_line.payment_amount or 0.0)
|
||||
if float_compare(remaining, 0.0, precision_digits=2) <= 0:
|
||||
continue
|
||||
|
||||
candidate_invoices = invoices.filtered(lambda inv: inv.partner_id == pay_line.partner_id)
|
||||
|
||||
if not candidate_invoices:
|
||||
candidate_invoices = invoices
|
||||
|
||||
for inv in candidate_invoices:
|
||||
if float_compare(remaining, 0.0, precision_digits=2) <= 0:
|
||||
break
|
||||
|
||||
inv_res = residual_map.get(inv.id, 0.0)
|
||||
if float_compare(inv_res, 0.0, precision_digits=2) <= 0:
|
||||
continue
|
||||
|
||||
pay_amount = min(remaining, inv_res)
|
||||
|
||||
payment_register_vals = {
|
||||
'payment_type': 'inbound',
|
||||
'partner_type': 'customer',
|
||||
'partner_id': inv.partner_id.id,
|
||||
'amount': pay_amount,
|
||||
'journal_id': pay_line.journal_id.id,
|
||||
# 'payment_method_id': pay_line.payment_method.id,
|
||||
'communication': _("Extension Payment for %s") % inv.name,
|
||||
'transaction_file_attachment': pay_line.payment_file_attachment,
|
||||
|
||||
}
|
||||
|
||||
ctx = {
|
||||
'active_model': 'account.move',
|
||||
'active_ids': [inv.id],
|
||||
'dont_redirect_to_payments': True,
|
||||
'sponsorship_line_ids': donation_line_ids.ids,
|
||||
'sponsorship_payment': True,
|
||||
'default_sponsorship_payment': True,
|
||||
}
|
||||
|
||||
payment_register = self.env['account.payment.register'].sudo().with_context(ctx).new(
|
||||
payment_register_vals)
|
||||
payments = payment_register.action_create_payments()
|
||||
|
||||
inv_sudo = inv.sudo()
|
||||
inv_sudo.invalidate_cache(['amount_residual'])
|
||||
new_residual = float(inv_sudo.amount_residual or 0.0)
|
||||
residual_map[inv.id] = new_residual
|
||||
|
||||
remaining = remaining - pay_amount
|
||||
|
||||
|
||||
|
||||
return {
|
||||
'type': 'ir.actions.client',
|
||||
|
|
@ -96,6 +187,73 @@ 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)
|
||||
remaining = fields.Float(string="Remaining", readonly=True)
|
||||
|
||||
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"
|
||||
|
|
@ -195,7 +353,6 @@ class DonationExtensionWizardLine(models.TransientModel):
|
|||
# Update end date
|
||||
donation_line_new_vals = {
|
||||
'end_date': new_end_date,
|
||||
'donation_amount': self.total_months_amount,
|
||||
'payment_month_count': self.donation_line_id.payment_month_count + self.months,
|
||||
}
|
||||
if self.direct_debit:
|
||||
|
|
|
|||
|
|
@ -77,6 +77,68 @@
|
|||
</form>
|
||||
</field>
|
||||
</page>
|
||||
<page string="Sub Payments" >
|
||||
<field name="payment_line_ids" nolabel="1">
|
||||
<tree editable="bottom" delete="true" create="true">
|
||||
<field name="payment_method" options="{'no_create': True, 'no_create_edit': True}"/>
|
||||
<field name="currency_id" invisible="1"/>
|
||||
<field name="donation_line_ids" invisible="1"/>
|
||||
<field name="payment_method_type" invisible="1"/>
|
||||
<field name="partner_id" invisible="1"/>
|
||||
<field name="journal_id" string="Association Journal"/>
|
||||
<field name="payment_amount" widget="monetary"
|
||||
options="{'currency_field': 'currency_id'}" force_save="1" sum="Total Amount"/>
|
||||
<field name="check_number"
|
||||
attrs="{
|
||||
'invisible': [
|
||||
('payment_method_type','!=','check')
|
||||
],
|
||||
'required': [
|
||||
('payment_method_type','=','check')
|
||||
]
|
||||
}"
|
||||
optional="hide"/>
|
||||
<field name="check_due_date"
|
||||
attrs="{
|
||||
'invisible': [
|
||||
('payment_method_type','!=','check')
|
||||
],
|
||||
'required': [
|
||||
('payment_method_type','=','check')
|
||||
]
|
||||
}"
|
||||
optional="hide"/>
|
||||
<field name="partner_bank_id"
|
||||
context="{
|
||||
'form_view_ref': 'odex_takaful.res_partner_bank_view_form_quick_create',
|
||||
'default_partner_id': context.get('force_sponsorship_line_partner_id')
|
||||
}"
|
||||
attrs="{
|
||||
'required': [
|
||||
('payment_method_type','=','bank')
|
||||
],
|
||||
'invisible': [
|
||||
('payment_method_type','!=','bank')
|
||||
]
|
||||
}"
|
||||
readonly="0"
|
||||
optional="hide"/>
|
||||
<field name="payment_file_attachment"
|
||||
widget="binary"
|
||||
filename="payment_file_attachment_name"
|
||||
attrs="{
|
||||
'invisible': [
|
||||
('payment_method_type','not in',['bank', 'check'])
|
||||
],
|
||||
'required': ['|',
|
||||
('payment_method_type','=','bank'),
|
||||
('payment_method_type','=','check')
|
||||
]
|
||||
}"
|
||||
optional="hide"/>
|
||||
</tree>
|
||||
</field>
|
||||
</page>
|
||||
</notebook>
|
||||
</sheet>
|
||||
<footer>
|
||||
|
|
|
|||
|
|
@ -130,46 +130,46 @@ class ReplacementWiz(models.TransientModel):
|
|||
('sponsor_related_id', '=', False),
|
||||
('general_restriction', '=', False)
|
||||
]])
|
||||
if rec.old_members_id.relationn.relation_type in ['mother','replacement_mother']:
|
||||
# if rec.old_members_id.relationn.relation_type in ['mother','replacement_mother']:
|
||||
# domain = expression.AND([domain, [
|
||||
# ('relationn.relation_type', 'in', ['mother', 'replacement_mother'])
|
||||
# ]])
|
||||
# elif rec.old_members_id.relationn.relation_type in ['son','daughter']:
|
||||
# domain = expression.AND([domain, [
|
||||
# ('relationn.relation_type', 'in', ['son', 'daughter'])
|
||||
# ]])
|
||||
if 1 <= rec.old_members_id.age <= 6:
|
||||
domain = expression.AND([domain, [
|
||||
('relationn.relation_type', 'in', ['mother', 'replacement_mother'])
|
||||
('age', '>=',1)
|
||||
]])
|
||||
elif rec.old_members_id.relationn.relation_type in ['son','daughter']:
|
||||
domain = expression.AND([domain, [
|
||||
('relationn.relation_type', 'in', ['son', 'daughter'])
|
||||
('age', '<=', 6)
|
||||
]])
|
||||
elif 7 <= rec.old_members_id.age <= 10:
|
||||
domain = expression.AND([domain, [
|
||||
('age', '>=',7)
|
||||
]])
|
||||
domain = expression.AND([domain, [
|
||||
('age', '<=', 10)
|
||||
]])
|
||||
elif 11 <= rec.old_members_id.age <= 15:
|
||||
domain = expression.AND([domain, [
|
||||
('age', '>=',11)
|
||||
]])
|
||||
domain = expression.AND([domain, [
|
||||
('age', '<=', 15)
|
||||
]])
|
||||
elif 16 <= rec.old_members_id.age <= 18:
|
||||
domain = expression.AND([domain, [
|
||||
('age', '>=',16)
|
||||
]])
|
||||
domain = expression.AND([domain, [
|
||||
('age', '<=', 18)
|
||||
]])
|
||||
elif rec.old_members_id.age > 18:
|
||||
domain = expression.AND([domain, [
|
||||
('age', '>',18)
|
||||
]])
|
||||
if 1 <= rec.old_members_id.age <= 6:
|
||||
domain = expression.AND([domain, [
|
||||
('age', '>=',1)
|
||||
]])
|
||||
domain = expression.AND([domain, [
|
||||
('age', '<=', 6)
|
||||
]])
|
||||
elif 7 <= rec.old_members_id.age <= 10:
|
||||
domain = expression.AND([domain, [
|
||||
('age', '>=',7)
|
||||
]])
|
||||
domain = expression.AND([domain, [
|
||||
('age', '<=', 10)
|
||||
]])
|
||||
elif 11 <= rec.old_members_id.age <= 15:
|
||||
domain = expression.AND([domain, [
|
||||
('age', '>=',11)
|
||||
]])
|
||||
domain = expression.AND([domain, [
|
||||
('age', '<=', 15)
|
||||
]])
|
||||
elif 16 <= rec.old_members_id.age <= 18:
|
||||
domain = expression.AND([domain, [
|
||||
('age', '>=',16)
|
||||
]])
|
||||
domain = expression.AND([domain, [
|
||||
('age', '<=', 18)
|
||||
]])
|
||||
elif rec.old_members_id.age > 18:
|
||||
domain = expression.AND([domain, [
|
||||
('age', '>',18)
|
||||
]])
|
||||
|
||||
|
||||
members = self.env['family.member'].sudo().search(domain)
|
||||
|
|
|
|||
Loading…
Reference in New Issue