Browse Source

correction PA

master
root 3 years ago
parent
commit
ea80936f17
5 changed files with 91 additions and 12 deletions
  1. +61
    -2
      models/donation.py
  2. +1
    -1
      views/donation.xml
  3. +2
    -2
      views/fls.xml
  4. +1
    -1
      views/partner.xml
  5. +26
    -6
      views/recurring_donation.xml

+ 61
- 2
models/donation.py View File

@ -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):


+ 1
- 1
views/donation.xml View File

@ -8,7 +8,7 @@
<xpath expr="//field[@name='donation_date']" position="after">
<field string="Payment state" name="payment_state"/>
<field string="Payment state" invisible="context.get('recurring_view')" name="payment_state"/>
</xpath>


+ 2
- 2
views/fls.xml View File

@ -10,11 +10,11 @@
</record>
<menuitem id="fls_title_menu" name ="fls"
<!-- <menuitem id="fls_title_menu" name ="fls"
parent="contacts.menu_contacts" sequence="4"/>
<menuitem id="flst_menu" action="fls_action" name ="fls data"
parent="fls_title_menu" sequence="1"/>
parent="fls_title_menu" sequence="1"/> -->
</data>
</odoo>

+ 1
- 1
views/partner.xml View File

@ -209,7 +209,7 @@
/>
</button>
<button class="oe_stat_button" type="action"
name="%(act_partner_recurring_donation)d"
name="%(recurring_action_tmp2)d"
icon="fa-heart-o">
<field string="Recurring_donation" name="recurring_donation_count" widget="statinfo"/>


+ 26
- 6
views/recurring_donation.xml View File

@ -47,12 +47,12 @@
<xpath expr="//field[@name='payment_ref']" position="replace">
</xpath>
<xpath expr="//label[@for='tax_receipt_option']" position="replace">
</xpath>
<xpath expr="//div[@name='tax_receipt_option']" position="attributes">
<!-- <xpath expr="//label[@for='tax_receipt_option']" position="replace">
</xpath> -->
<!-- <xpath expr="//div[@name='tax_receipt_option']" position="attributes">
<attribute name="invisible">context.get('recurring_view')</attribute>
</xpath>
</xpath> -->
<xpath expr="//field[@name='company_id']" position="replace">
<field name="company_id" invisible="context.get('recurring_view')"/>
@ -60,6 +60,13 @@
</xpath>
<xpath expr="//button[@name='done2cancel']" position="after">
<button
name="create_mandate"
type="object"
string="Create a mandate"
attrs="{'invisible': ['|',('recurring_template', 'not in', ('active','suspended')),('partner_id','=',False)]}"
groups="donation.group_donation_user"/>
<button
name="active2stopped"
type="object"
@ -113,9 +120,10 @@
<field name="mandate_id" attrs="{'readonly':[('recurring_template','=','stopped')]}"/>
</xpath>
<xpath expr="//field[@name='mandate_id']" position="attributes">
<!-- <xpath expr="//field[@name='mandate_id']" position="attributes">
<attribute name="options">{'no_create_edit': True,'no_create': True}</attribute>
</xpath>
</xpath> -->
</field>
</record>
@ -138,6 +146,10 @@
<field name="frequency" invisible="not context.get('recurring_view')"/>
</xpath>
<!-- <xpath expr="//field[@name='payment_state']" position="attribute">
<attribute name="invisible">context.get('recurring_view')</attribute>
</xpath> -->
</field>
</record>
@ -204,6 +216,14 @@
action = model.sudo().recurring_donation_action()
</field>
</record>
<record model="ir.actions.server" id="recurring_action_tmp2">
<field name="name">resume res_id action partner</field>
<field name="model_id" ref="opendons.model_donation_donation"/>
<field name="state">code</field>
<field name="code">
action = model.sudo().recurring_donation_action_partner()
</field>
</record>
<record model="ir.actions.server" id="ir_action_payment_order">
<field name="name">Payment order</field>


Loading…
Cancel
Save