Add back2draft on SEPA Direct Debit mandates (in case it was cancelled by mistake).

This commit is contained in:
Alexis de Lattre
2014-06-12 00:03:21 +02:00
parent 4faa3be557
commit dd022faafb
2 changed files with 14 additions and 1 deletions

View File

@@ -314,6 +314,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() + \

View File

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