Merge pull request #5584 from expsa/search_res_partner
[FIX] search res partner by phone
This commit is contained in:
commit
28a3aee701
|
|
@ -135,6 +135,26 @@ class ResPartner(models.Model):
|
|||
if is_family_or_beneficiary and is_donor_vendor_sponsor:
|
||||
raise ValidationError(_("A contact cannot be both Family/Beneficiary and Donor/Member/Sponsor at the same time!"))
|
||||
|
||||
@api.model
|
||||
def search(self, args, offset=0, limit=None, order=None, count=False):
|
||||
|
||||
if not self.env.context.get('from_contact_search'):
|
||||
return super().search(args, offset=offset, limit=limit, order=order, count=count)
|
||||
|
||||
if self.env.context.get('mail_read') or self.env.context.get('mail_message_origin'):
|
||||
return super().search(args, offset=offset, limit=limit, order=order, count=count)
|
||||
|
||||
base_results = super().search(args, offset=offset, limit=limit, order=order)
|
||||
|
||||
if not base_results:
|
||||
return base_results
|
||||
|
||||
children = super().search([('parent_id', 'in', base_results.ids)])
|
||||
|
||||
final_ids = list(set(base_results.ids + children.ids))
|
||||
|
||||
return super().search([('id', 'in', final_ids)], offset=0, limit=limit, order=order, count=count)
|
||||
|
||||
@api.model
|
||||
def _name_search(self, name, args=None, operator='ilike', limit=100, name_get_uid=None):
|
||||
if not args:
|
||||
|
|
|
|||
|
|
@ -196,16 +196,7 @@
|
|||
<field name="perm_create" eval="1"/>
|
||||
<field name="perm_unlink" eval="1"/>
|
||||
</record>
|
||||
<record id="branch_manager_restrictions_lines" model="ir.rule">
|
||||
<field name="name">Branch Manager can only see all his branch sponsorships and donations Lines</field>
|
||||
<field name="model_id" ref="model_donations_details_lines"/>
|
||||
<field name="groups" eval="[(4, ref('branch_manager_group'))]"/>
|
||||
<field name="domain_force">[('branch_custom_id.branch.manager_id.user_id', 'in', [user.id, False])]</field>
|
||||
<field name="perm_read" eval="1"/>
|
||||
<field name="perm_write" eval="1"/>
|
||||
<field name="perm_create" eval="1"/>
|
||||
<field name="perm_unlink" eval="1"/>
|
||||
</record>
|
||||
|
||||
<record id="sponsorship_system_manager_group" model="res.groups">
|
||||
<field name="name">Sponsorship System Manager</field>
|
||||
<field name="category_id" ref="module_category_kufula"/>
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
<field name="acc_holder_name"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="bank_id"/>
|
||||
<field name="bank_id" required="1"/>
|
||||
<field name="partner_id" readonly="1"/>
|
||||
</group>
|
||||
</group>
|
||||
|
|
|
|||
|
|
@ -187,10 +187,10 @@
|
|||
|
||||
</notebook>
|
||||
</sheet>
|
||||
<footer>
|
||||
<button name="action_save_and_close" string="حفظ وإغلاق" type="object" class="btn-primary"/>
|
||||
<button string="تجاهل" class="btn-secondary" special="cancel"/>
|
||||
</footer>
|
||||
<!-- <footer>-->
|
||||
<!-- <button name="action_save_and_close" string="حفظ وإغلاق" type="object" class="btn-primary"/>-->
|
||||
<!-- <button string="تجاهل" class="btn-secondary" special="cancel"/>-->
|
||||
<!-- </footer>-->
|
||||
<div class="oe_chatter">
|
||||
<field name="message_follower_ids" widget="mail_followers"/>
|
||||
<field name="message_ids" widget="mail_thread"/>
|
||||
|
|
@ -210,7 +210,8 @@
|
|||
'default_company_type': 'person',
|
||||
'default_is_sponsor_portal': True,
|
||||
'default_is_donor': True,
|
||||
'sponsor_contact': True
|
||||
'sponsor_contact': True,
|
||||
'from_contact_search': True
|
||||
}
|
||||
</field>
|
||||
</record>
|
||||
|
|
@ -249,6 +250,20 @@
|
|||
</field>
|
||||
</record>
|
||||
|
||||
<!-- <record id="res_partner_phone_filter" model="ir.ui.view">-->
|
||||
<!-- <field name="name">res.partner.phone.filter</field>-->
|
||||
<!-- <field name="model">res.partner</field>-->
|
||||
<!-- <field name="inherit_id" ref="base.view_res_partner_filter"/>-->
|
||||
<!-- <field name="arch" type="xml">-->
|
||||
|
||||
<!-- <xpath expr="//search" position="attributes">-->
|
||||
<!-- <attribute name="context">{'from_contact_search': True}</attribute>-->
|
||||
<!-- </xpath>-->
|
||||
|
||||
<!-- </field>-->
|
||||
<!-- </record>-->
|
||||
|
||||
|
||||
<!-- Unarchive Sponsor -->
|
||||
<record id="activate_sponsor_multi" model="ir.actions.server">
|
||||
<field name="name">Make Active</field>
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@
|
|||
<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="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')]}" create="1" edit="1"/>
|
||||
<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')]}"/>
|
||||
|
|
|
|||
|
|
@ -263,6 +263,12 @@ class DonationExtensionWizardLine(models.TransientModel):
|
|||
compute='_compute_new_end_date',
|
||||
readonly=True
|
||||
)
|
||||
extension_invoice_id = fields.Many2one(
|
||||
'account.move',
|
||||
string="Extension Invoice",
|
||||
readonly=True
|
||||
)
|
||||
|
||||
direct_debit_partner_bank_id = fields.Many2one("res.partner.bank", string="Direct Debit Partner Bank", domain="[('partner_id', '=', partner_id)]")
|
||||
debit_payment_file_attachment = fields.Binary(string='Debit Payment Attachment', attachment=True)
|
||||
debit_payment_attachment_file_name = fields.Char('Debit Payment File Name', required=False)
|
||||
|
|
@ -313,55 +319,56 @@ class DonationExtensionWizardLine(models.TransientModel):
|
|||
|
||||
if not self.donation_line_id:
|
||||
raise ValidationError(_("No donation detail line selected."))
|
||||
|
||||
# Update the donation detail line
|
||||
new_end_date = self.current_end_date + relativedelta(months=self.months)
|
||||
old_end_date = self.current_end_date
|
||||
|
||||
# Update end date
|
||||
donation_line_new_vals = {
|
||||
'end_date': new_end_date,
|
||||
'payment_month_count': self.donation_line_id.payment_month_count + self.months,
|
||||
}
|
||||
if self.direct_debit:
|
||||
donation_line_new_vals.update({
|
||||
'direct_debit': self.direct_debit,
|
||||
'direct_debit_partner_bank_id': self.direct_debit_partner_bank_id.id,
|
||||
'journal_id': self.journal_id.id,
|
||||
'debit_payment_file_attachment': self.debit_payment_file_attachment,
|
||||
'debit_payment_attachment_file_name': self.debit_payment_attachment_file_name,
|
||||
})
|
||||
self.donation_line_id.write(donation_line_new_vals)
|
||||
if not self.extension_invoice_id:
|
||||
# Update the donation detail line
|
||||
new_end_date = self.current_end_date + relativedelta(months=self.months)
|
||||
old_end_date = self.current_end_date
|
||||
|
||||
benefit_ids = self.donation_line_id.benefit_ids | self.donation_line_id.benefit_id
|
||||
benefit_ids.write({
|
||||
'sponsorship_end_date': new_end_date,
|
||||
'kafala_status': 'have_kafala',
|
||||
})
|
||||
|
||||
# Create new scheduling lines for the extension period
|
||||
if self.direct_debit:
|
||||
self._create_extension_scheduling_lines()
|
||||
|
||||
# Create invoice for the extension
|
||||
invoice_id = self._create_extension_invoice()
|
||||
|
||||
# Create extension history record
|
||||
self.env['donation.extension.history'].create({
|
||||
'donation_detail_id': self.donation_line_id.id,
|
||||
'sponsorship_id': self.donation_line_id.sponsorship_id.id or self.donation_line_id.sponsorship_mechanism_id.id,
|
||||
'extension_amount': self.total_donation_amount,
|
||||
'extension_months': self.months,
|
||||
'old_end_date': old_end_date,
|
||||
'new_end_date': new_end_date,
|
||||
'invoice_id': invoice_id.id if invoice_id else False,
|
||||
'old_direct_debit': self.donation_line_id.direct_debit,
|
||||
'new_direct_debit': self.direct_debit,
|
||||
|
||||
})
|
||||
# Update end date
|
||||
donation_line_new_vals = {
|
||||
'end_date': new_end_date,
|
||||
'payment_month_count': self.donation_line_id.payment_month_count + self.months,
|
||||
}
|
||||
if self.direct_debit:
|
||||
donation_line_new_vals.update({
|
||||
'direct_debit': self.direct_debit,
|
||||
'direct_debit_partner_bank_id': self.direct_debit_partner_bank_id.id,
|
||||
'journal_id': self.journal_id.id,
|
||||
'debit_payment_file_attachment': self.debit_payment_file_attachment,
|
||||
'debit_payment_attachment_file_name': self.debit_payment_attachment_file_name,
|
||||
})
|
||||
self.donation_line_id.write(donation_line_new_vals)
|
||||
|
||||
benefit_ids = self.donation_line_id.benefit_ids | self.donation_line_id.benefit_id
|
||||
benefit_ids.write({
|
||||
'sponsorship_end_date': new_end_date,
|
||||
'kafala_status': 'have_kafala',
|
||||
})
|
||||
|
||||
# Create new scheduling lines for the extension period
|
||||
if self.direct_debit:
|
||||
self._create_extension_scheduling_lines()
|
||||
|
||||
# Create invoice for the extension
|
||||
invoice_id = self._create_extension_invoice()
|
||||
self.extension_invoice_id = invoice_id
|
||||
|
||||
# Create extension history record
|
||||
self.env['donation.extension.history'].create({
|
||||
'donation_detail_id': self.donation_line_id.id,
|
||||
'sponsorship_id': self.donation_line_id.sponsorship_id.id or self.donation_line_id.sponsorship_mechanism_id.id,
|
||||
'extension_amount': self.total_donation_amount,
|
||||
'extension_months': self.months,
|
||||
'old_end_date': old_end_date,
|
||||
'new_end_date': new_end_date,
|
||||
'invoice_id': invoice_id.id if invoice_id else False,
|
||||
'old_direct_debit': self.donation_line_id.direct_debit,
|
||||
'new_direct_debit': self.direct_debit,
|
||||
|
||||
})
|
||||
|
||||
if not self.direct_debit:
|
||||
return invoice_id, self.donation_line_id
|
||||
return self.extension_invoice_id, self.donation_line_id
|
||||
|
||||
|
||||
return False
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@
|
|||
<field name="direct_debit" force_save="1"/>
|
||||
<field name="direct_debit_partner_bank_id"
|
||||
context="{'form_view_ref': 'odex_takaful.res_partner_bank_view_form_quick_create', 'default_partner_id': partner_id}"
|
||||
attrs="{'invisible': [('direct_debit', '=', False)], 'required': [('direct_debit', '=', True)]}"/>
|
||||
attrs="{'invisible': [('direct_debit', '=', False)], 'required': [('direct_debit', '=', True)]}" create="1" edit="1"/>
|
||||
<field name="journal_id" attrs="{'invisible': [('direct_debit', '=', False)], 'required': [('direct_debit', '=', True)]}"/>
|
||||
<field name="debit_payment_file_attachment" widget="binary"
|
||||
filename="debit_payment_attachment_file_name"
|
||||
|
|
|
|||
Loading…
Reference in New Issue