banking-addons-team team mailing list archive
-
banking-addons-team team
-
Mailing list archive
-
Message #02047
[Merge] lp:~compassion/banking-addons/banking-addons-mandate into lp:banking-addons
Nicolas Bessi - Camptocamp has proposed merging lp:~compassion/banking-addons/banking-addons-mandate into lp:banking-addons.
Requested reviews:
Banking Addons Core Editors (banking-addons-team)
For more details, see:
https://code.launchpad.net/~compassion/banking-addons/banking-addons-mandate/+merge/224428
--
https://code.launchpad.net/~compassion/banking-addons/banking-addons-mandate/+merge/224428
Your team Banking Addons Core Editors is requested to review the proposed merge of lp:~compassion/banking-addons/banking-addons-mandate into lp:banking-addons.
=== added directory 'account_banking_mandate'
=== added file 'account_banking_mandate/__init__.py'
--- account_banking_mandate/__init__.py 1970-01-01 00:00:00 +0000
+++ account_banking_mandate/__init__.py 2014-06-25 11:54:20 +0000
@@ -0,0 +1,22 @@
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+# Mandate module for openERP
+# Copyright (C) 2014 Compassion CH (http://www.compassion.ch)
+# @author: Cyril Sester <csester@xxxxxxxxxxxxx>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+import model
\ No newline at end of file
=== added file 'account_banking_mandate/__openerp__.py'
--- account_banking_mandate/__openerp__.py 1970-01-01 00:00:00 +0000
+++ account_banking_mandate/__openerp__.py 2014-06-25 11:54:20 +0000
@@ -0,0 +1,46 @@
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+# Mandate module for openERP
+# Copyright (C) 2014 Compassion CH (http://www.compassion.ch)
+# @author: Cyril Sester <csester@xxxxxxxxxxxxx>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+{
+ 'name': 'Account Banking Mandate',
+ 'summary': 'Direct Debit mandate',
+ 'version': '0.1',
+ 'license': 'AGPL-3',
+ 'author': 'Compassion CH',
+ 'website': 'http://www.compassion.ch',
+ 'category': 'Banking addons',
+ 'depends': ['account_direct_debit'],
+ 'external_dependencies': {},
+ 'data': [
+ 'view/account_banking_mandate_view.xml',
+ 'view/account_invoice_view.xml',
+ 'view/account_payment_view.xml',
+ 'view/res_partner_bank_view.xml',
+ 'data/mandate_reference_sequence.xml',
+ ],
+ 'demo': [],
+ 'description': '''
+This module adds a generic model for direct debit mandates. These mandates can be specialized to
+fit any direct debit mandate (such as sepa or lsv).
+ ''',
+ 'active': False,
+ 'installable': True,
+}
=== added directory 'account_banking_mandate/data'
=== renamed file 'account_banking_sepa_direct_debit/data/mandate_reference_sequence.xml' => 'account_banking_mandate/data/mandate_reference_sequence.xml'
--- account_banking_sepa_direct_debit/data/mandate_reference_sequence.xml 2013-10-22 22:25:06 +0000
+++ account_banking_mandate/data/mandate_reference_sequence.xml 2014-06-25 11:54:20 +0000
@@ -3,14 +3,14 @@
<data noupdate="1">
-<record id="sdd_mandate_seq_type" model="ir.sequence.type">
- <field name="name">SDD Mandate Reference</field>
- <field name="code">sdd.mandate.reference</field>
+<record id="dd_mandate_seq_type" model="ir.sequence.type">
+ <field name="name">DD Mandate Reference</field>
+ <field name="code">account.banking.mandate</field>
</record>
-<record id="sdd_mandate_seq" model="ir.sequence">
- <field name="name">SDD Mandate Reference</field>
- <field name="code">sdd.mandate.reference</field>
+<record id="dd_mandate_seq" model="ir.sequence">
+ <field name="name">DD Mandate Reference</field>
+ <field name="code">account.banking.mandate</field>
<field name="prefix">RUM</field>
<field name="padding" eval="7"/>
<!-- remember that max size for the mandate ref is 35 -->
=== added directory 'account_banking_mandate/model'
=== added file 'account_banking_mandate/model/__init__.py'
--- account_banking_mandate/model/__init__.py 1970-01-01 00:00:00 +0000
+++ account_banking_mandate/model/__init__.py 2014-06-25 11:54:20 +0000
@@ -0,0 +1,22 @@
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+# Mandate module for openERP
+# Copyright (C) 2014 Compassion CH (http://www.compassion.ch)
+# @author: Cyril Sester <csester@xxxxxxxxxxxxx>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+import account_banking_mandate
\ No newline at end of file
=== added file 'account_banking_mandate/model/account_banking_mandate.py'
--- account_banking_mandate/model/account_banking_mandate.py 1970-01-01 00:00:00 +0000
+++ account_banking_mandate/model/account_banking_mandate.py 2014-06-25 11:54:20 +0000
@@ -0,0 +1,261 @@
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+# Mandate module for openERP
+# Copyright (C) 2014 Compassion CH (http://www.compassion.ch)
+# @author: Cyril Sester <csester@xxxxxxxxxxxxx>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from openerp.osv import orm, fields
+from openerp.tools.translate import _
+from datetime import datetime
+import logging
+
+logger = logging.getLogger(__name__)
+
+class mandate(orm.Model):
+ '''Direct Debit Mandate'''
+ _name = 'account.banking.mandate'
+ _description = __doc__
+ _rec_name = 'unique_mandate_reference'
+ _inherit = ['mail.thread']
+ _order = 'signature_date desc'
+ _track = {
+ 'state': {
+ 'account_banking_mandate.mandate_valid':
+ lambda self, cr, uid, obj, ctx=None:
+ obj['state'] == 'valid',
+ 'account_banking_mandate.mandate_expired':
+ lambda self, cr, uid, obj, ctx=None:
+ obj['state'] == 'expired',
+ 'account_banking_mandate.mandate_cancel':
+ lambda self, cr, uid, obj, ctx=None:
+ obj['state'] == 'cancel',
+ },
+ }
+
+ _columns = {
+ 'partner_bank_id': fields.many2one(
+ 'res.partner.bank', 'Bank Account', track_visibility='onchange'),
+ 'partner_id': fields.related(
+ 'partner_bank_id', 'partner_id', type='many2one',
+ relation='res.partner', string='Partner', readonly=True),
+ 'company_id': fields.many2one('res.company', 'Company', required=True),
+ 'unique_mandate_reference': fields.char(
+ 'Unique Mandate Reference', size=35, readonly=True,
+ track_visibility='always'),
+ 'signature_date': fields.date(
+ 'Date of Signature of the Mandate', track_visibility='onchange'),
+ 'scan': fields.binary('Scan of the Mandate'),
+ 'last_debit_date': fields.date(
+ 'Date of the Last Debit', readonly=True),
+ 'state': fields.selection([
+ ('draft', 'Draft'),
+ ('valid', 'Valid'),
+ ('expired', 'Expired'),
+ ('cancel', 'Cancelled'),
+ ], 'Status',
+ help="Only valid mandates can be used in a payment line. A "
+ "cancelled mandate is a mandate that has been cancelled by "
+ "the customer. "),
+ 'payment_line_ids': fields.one2many(
+ 'payment.line', 'mandate_id', "Related Payment Lines"),
+ }
+
+ _defaults = {
+ 'company_id': lambda self, cr, uid, context:
+ self.pool['res.company']._company_default_get(
+ cr, uid, 'account.banking.mandate', context=context),
+ 'state': 'draft',
+ 'unique_mandate_reference': '/',
+ }
+
+ _sql_constraints = [(
+ 'mandate_ref_company_uniq',
+ 'unique(unique_mandate_reference, company_id)',
+ 'A Mandate with the same reference already exists for this company !'
+ )]
+
+ def create(self, cr, uid, vals, context=None):
+ if vals.get('unique_mandate_reference', '/') == '/':
+ vals['unique_mandate_reference'] = \
+ self.pool['ir.sequence'].next_by_code(
+ cr, uid, 'account.banking.mandate', context=context)
+ return super(mandate, self).create(cr, uid, vals, context=context)
+
+ def _check_mandate(self, cr, uid, ids):
+ for mandate in self.browse(cr, uid, ids):
+ if (mandate.signature_date and
+ mandate.signature_date >
+ datetime.today().strftime('%Y-%m-%d')):
+ raise orm.except_orm(
+ _('Error:'),
+ _("The date of signature of mandate '%s' is in the "
+ "future !")
+ % mandate.unique_mandate_reference)
+ if mandate.state == 'valid' and not mandate.signature_date:
+ raise orm.except_orm(
+ _('Error:'),
+ _("Cannot validate the mandate '%s' without a date of "
+ "signature.")
+ % mandate.unique_mandate_reference)
+ if mandate.state == 'valid' and not mandate.partner_bank_id:
+ raise orm.except_orm(
+ _('Error:'),
+ _("Cannot validate the mandate '%s' because it is not "
+ "attached to a bank account.")
+ % mandate.unique_mandate_reference)
+
+ if (mandate.signature_date and mandate.last_debit_date and
+ mandate.signature_date > mandate.last_debit_date):
+ raise orm.except_orm(
+ _('Error:'),
+ _("The mandate '%s' can't have a date of last debit "
+ "before the date of signature.")
+ % mandate.unique_mandate_reference)
+ return True
+
+ _constraints = [
+ (_check_mandate, "Error msg in raise", [
+ 'last_debit_date', 'signature_date', 'state', 'partner_bank_id',
+ ]),
+ ]
+
+ def mandate_partner_bank_change(
+ self, cr, uid, ids, partner_bank_id, last_debit_date, state):
+ res = {'value': {}}
+ if partner_bank_id:
+ partner_bank_read = self.pool['res.partner.bank'].read(
+ cr, uid, partner_bank_id, ['partner_id'])['partner_id']
+ if partner_bank_read:
+ res['value']['partner_id'] = partner_bank_read[0]
+ return res
+
+ def validate(self, cr, uid, ids, context=None):
+ to_validate_ids = []
+ for mandate in self.browse(cr, uid, ids, context=context):
+ assert mandate.state == 'draft', 'Mandate should be in draft state'
+ to_validate_ids.append(mandate.id)
+ self.write(
+ cr, uid, to_validate_ids, {'state': 'valid'}, context=context)
+ return True
+
+ def cancel(self, cr, uid, ids, context=None):
+ to_cancel_ids = []
+ for mandate in self.browse(cr, uid, ids, context=context):
+ assert mandate.state in ('draft', 'valid'),\
+ 'Mandate should be in draft or valid state'
+ to_cancel_ids.append(mandate.id)
+ self.write(
+ cr, uid, to_cancel_ids, {'state': 'cancel'}, context=context)
+ return True
+
+ def back2draft(self, cr, uid, ids, context=None):
+ to_draft_ids = []
+ for mandate in self.browse(cr, uid, ids, context=context):
+ assert mandate.state == 'cancel',\
+ 'Mandate should be in cancel state'
+ to_draft_ids.append(mandate.id)
+ self.write(
+ cr, uid, to_draft_ids, {'state': 'draft'}, context=context)
+ return True
+
+class res_partner_bank(orm.Model):
+ _inherit = 'res.partner.bank'
+
+ #Add mandate references on bank account (a bank account can have several mandates)
+ _columns = {
+ 'mandate_ids': fields.one2many(
+ 'account.banking.mandate', 'partner_bank_id', 'Direct Debit Mandates'),
+ }
+
+class payment_line(orm.Model):
+ _inherit = 'payment.line'
+
+ #Add mandate reference on payment line (several payment line can referer to same mandate)
+ _columns = {
+ 'mandate_id': fields.many2one(
+ 'account.banking.mandate', 'Direct Debit Mandate',
+ domain=[('state', '=', 'valid')]),
+ }
+
+ def create(self, cr, uid, vals, context=None):
+ '''If the customer invoice has a mandate, take it
+ otherwise, take the first valid mandate of the bank account'''
+ if context is None:
+ context = {}
+ if not vals:
+ vals = {}
+ partner_bank_id = vals.get('bank_id')
+ move_line_id = vals.get('move_line_id')
+ if (context.get('default_payment_order_type') == 'debit'
+ and 'mandate_id' not in vals):
+ if move_line_id:
+ line = self.pool['account.move.line'].browse(
+ cr, uid, move_line_id, context=context)
+ if (line.invoice and line.invoice.type == 'out_invoice'
+ and line.invoice.mandate_id):
+ vals.update({
+ 'mandate_id': line.invoice.mandate_id.id,
+ 'bank_id':
+ line.invoice.mandate_id.partner_bank_id.id,
+ })
+ if partner_bank_id and 'mandate_id' not in vals:
+ mandate_ids = self.pool['account.banking.mandate'].search(cr, uid, [
+ ('partner_bank_id', '=', partner_bank_id),
+ ('state', '=', 'valid'),
+ ], context=context)
+ if mandate_ids:
+ vals['mandate_id'] = mandate_ids[0]
+ return super(payment_line, self).create(cr, uid, vals, context=context)
+
+ def _check_mandate_bank_link(self, cr, uid, ids):
+ for payline in self.browse(cr, uid, ids):
+ if (payline.mandate_id and payline.bank_id
+ and payline.mandate_id.partner_bank_id.id !=
+ payline.bank_id.id):
+ raise orm.except_orm(
+ _('Error:'),
+ _("The payment line with reference '%s' has the bank "
+ "account '%s' which is not attached to the mandate "
+ "'%s' (this mandate is attached to the bank account "
+ "'%s').") % (
+ payline.name,
+ self.pool['res.partner.bank'].name_get(
+ cr, uid, [payline.bank_id.id])[0][1],
+ payline.mandate_id.unique_mandate_reference,
+ self.pool['res.partner.bank'].name_get(
+ cr, uid,
+ [payline.mandate_id.partner_bank_id.id])[0][1],
+ ))
+ return True
+
+ _constraints = [
+ (_check_mandate_bank_link, 'Error msg in raise',
+ ['mandate_id', 'bank_id']),
+ ]
+
+
+class account_invoice(orm.Model):
+ _inherit = 'account.invoice'
+
+ _columns = {
+ 'mandate_id': fields.many2one(
+ 'account.banking.mandate', 'Direct Debit Mandate',
+ domain=[('state', '=', 'valid')], readonly=True,
+ states={'draft': [('readonly', False)]})
+ }
=== added directory 'account_banking_mandate/view'
=== renamed file 'account_banking_sepa_direct_debit/sdd_mandate_view.xml' => 'account_banking_mandate/view/account_banking_mandate_view.xml'
--- account_banking_sepa_direct_debit/sdd_mandate_view.xml 2014-06-11 22:03:21 +0000
+++ account_banking_mandate/view/account_banking_mandate_view.xml 2014-06-25 11:54:20 +0000
@@ -7,11 +7,11 @@
<openerp>
<data>
-<record id="sdd_mandate_form" model="ir.ui.view">
- <field name="name">sdd.mandate.form</field>
- <field name="model">sdd.mandate</field>
+<record id="dd_mandate_form" model="ir.ui.view">
+ <field name="name">dd.mandate.form</field>
+ <field name="model">account.banking.mandate</field>
<field name="arch" type="xml">
- <form string="SEPA Direct Debit Mandate" version="7.0">
+ <form string="Direct Debit Mandate" version="7.0">
<header>
<button name="validate" type="object" string="Validate" states="draft" class="oe_highlight"/>
<button name="cancel" type="object" string="Cancel" states="draft,valid"/>
@@ -29,17 +29,13 @@
<group name="main">
<field name="company_id" groups="base.group_multi_company"/>
<field name="partner_bank_id"
- on_change="mandate_partner_bank_change(partner_bank_id, type, recurrent_sequence_type, last_debit_date, state)"
- invisible="context.get('sdd_mandate_bank_partner_view')"
+ on_change="mandate_partner_bank_change(partner_bank_id, last_debit_date, state)"
+ invisible="context.get('dd_mandate_bank_partner_view')"
/>
- <field name="partner_id" invisible="context.get('sdd_mandate_bank_partner_view')"/>
- <field name="type" on_change="mandate_type_change(type)"/>
- <field name="recurrent_sequence_type" attrs="{'invisible': [('type', '=', 'oneoff')], 'required': [('type', '=', 'recurrent')]}"/>
+ <field name="partner_id" invisible="context.get('dd_mandate_bank_partner_view')"/>
<field name="signature_date"/>
<field name="scan"/>
<field name="last_debit_date"/>
- <field name="sepa_migrated" groups="account_banking_sepa_direct_debit.group_original_mandate_required"/>
- <field name="original_mandate_identification" attrs="{'invisible': [('sepa_migrated', '=', True)], 'required': [('sepa_migrated', '=', False)]}" groups="account_banking_sepa_direct_debit.group_original_mandate_required"/>
</group>
<group name="payment_lines" string="Related Payment Lines">
<field name="payment_line_ids" nolabel="1"/>
@@ -53,15 +49,14 @@
</field>
</record>
-<record id="sdd_mandate_tree" model="ir.ui.view">
- <field name="name">sdd.mandate.tree</field>
- <field name="model">sdd.mandate</field>
+<record id="dd_mandate_tree" model="ir.ui.view">
+ <field name="name">dd.mandate.tree</field>
+ <field name="model">account.banking.mandate</field>
<field name="arch" type="xml">
- <tree string="SEPA Direct Debit Mandate" colors="blue:state=='draft';black:state in ('expired', 'cancel')">
+ <tree string="Direct Debit Mandate" colors="blue:state=='draft';black:state in ('expired', 'cancel')">
<field name="company_id" groups="base.group_multi_company"/>
- <field name="partner_id" invisible="context.get('sdd_mandate_bank_partner_view')"/>
+ <field name="partner_id" invisible="context.get('dd_mandate_bank_partner_view')"/>
<field name="unique_mandate_reference" string="Reference"/>
- <field name="type" string="Type"/>
<field name="signature_date" string="Signature Date"/>
<field name="last_debit_date"/>
<field name="state"/>
@@ -69,83 +64,60 @@
</field>
</record>
-<record id="sdd_mandate_search" model="ir.ui.view">
- <field name="name">sdd.mandate.search</field>
- <field name="model">sdd.mandate</field>
+<record id="dd_mandate_search" model="ir.ui.view">
+ <field name="name">dd.mandate.search</field>
+ <field name="model">account.banking.mandate</field>
<field name="arch" type="xml">
- <search string="Search SEPA Direct Debit Mandates">
+ <search string="Search Direct Debit Mandates">
<field name="partner_id"/>
<filter name="draft" string="Draft" domain="[('state', '=', 'draft')]" />
<filter name="valid" string="Valid" domain="[('state', '=', 'valid')]" />
<filter name="cancel" string="Cancelled" domain="[('state', '=', 'cancel')]" />
<filter name="expired" string="Expired" domain="[('state', '=', 'expired')]" />
- <filter name="oneoff" string="One-Off" domain="[('type', '=', 'oneoff')]" />
- <filter name="recurrent" string="Recurrent" domain="[('type', '=', 'recurrent')]" />
</search>
</field>
</record>
-<record id="sdd_mandate_action" model="ir.actions.act_window">
- <field name="name">SEPA Direct Debit Mandates</field>
- <field name="res_model">sdd.mandate</field>
+<record id="dd_mandate_action" model="ir.actions.act_window">
+ <field name="name">Direct Debit Mandates</field>
+ <field name="res_model">account.banking.mandate</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="help" type="html">
<p class="oe_view_nocontent_create">
- Click to create a new SEPA Direct Debit Mandate.
+ Click to create a new Direct Debit Mandate.
</p><p>
- A SEPA Direct Debit Mandate is a document signed by your customer that gives you the autorization to do one or several direct debits on his bank account.
+ A Direct Debit Mandate is a document signed by your customer that gives you the autorization to do one or several direct debits on his bank account.
</p>
</field>
</record>
-<menuitem id="sdd_mandate_menu"
+<menuitem id="dd_mandate_menu"
parent="account_payment.menu_main_payment"
- action="sdd_mandate_action"
+ action="dd_mandate_action"
sequence="20"
/>
-<!-- notifications in the chatter -->
+<!-- notifications statuses in the chatter -->
<record id="mandate_valid" model="mail.message.subtype">
<field name="name">Mandate Validated</field>
- <field name="res_model">sdd.mandate</field>
+ <field name="res_model">account.banking.mandate</field>
<field name="default" eval="False"/>
- <field name="description">SEPA Direct Debit Mandate Validated</field>
+ <field name="description">Direct Debit Mandate Validated</field>
</record>
<record id="mandate_expired" model="mail.message.subtype">
<field name="name">Mandate Expired</field>
- <field name="res_model">sdd.mandate</field>
+ <field name="res_model">account.banking.mandate</field>
<field name="default" eval="False"/>
- <field name="description">SEPA Direct Debit Mandate has Expired</field>
+ <field name="description">Direct Debit Mandate has Expired</field>
</record>
<record id="mandate_cancel" model="mail.message.subtype">
<field name="name">Mandate Cancelled</field>
- <field name="res_model">sdd.mandate</field>
- <field name="default" eval="False"/>
- <field name="description">SEPA Direct Debit Mandate Cancelled</field>
-</record>
-
-<record id="recurrent_sequence_type_first" model="mail.message.subtype">
- <field name="name">Sequence Type set to First</field>
- <field name="res_model">sdd.mandate</field>
- <field name="default" eval="False"/>
- <field name="description">Sequence Type set to First</field>
-</record>
-
-<record id="recurrent_sequence_type_recurring" model="mail.message.subtype">
- <field name="name">Sequence Type set to Recurring</field>
- <field name="res_model">sdd.mandate</field>
- <field name="default" eval="False"/>
- <field name="description">Sequence Type set to Recurring</field>
-</record>
-
-<record id="recurrent_sequence_type_final" model="mail.message.subtype">
- <field name="name">Sequence Type set to Final</field>
- <field name="res_model">sdd.mandate</field>
- <field name="default" eval="False"/>
- <field name="description">Sequence Type set to Final</field>
+ <field name="res_model">account.banking.mandate</field>
+ <field name="default" eval="False"/>
+ <field name="description">Direct Debit Mandate Cancelled</field>
</record>
</data>
=== renamed file 'account_banking_sepa_direct_debit/account_invoice_view.xml' => 'account_banking_mandate/view/account_invoice_view.xml'
--- account_banking_sepa_direct_debit/account_invoice_view.xml 2013-11-09 14:05:07 +0000
+++ account_banking_mandate/view/account_invoice_view.xml 2014-06-25 11:54:20 +0000
@@ -8,12 +8,12 @@
<data>
<record id="invoice_form" model="ir.ui.view">
- <field name="name">add.sdd.mandate.on.customer.invoice.form</field>
+ <field name="name">add.dd.mandate.on.customer.invoice.form</field>
<field name="model">account.invoice</field>
<field name="inherit_id" ref="account.invoice_form"/>
<field name="arch" type="xml">
<field name="partner_bank_id" position="after">
- <field name="sdd_mandate_id" domain="[('partner_id', '=', partner_id), ('state', '=', 'valid')]" attrs="{'invisible': [('type', '=', 'out_refund')]}"/>
+ <field name="mandate_id" domain="[('partner_id', '=', partner_id), ('state', '=', 'valid')]" attrs="{'invisible': [('type', '=', 'out_refund')]}"/>
</field>
</field>
</record>
=== renamed file 'account_banking_sepa_direct_debit/account_payment_view.xml' => 'account_banking_mandate/view/account_payment_view.xml'
--- account_banking_sepa_direct_debit/account_payment_view.xml 2013-11-11 10:56:49 +0000
+++ account_banking_mandate/view/account_payment_view.xml 2014-06-25 11:54:20 +0000
@@ -7,17 +7,17 @@
<openerp>
<data>
-<record id="sdd_view_payment_order_form" model="ir.ui.view">
- <field name="name">sdd.payment.order.form</field>
+<record id="dd_view_payment_order_form" model="ir.ui.view">
+ <field name="name">dd.payment.order.form</field>
<field name="model">payment.order</field>
<field name="inherit_id" ref="account_payment.view_payment_order_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='line_ids']/form/notebook/page/group/field[@name='bank_id']" position="after">
- <field name="sdd_mandate_id" domain="[('partner_bank_id', '=', bank_id), ('state', '=', 'valid')]" invisible="context.get('default_payment_order_type')!='debit'" context="{'default_partner_bank_id': bank_id}"/>
+ <field name="mandate_id" domain="[('partner_bank_id', '=', bank_id), ('state', '=', 'valid')]" invisible="context.get('default_payment_order_type')!='debit'" context="{'default_partner_bank_id': bank_id}"/>
<newline />
</xpath>
<xpath expr="//field[@name='line_ids']/tree/field[@name='bank_id']" position="after">
- <field name="sdd_mandate_id" string="SDD Mandate" invisible="context.get('default_payment_order_type')!='debit'"/>
+ <field name="mandate_id" string="DD Mandate" invisible="context.get('default_payment_order_type')!='debit'"/>
</xpath>
</field>
</record>
=== renamed file 'account_banking_sepa_direct_debit/res_partner_bank_view.xml' => 'account_banking_mandate/view/res_partner_bank_view.xml'
--- account_banking_sepa_direct_debit/res_partner_bank_view.xml 2013-11-11 10:56:49 +0000
+++ account_banking_mandate/view/res_partner_bank_view.xml 2014-06-25 11:54:20 +0000
@@ -7,39 +7,38 @@
<openerp>
<data>
-<record id="sdd_mandate_partner_bank_form" model="ir.ui.view">
- <field name="name">sdd.mandate.res.partner.bank.form</field>
+<record id="dd_mandate_partner_bank_form" model="ir.ui.view">
+ <field name="name">dd.mandate.res.partner.bank.form</field>
<field name="model">res.partner.bank</field>
<field name="inherit_id" ref="base.view_partner_bank_form"/>
<field name="arch" type="xml">
<group name="bank" position="after">
- <group name="sdd_mandates" string="SEPA Direct Debit Mandates" colspan="4">
- <field name="sdd_mandate_ids" context="{'default_partner_bank_id': active_id, 'sdd_mandate_bank_partner_view': True}" nolabel="1"/>
+ <group name="dd_mandates" string="Direct Debit Mandates" colspan="4">
+ <field name="mandate_ids" context="{'default_partner_bank_id': active_id, 'dd_mandate_bank_partner_view': True}" nolabel="1"/>
</group>
</group>
</field>
</record>
-<record id="sdd_mandate_partner_bank_tree" model="ir.ui.view">
- <field name="name">sdd.mandate.res.partner.bank.tree</field>
+<record id="dd_mandate_partner_bank_tree" model="ir.ui.view">
+ <field name="name">dd.mandate.res.partner.bank.tree</field>
<field name="model">res.partner.bank</field>
<field name="inherit_id" ref="base.view_partner_bank_tree"/>
<field name="arch" type="xml">
<field name="partner_id" position="after">
- <field name="sdd_mandate_ids" string="SDD Mandates"/>
+ <field name="mandate_ids" string="DD Mandates"/>
</field>
</field>
</record>
-<!-- add number of mandates in this list of bank accounts
-on the partner form -->
-<record id="sdd_mandate_partner_form" model="ir.ui.view">
- <field name="name">sdd.mandate.partner.form</field>
+<!-- add number of mandates in this list of bank accounts on the partner form -->
+<record id="dd_mandate_partner_form" model="ir.ui.view">
+ <field name="name">dd.mandate.partner.form</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="account.view_partner_property_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='bank_ids']/tree/field[@name='owner_name']" position="after">
- <field name="sdd_mandate_ids" string="SDD Mandates"/>
+ <field name="mandate_ids" string="DD Mandates"/>
</xpath>
</field>
</record>
=== modified file 'account_banking_sepa_direct_debit/__openerp__.py'
--- account_banking_sepa_direct_debit/__openerp__.py 2014-03-12 22:18:33 +0000
+++ account_banking_sepa_direct_debit/__openerp__.py 2014-06-25 11:54:20 +0000
@@ -27,7 +27,7 @@
'author': 'Akretion',
'website': 'http://www.akretion.com',
'category': 'Banking addons',
- 'depends': ['account_direct_debit', 'account_banking_pain_base'],
+ 'depends': ['account_banking_mandate', 'account_banking_pain_base'],
'external_dependencies': {
'python': ['unidecode', 'lxml'],
},
@@ -35,14 +35,10 @@
'security/original_mandate_required_security.xml',
'account_banking_sdd_view.xml',
'sdd_mandate_view.xml',
- 'res_partner_bank_view.xml',
- 'account_payment_view.xml',
'company_view.xml',
'mandate_expire_cron.xml',
- 'account_invoice_view.xml',
'wizard/export_sdd_view.xml',
'data/payment_type_sdd.xml',
- 'data/mandate_reference_sequence.xml',
'security/ir.model.access.csv',
],
'demo': ['sepa_direct_debit_demo.xml'],
=== modified file 'account_banking_sepa_direct_debit/account_banking_sdd.py'
--- account_banking_sepa_direct_debit/account_banking_sdd.py 2014-06-23 09:47:01 +0000
+++ account_banking_sepa_direct_debit/account_banking_sdd.py 2014-06-25 11:54:20 +0000
@@ -32,7 +32,6 @@
logger = logging.getLogger(__name__)
-
class banking_export_sdd(orm.Model):
'''SEPA Direct Debit export'''
_name = 'banking.export.sdd'
@@ -100,23 +99,10 @@
class sdd_mandate(orm.Model):
'''SEPA Direct Debit Mandate'''
- _name = 'sdd.mandate'
_description = __doc__
- _rec_name = 'unique_mandate_reference'
- _inherit = ['mail.thread']
- _order = 'signature_date desc'
+ _name = 'account.banking.mandate'
+ _inherit = 'account.banking.mandate'
_track = {
- 'state': {
- 'account_banking_sepa_direct_debit.mandate_valid':
- lambda self, cr, uid, obj, ctx=None:
- obj['state'] == 'valid',
- 'account_banking_sepa_direct_debit.mandate_expired':
- lambda self, cr, uid, obj, ctx=None:
- obj['state'] == 'expired',
- 'account_banking_sepa_direct_debit.mandate_cancel':
- lambda self, cr, uid, obj, ctx=None:
- obj['state'] == 'cancel',
- },
'recurrent_sequence_type': {
'account_banking_sepa_direct_debit.recurrent_sequence_type_first':
lambda self, cr, uid, obj, ctx=None:
@@ -132,15 +118,6 @@
}
_columns = {
- 'partner_bank_id': fields.many2one(
- 'res.partner.bank', 'Bank Account', track_visibility='onchange'),
- 'partner_id': fields.related(
- 'partner_bank_id', 'partner_id', type='many2one',
- relation='res.partner', string='Partner', readonly=True),
- 'company_id': fields.many2one('res.company', 'Company', required=True),
- 'unique_mandate_reference': fields.char(
- 'Unique Mandate Reference', size=35, readonly=True,
- track_visibility='always'),
'type': fields.selection([
('recurrent', 'Recurrent'),
('oneoff', 'One-Off'),
@@ -152,24 +129,6 @@
], 'Sequence Type for Next Debit', track_visibility='onchange',
help="This field is only used for Recurrent mandates, not for "
"One-Off mandates."),
- 'signature_date': fields.date(
- 'Date of Signature of the Mandate', track_visibility='onchange'),
- 'scan': fields.binary('Scan of the Mandate'),
- 'last_debit_date': fields.date(
- 'Date of the Last Debit', readonly=True),
- 'state': fields.selection([
- ('draft', 'Draft'),
- ('valid', 'Valid'),
- ('expired', 'Expired'),
- ('cancel', 'Cancelled'),
- ], 'Status',
- help="Only valid mandates can be used in a payment line. A "
- "cancelled mandate is a mandate that has been cancelled by "
- "the customer. A one-off mandate expires after its first use. "
- "A recurrent mandate expires after it's final use or if it "
- "hasn't been used for 36 months."),
- 'payment_line_ids': fields.one2many(
- 'payment.line', 'sdd_mandate_id', "Related Payment Lines"),
'sepa_migrated': fields.boolean(
'Migrated to SEPA', track_visibility='onchange',
help="If this field is not active, the mandate section of the "
@@ -188,57 +147,11 @@
}
_defaults = {
- 'company_id': lambda self, cr, uid, context:
- self.pool['res.company']._company_default_get(
- cr, uid, 'sdd.mandate', context=context),
- 'unique_mandate_reference': '/',
- 'state': 'draft',
'sepa_migrated': True,
}
- _sql_constraints = [(
- 'mandate_ref_company_uniq',
- 'unique(unique_mandate_reference, company_id)',
- 'A Mandate with the same reference already exists for this company !'
- )]
-
- def create(self, cr, uid, vals, context=None):
- if vals.get('unique_mandate_reference', '/') == '/':
- vals['unique_mandate_reference'] = \
- self.pool['ir.sequence'].next_by_code(
- cr, uid, 'sdd.mandate.reference', context=context)
- return super(sdd_mandate, self).create(cr, uid, vals, context=context)
-
def _check_sdd_mandate(self, cr, uid, ids):
for mandate in self.browse(cr, uid, ids):
- if (mandate.signature_date and
- mandate.signature_date >
- datetime.today().strftime('%Y-%m-%d')):
- raise orm.except_orm(
- _('Error:'),
- _("The date of signature of mandate '%s' is in the "
- "future !")
- % mandate.unique_mandate_reference)
- if mandate.state == 'valid' and not mandate.signature_date:
- raise orm.except_orm(
- _('Error:'),
- _("Cannot validate the mandate '%s' without a date of "
- "signature.")
- % mandate.unique_mandate_reference)
- if mandate.state == 'valid' and not mandate.partner_bank_id:
- raise orm.except_orm(
- _('Error:'),
- _("Cannot validate the mandate '%s' because it is not "
- "attached to a bank account.")
- % mandate.unique_mandate_reference)
-
- if (mandate.signature_date and mandate.last_debit_date and
- mandate.signature_date > mandate.last_debit_date):
- raise orm.except_orm(
- _('Error:'),
- _("The mandate '%s' can't have a date of last debit "
- "before the date of signature.")
- % mandate.unique_mandate_reference)
if (mandate.type == 'recurrent'
and not mandate.recurrent_sequence_type):
raise orm.except_orm(
@@ -265,7 +178,6 @@
_constraints = [
(_check_sdd_mandate, "Error msg in raise", [
- 'last_debit_date', 'signature_date', 'state', 'partner_bank_id',
'type', 'recurrent_sequence_type', 'sepa_migrated',
'original_mandate_identification',
]),
@@ -282,12 +194,8 @@
def mandate_partner_bank_change(
self, cr, uid, ids, partner_bank_id, type, recurrent_sequence_type,
last_debit_date, state):
- res = {'value': {}}
- if partner_bank_id:
- partner_bank_read = self.pool['res.partner.bank'].read(
- cr, uid, partner_bank_id, ['partner_id'])['partner_id']
- if partner_bank_read:
- res['value']['partner_id'] = partner_bank_read[0]
+ res = super(sdd_mandate, self).mandate_partner_bank_change(cr, uid,
+ ids, partner_bank_id, last_debit_date, state)
if (state == 'valid' and partner_bank_id
and type == 'recurrent'
and recurrent_sequence_type != 'first'):
@@ -301,35 +209,6 @@
}
return res
- def validate(self, cr, uid, ids, context=None):
- to_validate_ids = []
- for mandate in self.browse(cr, uid, ids, context=context):
- assert mandate.state == 'draft', 'Mandate should be in draft state'
- to_validate_ids.append(mandate.id)
- self.write(
- cr, uid, to_validate_ids, {'state': 'valid'}, context=context)
- return True
-
- def cancel(self, cr, uid, ids, context=None):
- to_cancel_ids = []
- for mandate in self.browse(cr, uid, ids, context=context):
- assert mandate.state in ('draft', 'valid'),\
- 'Mandate should be in draft or valid state'
- to_cancel_ids.append(mandate.id)
- self.write(
- cr, uid, to_cancel_ids, {'state': 'cancel'}, context=context)
- return True
-
- def back2draft(self, cr, uid, ids, context=None):
- to_draft_ids = []
- for mandate in self.browse(cr, uid, ids, context=context):
- assert mandate.state == 'cancel',\
- 'Mandate should be in cancel state'
- to_draft_ids.append(mandate.id)
- self.write(
- cr, uid, to_draft_ids, {'state': 'draft'}, context=context)
- return True
-
def _sdd_mandate_set_state_to_expired(self, cr, uid, context=None):
logger.info('Searching for SDD Mandates that must be set to Expired')
expire_limit_date = datetime.today() + \
@@ -351,90 +230,4 @@
% expired_mandate_ids)
else:
logger.info('0 SDD Mandates must be set to Expired')
- return True
-
-
-class res_partner_bank(orm.Model):
- _inherit = 'res.partner.bank'
-
- _columns = {
- 'sdd_mandate_ids': fields.one2many(
- 'sdd.mandate', 'partner_bank_id', 'SEPA Direct Debit Mandates'),
- }
-
-
-class payment_line(orm.Model):
- _inherit = 'payment.line'
-
- _columns = {
- 'sdd_mandate_id': fields.many2one(
- 'sdd.mandate', 'SEPA Direct Debit Mandate',
- domain=[('state', '=', 'valid')]),
- }
-
- def create(self, cr, uid, vals, context=None):
- '''If the customer invoice has a mandate, take it
- otherwise, take the first valid mandate of the bank account'''
- if context is None:
- context = {}
- if not vals:
- vals = {}
- partner_bank_id = vals.get('bank_id')
- move_line_id = vals.get('move_line_id')
- if (context.get('default_payment_order_type') == 'debit'
- and 'sdd_mandate_id' not in vals):
- if move_line_id:
- line = self.pool['account.move.line'].browse(
- cr, uid, move_line_id, context=context)
- if (line.invoice and line.invoice.type == 'out_invoice'
- and line.invoice.sdd_mandate_id):
- vals.update({
- 'sdd_mandate_id': line.invoice.sdd_mandate_id.id,
- 'bank_id':
- line.invoice.sdd_mandate_id.partner_bank_id.id,
- })
- if partner_bank_id and 'sdd_mandate_id' not in vals:
- mandate_ids = self.pool['sdd.mandate'].search(cr, uid, [
- ('partner_bank_id', '=', partner_bank_id),
- ('state', '=', 'valid'),
- ], context=context)
- if mandate_ids:
- vals['sdd_mandate_id'] = mandate_ids[0]
- return super(payment_line, self).create(cr, uid, vals, context=context)
-
- def _check_mandate_bank_link(self, cr, uid, ids):
- for payline in self.browse(cr, uid, ids):
- if (payline.sdd_mandate_id and payline.bank_id
- and payline.sdd_mandate_id.partner_bank_id.id !=
- payline.bank_id.id):
- raise orm.except_orm(
- _('Error:'),
- _("The payment line with reference '%s' has the bank "
- "account '%s' which is not attached to the mandate "
- "'%s' (this mandate is attached to the bank account "
- "'%s').") % (
- payline.name,
- self.pool['res.partner.bank'].name_get(
- cr, uid, [payline.bank_id.id])[0][1],
- payline.sdd_mandate_id.unique_mandate_reference,
- self.pool['res.partner.bank'].name_get(
- cr, uid,
- [payline.sdd_mandate_id.partner_bank_id.id])[0][1],
- ))
- return True
-
- _constraints = [
- (_check_mandate_bank_link, 'Error msg in raise',
- ['sdd_mandate_id', 'bank_id']),
- ]
-
-
-class account_invoice(orm.Model):
- _inherit = 'account.invoice'
-
- _columns = {
- 'sdd_mandate_id': fields.many2one(
- 'sdd.mandate', 'SEPA Direct Debit Mandate',
- domain=[('state', '=', 'valid')], readonly=True,
- states={'draft': [('readonly', False)]})
- }
+ return True
\ No newline at end of file
=== modified file 'account_banking_sepa_direct_debit/mandate_expire_cron.xml'
--- account_banking_sepa_direct_debit/mandate_expire_cron.xml 2013-11-07 22:22:19 +0000
+++ account_banking_sepa_direct_debit/mandate_expire_cron.xml 2014-06-25 11:54:20 +0000
@@ -17,7 +17,7 @@
<field name="interval_type">days</field>
<field name="numbercall">-1</field> <!-- don't limit the number of calls -->
<field name="doall" eval="False"/>
- <field name="model" eval="'sdd.mandate'"/>
+ <field name="model" eval="'account.banking.mandate'"/>
<field name="function" eval="'_sdd_mandate_set_state_to_expired'" />
<field name="args" eval="'()'"/>
</record>
=== added file 'account_banking_sepa_direct_debit/sdd_mandate_view.xml'
--- account_banking_sepa_direct_debit/sdd_mandate_view.xml 1970-01-01 00:00:00 +0000
+++ account_banking_sepa_direct_debit/sdd_mandate_view.xml 2014-06-25 11:54:20 +0000
@@ -0,0 +1,136 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2013 Akretion (http://www.akretion.com)
+ @author: Alexis de Lattre <alexis.delattre@xxxxxxxxxxxx>
+ The licence is in the file __openerp__.py
+-->
+<!--
+ Customize all mandate views (and actions) to fit SEPA mandate style
+-->
+<openerp>
+<data>
+
+<record id="sdd_mandate_form" model="ir.ui.view">
+ <field name="name">sdd.mandate.form</field>
+ <field name="model">account.banking.mandate</field>
+ <field name="inherit_id" ref="account_banking_mandate.dd_mandate_form"/>
+ <field name="arch" type="xml">
+ <data>
+ <xpath expr="//field[@name='partner_id']" position="after">
+ <field name="type" on_change="mandate_type_change(type)"/>
+ <field name="recurrent_sequence_type" attrs="{'invisible': [('type', '=', 'oneoff')], 'required': [('type', '=', 'recurrent')]}"/>
+ </xpath>
+ <xpath expr="//field[@name='partner_bank_id']" position="attributes">
+ <attribute name="on_change">mandate_partner_bank_change(partner_bank_id, type, recurrent_sequence_type, last_debit_date, state)</attribute>
+ </xpath>
+ <xpath expr="//field[@name='last_debit_date']" position="after">
+ <field name="sepa_migrated" groups="account_banking_sepa_direct_debit.group_original_mandate_required"/>
+ <field name="original_mandate_identification" attrs="{'invisible': [('sepa_migrated', '=', True)], 'required': [('sepa_migrated', '=', False)]}" groups="account_banking_sepa_direct_debit.group_original_mandate_required"/>
+ </xpath>
+ </data>
+ </field>
+</record>
+
+<record id="sdd_mandate_tree" model="ir.ui.view">
+ <field name="name">sdd.mandate.tree</field>
+ <field name="model">account.banking.mandate</field>
+ <field name="inherit_id" ref="account_banking_mandate.dd_mandate_tree"/>
+ <field name="arch" type="xml">
+ <data>
+ <xpath expr="//field[@name='unique_mandate_reference']" position="after">
+ <field name="type" string="Type"/>
+ </xpath>
+ </data>
+ </field>
+</record>
+
+<record id="sdd_mandate_search" model="ir.ui.view">
+ <field name="name">sdd.mandate.search</field>
+ <field name="model">account.banking.mandate</field>
+ <field name="inherit_id" ref="account_banking_mandate.dd_mandate_search"/>
+ <field name="arch" type="xml">
+ <xpath expr="//filter[@name='expired']" position="after">
+ <filter name="oneoff" string="One-Off" domain="[('type', '=', 'oneoff')]" />
+ <filter name="recurrent" string="Recurrent" domain="[('type', '=', 'recurrent')]" />
+ </xpath>
+ </field>
+</record>
+
+<record id="dd_mandate_action" model="ir.actions.act_window">
+ <field name="name">SEPA Direct Debit Mandates</field>
+ <field name="res_model">account.banking.mandate</field>
+ <field name="view_type">form</field>
+ <field name="view_mode">tree,form</field>
+ <field name="help" type="html">
+ <p class="oe_view_nocontent_create">
+ Click to create a new SEPA Direct Debit Mandate.
+ </p><p>
+ A SEPA Direct Debit Mandate is a document signed by your customer that gives you the autorization to do one or several direct debits on his bank account.
+ </p>
+ </field>
+</record>
+
+<menuitem id="account_banking_mandate.dd_mandate_menu"
+ parent="account_payment.menu_main_payment"
+ action="dd_mandate_action"
+ sequence="40"
+ />
+
+<record id="sdd_mandate_partner_bank_form" model="ir.ui.view">
+ <field name="name">sdd.mandate.res.partner.bank.form</field>
+ <field name="model">res.partner.bank</field>
+ <field name="inherit_id" ref="account_banking_mandate.dd_mandate_partner_bank_form"/>
+ <field name="arch" type="xml">
+ <xpath expr="//group[@name='dd_mandates']" position="attributes">
+ <attribute name="string">SEPA Direct Debit Mandates</attribute>
+ </xpath>
+ </field>
+</record>
+
+<record id="sdd_mandate_partner_bank_tree" model="ir.ui.view">
+ <field name="name">sdd.mandate.res.partner.bank.tree</field>
+ <field name="model">res.partner.bank</field>
+ <field name="inherit_id" ref="account_banking_mandate.dd_mandate_partner_bank_tree"/>
+ <field name="arch" type="xml">
+ <xpath expr="//field[@name='mandate_ids']" position="attributes">
+ <attribute name="string">SDD Mandates</attribute>
+ </xpath>
+ </field>
+</record>
+
+<record id="sdd_mandate_partner_form" model="ir.ui.view">
+ <field name="name">sdd.mandate.partner.form</field>
+ <field name="model">res.partner</field>
+ <field name="inherit_id" ref="account_banking_mandate.dd_mandate_partner_form"/>
+ <field name="arch" type="xml">
+ <xpath expr="//field[@name='bank_ids']/tree/field[@name='mandate_ids']" position="attributes">
+ <attribute name="string">SDD Mandates</attribute>
+ </xpath>
+ </field>
+</record>
+
+
+<!-- notifications in the chatter -->
+<record id="recurrent_sequence_type_first" model="mail.message.subtype">
+ <field name="name">Sequence Type set to First</field>
+ <field name="res_model">account.banking.mandate</field>
+ <field name="default" eval="False"/>
+ <field name="description">Sequence Type set to First</field>
+</record>
+
+<record id="recurrent_sequence_type_recurring" model="mail.message.subtype">
+ <field name="name">Sequence Type set to Recurring</field>
+ <field name="res_model">account.banking.mandate</field>
+ <field name="default" eval="False"/>
+ <field name="description">Sequence Type set to Recurring</field>
+</record>
+
+<record id="recurrent_sequence_type_final" model="mail.message.subtype">
+ <field name="name">Sequence Type set to Final</field>
+ <field name="res_model">account.banking.mandate</field>
+ <field name="default" eval="False"/>
+ <field name="description">Sequence Type set to Final</field>
+</record>
+
+</data>
+</openerp>
=== modified file 'account_banking_sepa_direct_debit/security/ir.model.access.csv'
--- account_banking_sepa_direct_debit/security/ir.model.access.csv 2013-10-15 21:29:28 +0000
+++ account_banking_sepa_direct_debit/security/ir.model.access.csv 2014-06-25 11:54:20 +0000
@@ -1,4 +1,4 @@
"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
"access_banking_export_sdd","Full access on banking.export.sdd","model_banking_export_sdd","account_payment.group_account_payment",1,1,1,1
-"access_sdd_mandate","Full access on sdd.mandate","model_sdd_mandate","account_payment.group_account_payment",1,1,1,1
-"access_sdd_mandate_read","Read access on sdd.mandate","model_sdd_mandate","base.group_user",1,0,0,0
+"access_sdd_mandate","Full access on sdd.mandate","model_account_banking_mandate","account_payment.group_account_payment",1,1,1,1
+"access_sdd_mandate_read","Read access on sdd.mandate","model_account_banking_mandate","base.group_user",1,0,0,0
=== modified file 'account_banking_sepa_direct_debit/sepa_direct_debit_demo.xml'
--- account_banking_sepa_direct_debit/sepa_direct_debit_demo.xml 2014-02-16 14:01:09 +0000
+++ account_banking_sepa_direct_debit/sepa_direct_debit_demo.xml 2014-06-25 11:54:20 +0000
@@ -15,7 +15,7 @@
<field name="sepa_creditor_identifier">FR78ZZZ424242</field>
</record>
-<record id="res_partner_12_mandate" model="sdd.mandate">
+<record id="res_partner_12_mandate" model="account.banking.mandate">
<field name="partner_bank_id" ref="account_banking_payment_export.res_partner_12_iban"/>
<field name="type">recurrent</field>
<field name="recurrent_sequence_type">first</field>
=== modified file 'account_banking_sepa_direct_debit/wizard/export_sdd.py'
--- account_banking_sepa_direct_debit/wizard/export_sdd.py 2014-01-05 23:51:22 +0000
+++ account_banking_sepa_direct_debit/wizard/export_sdd.py 2014-06-25 11:54:20 +0000
@@ -93,7 +93,7 @@
previous_bank = False
payline_ids = payline_obj.search(
cr, uid, [
- ('sdd_mandate_id', '=', payline.sdd_mandate_id.id),
+ ('mandate_id', '=', payline.mandate_id.id),
('bank_id', '!=', payline.bank_id.id),
],
context=context)
@@ -188,22 +188,22 @@
requested_date = payment_order.date_scheduled or today
else:
requested_date = today
- if not line.sdd_mandate_id:
+ if not line.mandate_id:
raise orm.except_orm(
_('Error:'),
_("Missing SEPA Direct Debit mandate on the payment "
"line with partner '%s' and Invoice ref '%s'.")
% (line.partner_id.name,
line.ml_inv_ref.number))
- if line.sdd_mandate_id.state != 'valid':
+ if line.mandate_id.state != 'valid':
raise orm.except_orm(
_('Error:'),
_("The SEPA Direct Debit mandate with reference '%s' "
"for partner '%s' has expired.")
- % (line.sdd_mandate_id.unique_mandate_reference,
- line.sdd_mandate_id.partner_id.name))
- if line.sdd_mandate_id.type == 'oneoff':
- if not line.sdd_mandate_id.last_debit_date:
+ % (line.mandate_id.unique_mandate_reference,
+ line.mandate_id.partner_id.name))
+ if line.mandate_id.type == 'oneoff':
+ if not line.mandate_id.last_debit_date:
seq_type = 'OOFF'
else:
raise orm.except_orm(
@@ -212,17 +212,17 @@
"'%s' has type set to 'One-Off' and it has a "
"last debit date set to '%s', so we can't use "
"it.")
- % (line.sdd_mandate_id.unique_mandate_reference,
- line.sdd_mandate_id.partner_id.name,
- line.sdd_mandate_id.last_debit_date))
- elif line.sdd_mandate_id.type == 'recurrent':
+ % (line.mandate_id.unique_mandate_reference,
+ line.mandate_id.partner_id.name,
+ line.mandate_id.last_debit_date))
+ elif line.mandate_id.type == 'recurrent':
seq_type_map = {
'recurring': 'RCUR',
'first': 'FRST',
'final': 'FNAL',
}
seq_type_label = \
- line.sdd_mandate_id.recurrent_sequence_type
+ line.mandate_id.recurrent_sequence_type
assert seq_type_label is not False
seq_type = seq_type_map[seq_type_label]
@@ -306,22 +306,22 @@
mandate_related_info_2_47, 'MndtId')
mandate_identification_2_48.text = self._prepare_field(
cr, uid, 'Unique Mandate Reference',
- 'line.sdd_mandate_id.unique_mandate_reference',
+ 'line.mandate_id.unique_mandate_reference',
{'line': line}, 35,
gen_args=gen_args, context=context)
mandate_signature_date_2_49 = etree.SubElement(
mandate_related_info_2_47, 'DtOfSgntr')
mandate_signature_date_2_49.text = self._prepare_field(
cr, uid, 'Mandate Signature Date',
- 'line.sdd_mandate_id.signature_date',
+ 'line.mandate_id.signature_date',
{'line': line}, 10,
gen_args=gen_args, context=context)
if sequence_type == 'FRST' and (
- line.sdd_mandate_id.last_debit_date or
- not line.sdd_mandate_id.sepa_migrated):
+ line.mandate_id.last_debit_date or
+ not line.mandate_id.sepa_migrated):
previous_bank = self._get_previous_bank(
cr, uid, line, context=context)
- if previous_bank or not line.sdd_mandate_id.sepa_migrated:
+ if previous_bank or not line.mandate_id.sepa_migrated:
amendment_indicator_2_50 = etree.SubElement(
mandate_related_info_2_47, 'AmdmntInd')
amendment_indicator_2_50.text = 'true'
@@ -362,13 +362,13 @@
ori_debtor_agent_other, 'Id')
ori_debtor_agent_other_id.text = 'SMNDA'
# SMNDA = Same Mandate New Debtor Agent
- elif not line.sdd_mandate_id.sepa_migrated:
+ elif not line.mandate_id.sepa_migrated:
ori_mandate_identification_2_52 = etree.SubElement(
amendment_info_details_2_51, 'OrgnlMndtId')
ori_mandate_identification_2_52.text = \
self._prepare_field(
cr, uid, 'Original Mandate Identification',
- 'line.sdd_mandate_id.'
+ 'line.mandate_id.'
'original_mandate_identification',
{'line': line},
gen_args=gen_args,
@@ -425,25 +425,25 @@
wf_service = netsvc.LocalService('workflow')
for order in sepa_export.payment_order_ids:
wf_service.trg_validate(uid, 'payment.order', order.id, 'done', cr)
- mandate_ids = [line.sdd_mandate_id.id for line in order.line_ids]
- self.pool['sdd.mandate'].write(
+ mandate_ids = [line.mandate_id.id for line in order.line_ids]
+ self.pool['account.banking.mandate'].write(
cr, uid, mandate_ids,
{'last_debit_date': datetime.today().strftime('%Y-%m-%d')},
context=context)
to_expire_ids = []
first_mandate_ids = []
for line in order.line_ids:
- if line.sdd_mandate_id.type == 'oneoff':
- to_expire_ids.append(line.sdd_mandate_id.id)
- elif line.sdd_mandate_id.type == 'recurrent':
- seq_type = line.sdd_mandate_id.recurrent_sequence_type
+ if line.mandate_id.type == 'oneoff':
+ to_expire_ids.append(line.mandate_id.id)
+ elif line.mandate_id.type == 'recurrent':
+ seq_type = line.mandate_id.recurrent_sequence_type
if seq_type == 'final':
- to_expire_ids.append(line.sdd_mandate_id.id)
+ to_expire_ids.append(line.mandate_id.id)
elif seq_type == 'first':
- first_mandate_ids.append(line.sdd_mandate_id.id)
- self.pool['sdd.mandate'].write(
+ first_mandate_ids.append(line.mandate_id.id)
+ self.pool['account.banking.mandate'].write(
cr, uid, to_expire_ids, {'state': 'expired'}, context=context)
- self.pool['sdd.mandate'].write(
+ self.pool['account.banking.mandate'].write(
cr, uid, first_mandate_ids, {
'recurrent_sequence_type': 'recurring',
'sepa_migrated': True,
References