mirror of
https://github.com/OCA/bank-payment.git
synced 2025-02-02 10:37:31 +02:00
Don't allow deletion of an uploaded payment order + allow to cancel an uploaded payment order
This commit is contained in:
@@ -95,6 +95,14 @@ class AccountPaymentOrder(models.Model):
|
|||||||
'account.move', 'payment_order_id', string='Journal Entries',
|
'account.move', 'payment_order_id', string='Journal Entries',
|
||||||
readonly=True)
|
readonly=True)
|
||||||
|
|
||||||
|
@api.multi
|
||||||
|
def unlink(self):
|
||||||
|
for order in self:
|
||||||
|
if order.state == 'uploaded':
|
||||||
|
raise ValidationError(_(
|
||||||
|
"You cannot delete an uploaded payment order. You can "
|
||||||
|
"cancel it in order to do so."))
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
@api.constrains('payment_type', 'payment_mode_id')
|
@api.constrains('payment_type', 'payment_mode_id')
|
||||||
def payment_order_constraints(self):
|
def payment_order_constraints(self):
|
||||||
@@ -175,6 +183,16 @@ class AccountPaymentOrder(models.Model):
|
|||||||
})
|
})
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@api.multi
|
||||||
|
def action_done_cancel(self):
|
||||||
|
for move in self.move_ids:
|
||||||
|
move.button_cancel()
|
||||||
|
for move_line in move.line_ids:
|
||||||
|
move_line.remove_move_reconcile()
|
||||||
|
move.unlink()
|
||||||
|
self.action_cancel()
|
||||||
|
return True
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def cancel2draft(self):
|
def cancel2draft(self):
|
||||||
self.write({'state': 'draft'})
|
self.write({'state': 'draft'})
|
||||||
|
|||||||
@@ -22,6 +22,8 @@
|
|||||||
string="Back to Draft" />
|
string="Back to Draft" />
|
||||||
<button name="action_cancel" type="object" states="draft,open,generated"
|
<button name="action_cancel" type="object" states="draft,open,generated"
|
||||||
string="Cancel Payments"/>
|
string="Cancel Payments"/>
|
||||||
|
<button name="action_done_cancel" type="object" states="uploaded"
|
||||||
|
string="Cancel Payments"/>
|
||||||
<field name="state" widget="statusbar"/>
|
<field name="state" widget="statusbar"/>
|
||||||
</header>
|
</header>
|
||||||
<sheet>
|
<sheet>
|
||||||
|
|||||||
Reference in New Issue
Block a user