From 78eff7b461c2b440016aa48a07f43c1f9ee8966d Mon Sep 17 00:00:00 2001 From: root Date: Wed, 31 Aug 2022 17:24:48 +0200 Subject: [PATCH] bug pa --- models/donation.py | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/models/donation.py b/models/donation.py index efc3441..53a6b1e 100644 --- a/models/donation.py +++ b/models/donation.py @@ -244,19 +244,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']: - # total=0 - # #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') + #vals['tax_receipt_option']='annual' + if vals['tax_receipt_option']!='annual' and vals['recurring_template']: raise Warning('The tax receipt option must be annual') + + #si montant du PA=0 => message + if vals.get('line_ids',None): + total=0 + if not vals['line_ids']: + total=0 + #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)