Merge pull request #1933 from expsa/tasks_2_12

Sponsor(task04)
This commit is contained in:
enagahh 2024-12-18 02:39:48 +02:00 committed by GitHub
commit 5d15a7394f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 40 additions and 7 deletions

View File

@ -1169,7 +1169,7 @@ class DonationsDetailsLines(models.Model):
class PaymentDetailsLines(models.Model):
_name = "payment.details.lines"
payment_method = fields.Selection(selection=[("cash", "Cash"),("card", "Card"),("check", "Check"),("credit_card", "Credit Card")])
payment_method = fields.Selection(selection=[("cash", "Cash"),("card", "Card"),("check", "Check"),("credit_card", "Credit Card"),("bank_transfer", "Bank Transfer"),("direct_debit", "Direct Debit")])
donation_amount = fields.Float(string='Donation Amount')
donation_date = fields.Date(string='Donation Date',default=lambda self: fields.Date.today())
note = fields.Char(string='Note')
@ -1182,6 +1182,27 @@ class PaymentDetailsLines(models.Model):
check_number = fields.Char(string='Check Number')
account_payment_method = fields.Many2one('account.payment.method.line',domain="[('payment_type','=','inbound')]",string='Account Payment Method')
branch_custom_id = fields.Many2one('branch.settings', string="Branch",related='sponsorship_id.branch_custom_id')
sponsor_account_number = fields.Char(string='Sponsor Account Number')
sa_iban = fields.Char('SA',default='SA',readonly=True)
charity_bank_id = fields.Many2one('account.journal', string="charity Bank")
bank_transfer_amount = fields.Float(string='Bank Transfer Amount')
direct_debit_amount = fields.Float(string='Direct Debit Amount')
payment_attachment = fields.Many2many('ir.attachment', 'rel_attachment_payment_details', 'payment_id','attachment_id', string='Payment Attachment')
direct_debit_start_date = fields.Date(string='Direct Debit Start Date')
direct_debit_end_date = fields.Date(string='Direct Debit End Date')
@api.onchange('sponsor_account_number')
def onchange_sponsor_account_number(self):
if self.sponsor_account_number:
# Check if the value is numeric before anything else
if not self.sponsor_account_number.isdigit():
raise ValidationError(_("The account number should contain only digits."))
# Check if the account number contains exactly 22 digits
if len(self.sponsor_account_number) != 22:
raise ValidationError(_("The IBAN number must contain exactly 22 digits."))
@api.model

View File

@ -243,19 +243,31 @@
<group>
<group>
<field name="payment_method"/>
<field name="name" attrs="{'invisible': ['|','|',('payment_method','=','cash'),('payment_method','=','check'),('payment_method','=',False)]}"/>
<field name="direct_debit_start_date" attrs="{'invisible': [('payment_method','!=','direct_debit')]}"/>
<field name="name" attrs="{'invisible': [('payment_method','!=','card'),('payment_method','!=','debit_card')]}"/>
<field name="check_number" attrs="{'invisible': [('payment_method','!=','check')]}"/>
<field name="bank_id" attrs="{'invisible': ['|',('payment_method','=','cash'),('payment_method','=',False)]}"/>
<field name="journal_id" attrs="{'invisible': ['|','|',('payment_method','=','card'),('payment_method','=','credit_card'),('payment_method','=',False)]}"/>
<field name="charity_bank_id" attrs="{'invisible': [('payment_method','!=','bank_transfer'),('payment_method','!=','direct_debit')]}"/>
<label for="sponsor_account_number" attrs="{'invisible': [('payment_method','!=','bank_transfer'),('payment_method','!=','direct_debit')]}"/>
<div class="o_row" attrs="{'invisible': [('payment_method','!=','bank_transfer'),('payment_method','!=','direct_debit')]}">
<field name="sponsor_account_number" width="100%" />
<field name="sa_iban"/>
</div>
<field name="bank_transfer_amount" attrs="{'invisible': [('payment_method','!=','bank_transfer')]}"/>
<field name="direct_debit_amount" attrs="{'invisible': [('payment_method','!=','direct_debit')]}"/>
<field name="journal_id" attrs="{'invisible': [('payment_method','!=','cash'),('payment_method','!=','check')]}"/>
<field name="branch_custom_id" invisible="1"/>
<field name="points_of_sale" attrs="{'invisible': ['|','|',('payment_method','=','cash'),('payment_method','=','check'),('payment_method','=',False)]}"/>
<field name="points_of_sale" attrs="{'invisible': [('payment_method','!=','card'),('payment_method','!=','credit_card')]}"/>
</group>
<group>
<field name="direct_debit_end_date" attrs="{'invisible': [('payment_method','!=','direct_debit')]}"/>
<field name="donation_date"/>
<field name="charity_journal_id" attrs="{'invisible': ['|','|',('payment_method','=','cash'),('payment_method','=','check'),('payment_method','=',False)]}"/>
<field name="donation_amount"/>
<field name="account_payment_method" attrs="{'invisible': ['|','|',('payment_method','=','cash'),('payment_method','=','check'),('payment_method','=',False)]}"/>
<field name="charity_journal_id" attrs="{'invisible': [('payment_method','!=','card'),('payment_method','!=','credit_card')]}"/>
<field name="donation_amount" attrs="{'invisible': ['|',('payment_method','!=','bank_transfer'),('payment_method','!=','direct_debit')]}"/>
<field name="account_payment_method" attrs="{'invisible': [('payment_method','!=','card'),('payment_method','!=','credit_card')]}"/>
<field name="note"/>
<field name="payment_attachment" widget="many2many_attachment_preview" attrs="{'invisible': [('payment_method','!=','bank_transfer'),('payment_method','!=','direct_debit')]}"/>
</group>
</group>
</form>