[ADD] Replace and add fields in Donation

This commit is contained in:
odoo-syria-team 2025-11-18 13:41:26 +03:00
parent 775e3e5ab1
commit d0b8b35489
7 changed files with 167 additions and 97 deletions

View File

@ -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>"

View File

@ -99,6 +99,34 @@ 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="تاريخ الانتظار",
compute="_compute_dates",
store=True
)
replace_date = fields.Date(
string="تاريخ الاستبدال",
compute="_compute_dates",
store=True
)
@api.depends('state')
def _compute_dates(self):
"""Automatically set waiting_date or replace_date based on state."""
for rec in self:
if rec.state == 'waiting':
print(date.today())
rec.waiting_date = date.today()
rec.replace_date = False
elif rec.state == 'replace':
rec.replace_date = date.today()
rec.waiting_date = False
else:
rec.waiting_date = False
rec.replace_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)
@ -864,6 +892,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

View File

@ -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 , replace_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"/>
@ -84,6 +85,8 @@
<field name="benefit_id" optional="hide" />
<field name="sponsorship_creation_date" />
<field name="create_date" optional="hide"/>
<field name="waiting_date" widget="date" optional="hide"/>
<field name="replace_date" widget="date" optional="hide"/>
<field name="state" widget="badge"
decoration-muted="state == 'draft'"
decoration-warning="state == 'waiting'"
@ -179,6 +182,7 @@
<group>
<group string="Donation Information">
<field name="ages" invisible="1" />
<field name="waiting_date" widget="date" />
<field name="donation_type" invisible="1"/>
<field name="donation_types"
attrs="{'invisible': [('donation_type', '!=', 'donation')], 'readonly': [('parent_state', '!=', 'draft')]}" />
@ -362,16 +366,18 @@
<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="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="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>

View File

@ -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 -->
@ -27,7 +29,7 @@
<menuitem id="sponsorship_cancellation_menu" name="Sponsorship Cancellation"
parent="kafalat_main_menu" action="sponsorship_cancellation_action" sequence="3" />
<menuitem id="takaful_contribution_app_menu" name="The Financial Contributions"
<menuitem id="takaful_contribution_app_menu" name="The Financial Contributions"
parent="kafalat_main_menu" action="takaful_financial_contribution_action" sequence="4"/>
<menuitem id="takaful_push_notification_menu" name="Notifications Messages"
@ -141,4 +143,4 @@
<!-- END Kufala Settings -->
</odoo>
</odoo>

View File

@ -514,6 +514,7 @@
<group>
<group>
<field name="ages" invisible="1"/>
<field name="waiting_date" widget="date"/>
<field name="family_id"
attrs="{'invisible': [('sponsorship_type','=','group'), ('parent.record_type','=','sponsorship')],
'readonly': ['|', ('sponsorship_type', '!=', 'group'), ('parent.record_type','!=','donation')],

View File

@ -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:
@ -48,6 +54,7 @@ class AccountRegisterPayment(models.TransientModel):
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):
@ -66,6 +73,7 @@ class AccountRegisterPayment(models.TransientModel):
rec.takaful_payment_method = "bank"
else:
rec.takaful_payment_method = "cash"
def _create_payments(self):
sponsorship_line_ids = self.env.context.get('sponsorship_line_ids')

View File

@ -10,14 +10,15 @@
<xpath expr="//field[@name='amount']" position="after">
<field name="is_refund_sponsorship" invisible="1"/>
</xpath>
<!-- <xpath expr="//field[@name='amount']" position="attributes">-->
<!-- <attribute name="attrs">{'readonly':[('group_payment','=',True)]}</attribute>-->
<!-- </xpath>-->
<!-- <xpath expr="//field[@name='amount']" position="attributes">-->
<!-- <attribute name="attrs">{'readonly':[('group_payment','=',True)]}</attribute>-->
<!-- </xpath>-->
<xpath expr="//field[@name='journal_id']" position="attributes">
<attribute name="attrs">{'readonly':[('is_refund_sponsorship','=',True)]}</attribute>
<attribute name="attrs">
{'readonly': [('is_refund_sponsorship', '=', True)]}
</attribute>
<attribute name="string">Association Journal</attribute>
</xpath>
<xpath expr="//field[@name='partner_bank_id']" position="attributes">
<attribute name="invisible">context.get('sponsorship_payment')</attribute>
</xpath>
@ -25,7 +26,7 @@
<xpath expr="//field[@name='payment_method_line_id']" position="attributes">
<attribute name="invisible">context.get('sponsorship_payment')</attribute>
</xpath>
<xpath expr="//field[@name='branch_id']" position="attributes">
<attribute name="invisible">context.get('sponsorship_payment')</attribute>
</xpath>
@ -35,94 +36,99 @@
</xpath>
<xpath expr="//field[@name='journal_id']" position="before">
<field name="takaful_payment_method_id" attrs="{'invisible': [('sponsorship_payment', '=', False)]}" options="{'no_create': True, 'no_create_edit': True}"/>
<field name="takaful_payment_method_id" attrs="{'invisible': [('sponsorship_payment', '=', False)]}"
options="{'no_create': True, 'no_create_edit': True}"/>
</xpath>
<xpath expr="//field[@name='partner_bank_id']" position="after">
<xpath expr="//field[@name='partner_bank_id']" position="after">
<field name="sponsorship_payment" invisible="1"/>
<field name="takaful_payment_method" invisible="1"/>
<!-- <field name="payment_method" attrs="{'invisible': [('sponsorship_payment', '=', False)]}"/>-->
<!-- <field name="payment_method" attrs="{'invisible': [('sponsorship_payment', '=', False)]}"/>-->
<field name="payment_method" invisible="1"/>
<field name="check_number" attrs="{'invisible': ['|', ('sponsorship_payment', '=', False), ('takaful_payment_method','!=','check')], 'required': [('sponsorship_payment', '=', True), ('takaful_payment_method','=','check')]}"/>
<field name="check_due_date" attrs="{'invisible': ['|', ('sponsorship_payment', '=', False), ('takaful_payment_method','!=','check')], 'required': [('sponsorship_payment', '=', True), ('takaful_payment_method','=','check')]}"/>
<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': [('sponsorship_payment', '=', True), ('takaful_payment_method','=','bank')], 'invisible': ['|', ('sponsorship_payment', '=', False), ('takaful_payment_method','!=','bank')]}"/>
<field name="check_number"
attrs="{'invisible': ['|', ('sponsorship_payment', '=', False), ('takaful_payment_method','!=','check')], 'required': [('sponsorship_payment', '=', True), ('takaful_payment_method','=','check')]}"/>
<field name="check_due_date"
attrs="{'invisible': ['|', ('sponsorship_payment', '=', False), ('takaful_payment_method','!=','check')], 'required': [('sponsorship_payment', '=', True), ('takaful_payment_method','=','check')]}"/>
<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': [('sponsorship_payment', '=', True), ('takaful_payment_method','=','bank')], 'invisible': ['|', ('sponsorship_payment', '=', False), ('takaful_payment_method','!=','bank')]}"/>
<field name="transaction_file_attachment" widget="binary"
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')]}"/>
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')]}"/>
<field name="transaction_attachment_file_name" invisible="1"/>
</xpath>
<!--<xpath expr="//group" position="after">-->
<!-- <notebook>-->
<!-- <page string="Sub Payments" attrs="{'invisible': [('group_payment', '=', False)]}">-->
<!-- <field name="account_payment_register_ids" attrs="{'invisible': [('group_payment', '=', False)]}" nolabel="1">-->
<!-- <tree editable="bottom" delete="true" create="true">-->
<!-- <field name="sponsorship_payment" invisible="1"/>-->
<!-- <field name="takaful_payment_method" invisible="1"/>-->
<!-- <field name="available_partner_bank_ids" invisible="1"/>-->
<!-- <field name="company_id" invisible="1"/>-->
<!-- <field name="takaful_payment_method_id" options="{'no_create': True, 'no_create_edit': True}"/>-->
<!-- <field name="journal_id" string="Association Journal"/>-->
<!-- <field name="amount"/>-->
<!-- <field name="check_number"-->
<!-- attrs="{-->
<!-- 'invisible': [-->
<!-- ('takaful_payment_method','!=','check')-->
<!-- ],-->
<!-- 'required': [-->
<!-- ('takaful_payment_method','=','check')-->
<!-- ]-->
<!-- }"-->
<!-- optional="hide"/>-->
<!-- <field name="check_due_date"-->
<!-- attrs="{-->
<!-- 'invisible': [-->
<!-- ('takaful_payment_method','!=','check')-->
<!-- ],-->
<!-- 'required': [-->
<!-- ('takaful_payment_method','=','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': [-->
<!-- ('takaful_payment_method','=','bank')-->
<!-- ],-->
<!-- 'invisible': [-->
<!-- ('takaful_payment_method','!=','bank')-->
<!-- ]-->
<!-- }"-->
<!-- readonly="0"-->
<!-- optional="hide"/>-->
<!-- <field name="transaction_file_attachment"-->
<!-- widget="binary"-->
<!-- filename="transaction_attachment_file_name"-->
<!-- attrs="{-->
<!-- 'invisible': [-->
<!-- ('takaful_payment_method','not in',['bank', 'check'])-->
<!-- ],-->
<!-- 'required': ['|',-->
<!-- ('takaful_payment_method','=','bank'),-->
<!-- ('takaful_payment_method','=','check')-->
<!-- ]-->
<!-- }"-->
<!-- optional="hide"/>-->
<!-- </tree>-->
<!-- </field>-->
<!-- </page>-->
<!-- </notebook>-->
<!-- </xpath>-->
<!-- <xpath expr="//footer/button[@name='action_create_payments']" position="after">-->
<!-- <button name="action_register_all_lines"-->
<!-- type="object"-->
<!-- string="Register All Lines"-->
<!-- class="btn-secondary"-->
<!-- attrs="{'invisible': [('line_ids','=',False)]}"/>-->
<!-- </xpath>-->
</xpath>
<!--<xpath expr="//group" position="after">-->
<!-- <notebook>-->
<!-- <page string="Sub Payments" attrs="{'invisible': [('group_payment', '=', False)]}">-->
<!-- <field name="account_payment_register_ids" attrs="{'invisible': [('group_payment', '=', False)]}" nolabel="1">-->
<!-- <tree editable="bottom" delete="true" create="true">-->
<!-- <field name="sponsorship_payment" invisible="1"/>-->
<!-- <field name="takaful_payment_method" invisible="1"/>-->
<!-- <field name="available_partner_bank_ids" invisible="1"/>-->
<!-- <field name="company_id" invisible="1"/>-->
<!-- <field name="takaful_payment_method_id" options="{'no_create': True, 'no_create_edit': True}"/>-->
<!-- <field name="journal_id" string="Association Journal"/>-->
<!-- <field name="amount"/>-->
<!-- <field name="check_number"-->
<!-- attrs="{-->
<!-- 'invisible': [-->
<!-- ('takaful_payment_method','!=','check')-->
<!-- ],-->
<!-- 'required': [-->
<!-- ('takaful_payment_method','=','check')-->
<!-- ]-->
<!-- }"-->
<!-- optional="hide"/>-->
<!-- <field name="check_due_date"-->
<!-- attrs="{-->
<!-- 'invisible': [-->
<!-- ('takaful_payment_method','!=','check')-->
<!-- ],-->
<!-- 'required': [-->
<!-- ('takaful_payment_method','=','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': [-->
<!-- ('takaful_payment_method','=','bank')-->
<!-- ],-->
<!-- 'invisible': [-->
<!-- ('takaful_payment_method','!=','bank')-->
<!-- ]-->
<!-- }"-->
<!-- readonly="0"-->
<!-- optional="hide"/>-->
<!-- <field name="transaction_file_attachment"-->
<!-- widget="binary"-->
<!-- filename="transaction_attachment_file_name"-->
<!-- attrs="{-->
<!-- 'invisible': [-->
<!-- ('takaful_payment_method','not in',['bank', 'check'])-->
<!-- ],-->
<!-- 'required': ['|',-->
<!-- ('takaful_payment_method','=','bank'),-->
<!-- ('takaful_payment_method','=','check')-->
<!-- ]-->
<!-- }"-->
<!-- optional="hide"/>-->
<!-- </tree>-->
<!-- </field>-->
<!-- </page>-->
<!-- </notebook>-->
<!-- </xpath>-->
<!-- <xpath expr="//footer/button[@name='action_create_payments']" position="after">-->
<!-- <button name="action_register_all_lines"-->
<!-- type="object"-->
<!-- string="Register All Lines"-->
<!-- class="btn-secondary"-->
<!-- attrs="{'invisible': [('line_ids','=',False)]}"/>-->
<!-- </xpath>-->
</field>
</record>