|
|
@ -23,7 +23,7 @@ class DonationDonation(models.Model): |
|
|
|
string='Operation', |
|
|
|
track_visibility='onchange', |
|
|
|
ondelete='restrict', |
|
|
|
required=True, |
|
|
|
# required=True, |
|
|
|
domain=[('state', '=', 'exported')] |
|
|
|
|
|
|
|
) |
|
|
@ -33,7 +33,7 @@ class DonationDonation(models.Model): |
|
|
|
'opendons.segment', |
|
|
|
string='Segment', |
|
|
|
track_visibility='onchange', |
|
|
|
required=True, |
|
|
|
# required=True, |
|
|
|
ondelete='restrict' |
|
|
|
|
|
|
|
) |
|
|
@ -99,6 +99,19 @@ class DonationDonation(models.Model): |
|
|
|
], |
|
|
|
compute='_compute_payment_state', store=True) |
|
|
|
|
|
|
|
@api.onchange("recurring_template") |
|
|
|
def recurring_template_change(self): |
|
|
|
res = {"warning": {}} |
|
|
|
if self.recurring_template and self.tax_receipt_option == "each": |
|
|
|
self.tax_receipt_option = "annual" |
|
|
|
|
|
|
|
if not self.recurring_template and self.commercial_partner_id: |
|
|
|
if self.commercial_partner_id.tax_receipt_option != self.tax_receipt_option: |
|
|
|
self.tax_receipt_option = self.commercial_partner_id.tax_receipt_option |
|
|
|
return res |
|
|
|
|
|
|
|
def create_mandate(self): |
|
|
|
return True |
|
|
|
def generate_each_tax_receipt(self): |
|
|
|
#pas de création du RF à la validation du don, mais génération des RF ponctuels en mode batch |
|
|
|
return False |
|
|
@ -204,7 +217,7 @@ class DonationDonation(models.Model): |
|
|
|
rec.year_donation_date=rec.donation_date.year |
|
|
|
def _default_payment_mode_id(self): |
|
|
|
|
|
|
|
#raise Warning(self.recurring_template) |
|
|
|
|
|
|
|
if self.recurring_template=='active': |
|
|
|
|
|
|
|
sepa_payment_method=self.env['account.payment.method'].search([('code','=','sepa_direct_debit')],limit=1) |
|
|
@ -232,9 +245,21 @@ class DonationDonation(models.Model): |
|
|
|
@api.model |
|
|
|
def create(self, vals): |
|
|
|
#vals['tax_receipt_option']='annual' |
|
|
|
if vals['tax_receipt_option']!='annual': raise Warning('The tax receipt option must be annual') |
|
|
|
|
|
|
|
#si montant du PA=0 => message |
|
|
|
total=0 |
|
|
|
if not vals['line_ids']: |
|
|
|
raise Warning('please add a donation line') |
|
|
|
else: |
|
|
|
for line_d in vals['line_ids']: |
|
|
|
|
|
|
|
total=total+float(line_d[2]['unit_price']) |
|
|
|
if total==0:raise Warning('The total amount is null') |
|
|
|
res = super(DonationDonation, self).create(vals) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#si don hors lot de paiement,ne provenant pas d'un PA : création auto du lot de paiement |
|
|
|
if not res.payment_batch_id and res.state!='draft' and res.source_recurring_id==False : |
|
|
|
vals={} |
|
|
@ -633,6 +658,7 @@ class DonationDonation(models.Model): |
|
|
|
else: |
|
|
|
raise Warning('Please configure method sepa payment') |
|
|
|
|
|
|
|
today=fields.Date.context_today(self) |
|
|
|
action = self.env.ref("opendons.donation_recurring_action").sudo().read([])[0] |
|
|
|
|
|
|
|
action.update( |
|
|
@ -640,13 +666,46 @@ class DonationDonation(models.Model): |
|
|
|
"res_model": 'donation.donation', |
|
|
|
"view_mode": 'tree,form,pivot,graph', |
|
|
|
"context": {'default_recurring_template': 'active', 'recurring_view': True,'default_payment_mode_id':payment_mode_id, |
|
|
|
'default_tax_receipt_option':'annual'}, |
|
|
|
'default_tax_receipt_option':'annual', |
|
|
|
'default_donation_date':today}, |
|
|
|
"domain": [('recurring_template', '!=', False)] |
|
|
|
} |
|
|
|
) |
|
|
|
|
|
|
|
return action |
|
|
|
|
|
|
|
def recurring_donation_action_partner(self): |
|
|
|
|
|
|
|
partner_id = self._context.get('active_id') |
|
|
|
|
|
|
|
sepa_payment_method=self.env['account.payment.method'].search([('code','=','sepa_direct_debit')]) |
|
|
|
if sepa_payment_method: |
|
|
|
sepa_payment_mode=self.env['account.payment.mode'].search([('payment_method_id','=',int( sepa_payment_method))]) |
|
|
|
if sepa_payment_mode: |
|
|
|
payment_mode_id=sepa_payment_mode.id |
|
|
|
else: |
|
|
|
raise Warning('Please configure mode sepa payment') |
|
|
|
|
|
|
|
else: |
|
|
|
raise Warning('Please configure method sepa payment') |
|
|
|
|
|
|
|
|
|
|
|
action = self.env.ref("opendons.donation_recurring_action").sudo().read([])[0] |
|
|
|
today=fields.Date.context_today(self) |
|
|
|
action.update( |
|
|
|
{ |
|
|
|
"res_model": 'donation.donation', |
|
|
|
"view_mode": 'tree,form,pivot,graph', |
|
|
|
"context": {'default_recurring_template': 'active', 'recurring_view': True, |
|
|
|
'default_payment_mode_id':payment_mode_id,'default_partner_id':partner_id, |
|
|
|
'default_tax_receipt_option':'annual', |
|
|
|
'default_donation_date':today}, |
|
|
|
"domain": [('recurring_template', '!=', False),('partner_id','=',partner_id)] |
|
|
|
} |
|
|
|
) |
|
|
|
|
|
|
|
return action |
|
|
|
|
|
|
|
def payment_order_action(self): |
|
|
|
|
|
|
|
|
|
|
|