Browse Source

PA

master
root 3 years ago
parent
commit
e53e0f2f3c
6 changed files with 136 additions and 28 deletions
  1. +1
    -1
      __manifest__.py
  2. +12
    -0
      data/recurring_donation_configuration.xml
  3. +1
    -1
      models/__init__.py
  4. +32
    -20
      models/donation.py
  5. +71
    -0
      models/res_partner_bank.py
  6. +19
    -6
      views/donation.xml

+ 1
- 1
__manifest__.py View File

@ -20,7 +20,7 @@
'version': '0.1', 'version': '0.1',
# any module necessary for this one to work correctly # any module necessary for this one to work correctly
'depends': ['base','donation_recurring','website_sale'],
'depends': ['base','base_iban','donation_recurring','website_sale','donation','donation_base','donation_direct_debit'],
# always loaded # always loaded
'data': [ 'data': [


+ 12
- 0
data/recurring_donation_configuration.xml View File

@ -0,0 +1,12 @@
<odoo>
<data noupdate="1">
<record model="opendons.recurring_donation_configuration" id="num1">
<field name="generation_day">5</field>
<field name="limite_days_before">15</field>
</record>
</data>
</odoo>

+ 1
- 1
models/__init__.py View File

@ -17,4 +17,4 @@ from . import duplicate
from . import template_rf from . import template_rf
from . import donation_tax_receipt from . import donation_tax_receipt
from . import laposte_ref from . import laposte_ref
from . import res_partner_bank
#from . import res_partner_bank

+ 32
- 20
models/donation.py View File

@ -73,16 +73,16 @@ class DonationDonation(models.Model):
res = super(DonationDonation, self).create(vals) res = super(DonationDonation, self).create(vals)
#res.tax_receipt_option='annual' #res.tax_receipt_option='annual'
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:
res.payment_mode_id=sepa_payment_mode.id
else:
raise Warning('Please configure mode sepa payment')
# 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:
# res.payment_mode_id=sepa_payment_mode.id
# else:
# raise Warning('Please configure mode sepa payment')
else:
raise Warning('Please configure method sepa payment')
# else:
# raise Warning('Please configure method sepa payment')
return res return res
@ -218,7 +218,8 @@ class DonationDonation(models.Model):
apoo = self.env["account.payment.order"].sudo() apoo = self.env["account.payment.order"].sudo()
vals={} vals={}
vals['payment_mode_id']=payment_mode_id vals['payment_mode_id']=payment_mode_id
vals['sepa']=True
payorder = apoo.create(vals) payorder = apoo.create(vals)
@ -390,14 +391,25 @@ class DonationDonation(models.Model):
return return
def recurring_donation_action(self): def recurring_donation_action(self):
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] action = self.env.ref("opendons.donation_recurring_action").sudo().read([])[0]
action.update( action.update(
{ {
"res_model": 'donation.donation', "res_model": 'donation.donation',
"name": 'Prélèvements automatiques : mai 2022',
"view_mode": 'tree,form,pivot,graph', "view_mode": 'tree,form,pivot,graph',
"context": {'default_recurring_template': 'active', 'recurring_view': True,'default_tax_receipt_option':'annual'},
"context": {'default_recurring_template': 'active', 'recurring_view': True,'default_payment_mode_id':payment_mode_id,
'default_tax_receipt_option':'annual'},
"domain": [('recurring_template', '!=', False)] "domain": [('recurring_template', '!=', False)]
} }
) )
@ -406,16 +418,16 @@ class DonationDonation(models.Model):
def payment_order_action(self): def payment_order_action(self):
payorder=self.env['account.payment.order'].search([('state','=','draft')],order='create_date desc', limit=2)
#payorder=self.env['account.payment.order'].search([('state','=','draft')],order='create_date desc', limit=2)
action = self.env.ref("account_payment_order.account_payment_order_inbound_action").sudo().read([])[0] action = self.env.ref("account_payment_order.account_payment_order_inbound_action").sudo().read([])[0]
action.update(
{
"view_mode": "form",
"view_type":"list",
"res_id": payorder[0].id if payorder[0].id else False
}
)
# action.update(
# {
# "view_mode": "tree",
# "view_type":"list",
# #"res_id": payorder[0].id if payorder[0].id else False
# }
# )
return action return action

+ 71
- 0
models/res_partner_bank.py View File

@ -0,0 +1,71 @@
# -*- coding: utf-8 -*-
import re
from odoo import api, fields, models, _
from odoo.exceptions import UserError, ValidationError
class ResPartnerBank(models.Model):
_inherit = "res.partner.bank"
@api.model
def create(self, values):
values['acc_type']='iban'
res = super(ResPartnerBank, self).create(values)
# here you can do accordingly
return res
# class ResPartnerBank(models.Model):
# _inherit = 'res.partner.bank'
# @api.onchange('acc_number')
# def _onchange_acc_number(self):
# #validation IBAN
# #https://www.regextester.com/115565
# if self.acc_number:
# regex = re.compile(r'(^(?:(?:IT|SM)\d{2}[A-Z]\d{22}|CY\d{2}[A-Z]\d{23}|NL\d{2}[A-Z]{4}\d{10}|LV\d{2}[A-Z]{4}\d{13}|(?:BG|BH|GB|IE)\d{2}[A-Z]{4}\d{14}|GI\d{2}[A-Z]{4}\d{15}|RO\d{2}[A-Z]{4}\d{16}|KW\d{2}[A-Z]{4}\d{22}|MT\d{2}[A-Z]{4}\d{23}|NO\d{13}|(?:DK|FI|GL|FO)\d{16}|MK\d{17}|(?:AT|EE|KZ|LU|XK)\d{18}|(?:BA|HR|LI|CH|CR)\d{19}|(?:GE|DE|LT|ME|RS)\d{20}|IL\d{21}|(?:AD|CZ|ES|MD|SA)\d{22}|PT\d{23}|(?:BE|IS)\d{24}|(?:FR|MR|MC)\d{25}|(?:AL|DO|LB|PL)\d{26}|(?:AZ|HU)\d{27}|(?:GR|MU)\d{28})$)+')
# if not re.fullmatch(regex, self.acc_number):
# raise Warning('Invalid IBAN')
# @api.constrains('acc_number')
# def _onchange_acc_number(self):
# #validation IBAN
# #https://www.regextester.com/115565
# if self.acc_number:
# regex = re.compile(r'(^(?:(?:IT|SM)\d{2}[A-Z]\d{22}|CY\d{2}[A-Z]\d{23}|NL\d{2}[A-Z]{4}\d{10}|LV\d{2}[A-Z]{4}\d{13}|(?:BG|BH|GB|IE)\d{2}[A-Z]{4}\d{14}|GI\d{2}[A-Z]{4}\d{15}|RO\d{2}[A-Z]{4}\d{16}|KW\d{2}[A-Z]{4}\d{22}|MT\d{2}[A-Z]{4}\d{23}|NO\d{13}|(?:DK|FI|GL|FO)\d{16}|MK\d{17}|(?:AT|EE|KZ|LU|XK)\d{18}|(?:BA|HR|LI|CH|CR)\d{19}|(?:GE|DE|LT|ME|RS)\d{20}|IL\d{21}|(?:AD|CZ|ES|MD|SA)\d{22}|PT\d{23}|(?:BE|IS)\d{24}|(?:FR|MR|MC)\d{25}|(?:AL|DO|LB|PL)\d{26}|(?:AZ|HU)\d{27}|(?:GR|MU)\d{28})$)+')
# if not re.fullmatch(regex, self.acc_number):
# raise Warning('Invalid IBAN')
# @api.onchange('acc_number')
# def _onchange_acc_number(self):
# #validation IBAN
# #https://www.regextester.com/115565
# if self.acc_number:
# regex = re.compile(r'(^(?:(?:IT|SM)\d{2}[A-Z]\d{22}|CY\d{2}[A-Z]\d{23}|NL\d{2}[A-Z]{4}\d{10}|LV\d{2}[A-Z]{4}\d{13}|(?:BG|BH|GB|IE)\d{2}[A-Z]{4}\d{14}|GI\d{2}[A-Z]{4}\d{15}|RO\d{2}[A-Z]{4}\d{16}|KW\d{2}[A-Z]{4}\d{22}|MT\d{2}[A-Z]{4}\d{23}|NO\d{13}|(?:DK|FI|GL|FO)\d{16}|MK\d{17}|(?:AT|EE|KZ|LU|XK)\d{18}|(?:BA|HR|LI|CH|CR)\d{19}|(?:GE|DE|LT|ME|RS)\d{20}|IL\d{21}|(?:AD|CZ|ES|MD|SA)\d{22}|PT\d{23}|(?:BE|IS)\d{24}|(?:FR|MR|MC)\d{25}|(?:AL|DO|LB|PL)\d{26}|(?:AZ|HU)\d{27}|(?:GR|MU)\d{28})$)+')
# if not re.fullmatch(regex, self.acc_number):
# raise Warning('Invalid IBAN')
# @api.constrains('acc_number')
# def _onchange_acc_number(self):
# #validation IBAN
# #https://www.regextester.com/115565
# if self.acc_number:
# regex = re.compile(r'(^(?:(?:IT|SM)\d{2}[A-Z]\d{22}|CY\d{2}[A-Z]\d{23}|NL\d{2}[A-Z]{4}\d{10}|LV\d{2}[A-Z]{4}\d{13}|(?:BG|BH|GB|IE)\d{2}[A-Z]{4}\d{14}|GI\d{2}[A-Z]{4}\d{15}|RO\d{2}[A-Z]{4}\d{16}|KW\d{2}[A-Z]{4}\d{22}|MT\d{2}[A-Z]{4}\d{23}|NO\d{13}|(?:DK|FI|GL|FO)\d{16}|MK\d{17}|(?:AT|EE|KZ|LU|XK)\d{18}|(?:BA|HR|LI|CH|CR)\d{19}|(?:GE|DE|LT|ME|RS)\d{20}|IL\d{21}|(?:AD|CZ|ES|MD|SA)\d{22}|PT\d{23}|(?:BE|IS)\d{24}|(?:FR|MR|MC)\d{25}|(?:AL|DO|LB|PL)\d{26}|(?:AZ|HU)\d{27}|(?:GR|MU)\d{28})$)+')
# if not re.fullmatch(regex, self.acc_number):
# raise Warning('Invalid IBAN')

+ 19
- 6
views/donation.xml View File

@ -19,6 +19,7 @@
</xpath> </xpath>
<xpath expr="//field[@name='campaign_id']" position="replace"> <xpath expr="//field[@name='campaign_id']" position="replace">
</xpath> </xpath>
<xpath expr="//field[@name='payment_ref']" position="replace"> <xpath expr="//field[@name='payment_ref']" position="replace">
</xpath> </xpath>
<xpath expr="//label[@for='tax_receipt_option']" position="replace"> <xpath expr="//label[@for='tax_receipt_option']" position="replace">
@ -27,10 +28,7 @@
<attribute name="invisible">context.get('recurring_view')</attribute> <attribute name="invisible">context.get('recurring_view')</attribute>
</xpath> </xpath>
<xpath expr="//field[@name='payment_mode_id']" position="replace">
<field name="payment_mode_id" invisible="context.get('recurring_view')"/>
</xpath>
<xpath expr="//field[@name='company_id']" position="replace"> <xpath expr="//field[@name='company_id']" position="replace">
<field name="company_id" invisible="context.get('recurring_view')"/> <field name="company_id" invisible="context.get('recurring_view')"/>
@ -38,6 +36,21 @@
</field> </field>
</record> </record>
<record id="view_opendons_donation_direct_debit_form" model="ir.ui.view">
<field name="name">opendons.donation.direct_debit.form</field>
<field name="model">donation.donation</field>
<field name="inherit_id" ref="donation_direct_debit.donation_form" />
<field name="arch" type="xml">
<xpath expr="//field[@name='mandate_id']" position="attributes">
<attribute name="options">{'no_create_edit': True,'no_create': True}</attribute>
</xpath>
</field>
</record>
</data> </data>
@ -107,9 +120,9 @@
<field name="name">Recurring Donations</field> <field name="name">Recurring Donations</field>
<field name="res_model">donation.donation</field> <field name="res_model">donation.donation</field>
<field name="view_mode">tree,form,pivot,graph</field> <field name="view_mode">tree,form,pivot,graph</field>
<field
<!-- <field
name="context" name="context"
>{'default_recurring_template': 'active', 'recurring_view': True,'default_tax_receipt_option':'annual','default_donation_date':time.strftime('%Y-%m-%d')}</field>
>{'default_recurring_template': 'active', 'recurring_view': True,'default_tax_receipt_option':'annual','default_donation_date':time.strftime('%Y-%m-%d')}</field> -->
<field name="domain">[('recurring_template', '!=', False)]</field> <field name="domain">[('recurring_template', '!=', False)]</field>
</record> </record>


Loading…
Cancel
Save