mirror of
https://github.com/OCA/bank-payment.git
synced 2025-02-02 10:37:31 +02:00
[IMP] back2draft on SEPA Direct Debit mandates (in case it was cancelled by mistake)
This commit is contained in:
@@ -191,8 +191,7 @@ class sdd_mandate(orm.Model):
|
||||
'company_id': lambda self, cr, uid, context:
|
||||
self.pool['res.company']._company_default_get(
|
||||
cr, uid, 'sdd.mandate', context=context),
|
||||
'unique_mandate_reference': lambda self, cr, uid, ctx:
|
||||
self.pool['ir.sequence'].get(cr, uid, 'sdd.mandate.reference'),
|
||||
'unique_mandate_reference': '/',
|
||||
'state': 'draft',
|
||||
'sepa_migrated': True,
|
||||
}
|
||||
@@ -203,6 +202,13 @@ class sdd_mandate(orm.Model):
|
||||
'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
|
||||
@@ -314,6 +320,16 @@ class sdd_mandate(orm.Model):
|
||||
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() + \
|
||||
|
||||
@@ -13,8 +13,11 @@
|
||||
<field name="arch" type="xml">
|
||||
<form string="SEPA Direct Debit Mandate" version="7.0">
|
||||
<header>
|
||||
<button name="validate" type="object" string="Validate" states="draft"/>
|
||||
<button name="validate" type="object" string="Validate" states="draft" class="oe_highlight"/>
|
||||
<button name="cancel" type="object" string="Cancel" states="draft,valid"/>
|
||||
<button name="back2draft" type="object" string="Back to Draft"
|
||||
states="cancel" groups="account.group_account_manager"
|
||||
confirm="You should set a mandate back to draft only if you cancelled it by mistake. Do you want to continue ?"/>
|
||||
<field name="state" widget="statusbar"/>
|
||||
</header>
|
||||
<sheet>
|
||||
|
||||
Reference in New Issue
Block a user