mirror of
https://github.com/OCA/bank-payment.git
synced 2025-02-02 10:37:31 +02:00
Add group in order to mask the fields for "Original Mandate Indentification" for user s in countries that don't required it. Add tracking on important fields of the mandate. Better form view on company. Update constraint on mandate following my devs on "Original Mandate Identification".
This commit is contained in:
committed by
Enric Tobella
parent
2e3174c0de
commit
09af19ee2e
@@ -31,6 +31,7 @@
|
||||
'python': ['unidecode', 'lxml'],
|
||||
},
|
||||
'data': [
|
||||
'security/original_mandate_required_security.xml',
|
||||
'account_banking_sdd_view.xml',
|
||||
'sdd_mandate_view.xml',
|
||||
'res_partner_bank_view.xml',
|
||||
|
||||
@@ -118,24 +118,27 @@ class sdd_mandate(orm.Model):
|
||||
}
|
||||
|
||||
_columns = {
|
||||
'partner_bank_id': fields.many2one('res.partner.bank', 'Bank Account'),
|
||||
'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),
|
||||
'Unique Mandate Reference', size=35, readonly=True,
|
||||
track_visibility='always'),
|
||||
'type': fields.selection([
|
||||
('recurrent', 'Recurrent'),
|
||||
('oneoff', 'One-Off'),
|
||||
], 'Type of Mandate', required=True),
|
||||
], 'Type of Mandate', required=True, track_visibility='always'),
|
||||
'recurrent_sequence_type': fields.selection([
|
||||
('first', 'First'),
|
||||
('recurring', 'Recurring'),
|
||||
('final', 'Final'),
|
||||
], 'Sequence Type for Next Debit',
|
||||
], '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'),
|
||||
'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),
|
||||
@@ -149,10 +152,11 @@ class sdd_mandate(orm.Model):
|
||||
'payment_line_ids': fields.one2many(
|
||||
'payment.line', 'sdd_mandate_id', "Related Payment Lines"),
|
||||
'sepa_migrated': fields.boolean(
|
||||
'Migrated to SEPA',
|
||||
help="If this field is not active, the mandate section of the direct debit file will contain the Original Mandate Identification and the Original Creditor Scheme Identification."),
|
||||
'Migrated to SEPA', track_visibility='onchange',
|
||||
help="If this field is not active, the mandate section of the next direct debit file that include this mandate will contain the 'Original Mandate Identification' and the 'Original Creditor Scheme Identification'. This is required in a few countries (Belgium for instance), but not in all countries. If this is not required in your country, you should keep this field always active."),
|
||||
'original_mandate_identification': fields.char(
|
||||
'Original Mandate Identification', size=35,
|
||||
track_visibility='onchange',
|
||||
help="When the field 'Migrated to SEPA' is not active, this field will be used as the Original Mandate Identification in the the Direct Debit file."),
|
||||
}
|
||||
|
||||
@@ -172,48 +176,57 @@ class sdd_mandate(orm.Model):
|
||||
'A Mandate with the same reference already exists for this company !'
|
||||
)]
|
||||
|
||||
def _check_sdd_mandate(self, cr, uid, ids, context=None):
|
||||
for mandate in self.read(cr, uid, ids, [
|
||||
'last_debit_date', 'signature_date',
|
||||
'unique_mandate_reference', 'state', 'partner_bank_id',
|
||||
'type', 'recurrent_sequence_type',
|
||||
], context=context):
|
||||
if (mandate['signature_date'] and
|
||||
mandate['signature_date'] >
|
||||
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']:
|
||||
% 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']:
|
||||
% 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'])
|
||||
% mandate.unique_mandate_reference)
|
||||
|
||||
if (mandate['signature_date'] and mandate['last_debit_date'] and
|
||||
mandate['signature_date'] > mandate['last_debit_date']):
|
||||
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']):
|
||||
% mandate.unique_mandate_reference)
|
||||
if (mandate.type == 'recurrent'
|
||||
and not mandate.recurrent_sequence_type):
|
||||
raise orm.except_orm(
|
||||
_('Error:'),
|
||||
_("The recurrent mandate '%s' must have a sequence type.")
|
||||
% mandate['unique_mandate_reference'])
|
||||
% mandate.unique_mandate_reference)
|
||||
if (mandate.type == 'recurrent' and not mandate.sepa_migrated
|
||||
and mandate.recurrent_sequence_type != 'first'):
|
||||
raise orm.except_orm(
|
||||
_('Error:'),
|
||||
_("The recurrent mandate '%s' which is not marked as 'Migrated to SEPA' must have its recurrent sequence type set to 'First'.")
|
||||
% mandate.unique_mandate_reference)
|
||||
if (mandate.type == 'recurrent' and not mandate.sepa_migrated
|
||||
and not mandate.original_mandate_identification):
|
||||
raise orm.except_orm(
|
||||
_('Error:'),
|
||||
_("You must set the 'Original Mandate Identification' on the recurrent mandate '%s' which is not marked as 'Migrated to SEPA'.")
|
||||
% mandate.unique_mandate_reference)
|
||||
return True
|
||||
|
||||
_constraints = [
|
||||
(_check_sdd_mandate, "Error msg in raise", [
|
||||
'last_debit_date', 'signature_date', 'state', 'partner_bank_id',
|
||||
'type', 'recurrent_sequence_type',
|
||||
'type', 'recurrent_sequence_type', 'sepa_migrated',
|
||||
'original_mandate_identification',
|
||||
]),
|
||||
]
|
||||
|
||||
|
||||
@@ -10,12 +10,12 @@
|
||||
<record id="sdd_res_company_form" model="ir.ui.view">
|
||||
<field name="name">sepa_direct_debit.res.company.form</field>
|
||||
<field name="model">res.company</field>
|
||||
<field name="inherit_id" ref="base.view_company_form"/>
|
||||
<field name="inherit_id" ref="account_banking_pain_base.view_company_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="currency_id" position="after">
|
||||
<group name="pain" position="inside">
|
||||
<field name="sepa_creditor_identifier"/>
|
||||
<field name="original_creditor_identifier"/>
|
||||
</field>
|
||||
<field name="original_creditor_identifier" groups="account_banking_sepa_direct_debit.group_original_mandate_required"/>
|
||||
</group>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
@@ -35,8 +35,8 @@
|
||||
<field name="signature_date"/>
|
||||
<field name="scan"/>
|
||||
<field name="last_debit_date"/>
|
||||
<field name="sepa_migrated"/>
|
||||
<field name="original_mandate_identification" attrs="{'invisible': [('sepa_migrated', '=', True)], 'required': [('sepa_migrated', '=', False)]}"/>
|
||||
<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"/>
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2013 Akretion (http://www.akretion.com/)
|
||||
@author: Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
The licence is in the file __openerp__.py
|
||||
-->
|
||||
|
||||
<openerp>
|
||||
<data noupdate="1">
|
||||
|
||||
<record id="group_original_mandate_required" model="res.groups">
|
||||
<field name="name">Original Mandate Required (SEPA)</field>
|
||||
<field name="category_id" ref="base.module_category_hidden"/>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
Reference in New Issue
Block a user