root 3 years ago
parent
commit
52a11ad65e
8 changed files with 100 additions and 19 deletions
  1. +63
    -4
      models/donation.py
  2. +2
    -1
      models/duplicate.py
  3. +2
    -2
      models/partner.py
  4. +1
    -1
      views/donation.xml
  5. +1
    -0
      views/duplicate.xml
  6. +2
    -2
      views/fls.xml
  7. +1
    -1
      views/partner.xml
  8. +28
    -8
      views/recurring_donation.xml

+ 63
- 4
models/donation.py View File

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


+ 2
- 1
models/duplicate.py View File

@ -21,8 +21,9 @@ class opendons_duplicate_partner(models.Model):
index=True,
readonly=True,
track_visibility='onchange',
ondelete='restrict'
ondelete='cascade'
)
user_ids=fields.One2many(related='partner_id.user_ids')
def find_duplicate_partner(self):
self.env['opendons.duplicate_partner'].search([]).unlink()


+ 2
- 2
models/partner.py View File

@ -108,7 +108,7 @@ class partner(models.Model):
npai_count=fields.Integer(String="NPAI count", readonly=True)
source=fields.Char(String="source")
donor_id=fields.Char('Donor id',compute="_compute_donor_id",store=True)
donor_id=fields.Char('Donor id',readonly=True)
aggregate_id=fields.Many2one('opendons.aggregate.partner','partner_id')
@ -170,7 +170,7 @@ class partner(models.Model):
# Change the values of a variable in this super function
record['key'] = self._alpha(int(record.id))
record.donor_id=str(record.id)+record.key
# Return the record so that the changes are applied and everything is stored.
return record


+ 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>


+ 1
- 0
views/duplicate.xml View File

@ -20,6 +20,7 @@
<field name="arch" type="xml">
<tree>
<field name="partner_id"/>
<field name="user_ids"/>
</tree>
</field>


+ 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"/>


+ 28
- 8
views/recurring_donation.xml View File

@ -15,8 +15,8 @@
<field name="end_date" attrs="{'readonly':[('recurring_template','=','stopped')],'invisible':[('recurring_template','not in',('active','suspended','stopped'))]}"/>
<field name="stopped_date" attrs="{'invisible':['|',('recurring_template','not in',('active','suspended','stopped')),('stopped_date','=',False)]}"/>
<field name="stopped_reason" attrs="{'readonly':[('recurring_template','=','stopped')],'invisible':['|',('recurring_template','not in',('active','suspended','stopped')),('stopped_date','=',False)]}"/>
<field name="operation_id" attrs="{'readonly':['|',('recurring_template','=','stopped'),('state','in',['done','cancel'])]}" options="{'no_open': True, 'no_create': True}" can_create="true" can_write="true"/>
<field name="segment_id" attrs="{'readonly':['|',('recurring_template','=','stopped'),('state','in',['done','cancel'])]}" options="{'no_open': True, 'no_create': True}" can_create="true" can_write="true"/>
<field name="operation_id" attrs="{'readonly':[('recurring_template','=','stopped')]}" options="{'no_open': True, 'no_create': True}" can_create="true" can_write="true"/>
<field name="segment_id" attrs="{'readonly':[('recurring_template','=','stopped')]}" options="{'no_open': True, 'no_create': True}" can_create="true" can_write="true"/>
<field name="frequency" attrs="{'readonly':[('recurring_template','=','stopped')],'invisible':[('recurring_template','not in',('active','suspended','stopped'))]}"/>
@ -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