Skip to content

Commit

Permalink
[8.0] evita di riaprire fattura se presente una ricevuta bancaria (OC…
Browse files Browse the repository at this point in the history
  • Loading branch information
scigghia authored and TheMule71 committed Oct 15, 2021
1 parent d11a4d3 commit 69aafc1
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions l10n_it_ricevute_bancarie/models/account/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,27 @@ def action_invoice_draft(self):
super(AccountInvoice, self).action_invoice_draft()

@api.multi
def action_cancel(self):
for invoice in self:
# we get move_lines with date_maturity and check if they are
# present in some riba_distinta_line
move_line_model = self.env['account.move.line']
rdml_model = self.env['riba.distinta.move.line']
move_line_ids = move_line_model.search([
('move_id', '=', invoice.move_id.id),
('date_maturity', '!=', False)])
if move_line_ids:
riba_line_ids = rdml_model.search(
[('move_line_id', 'in', [m.id for m in move_line_ids])])
if riba_line_ids:
if len(riba_line_ids) > 1:
riba_line_ids = riba_line_ids[0]
raise UserError(
_('Invoice is linked to RI.BA. list nr {riba}').format(
riba=riba_line_ids.riba_line_id.distinta_id.name
))
super(AccountInvoice, self).action_cancel()

def copy(self, default=None):
self.ensure_one()
# Delete Due Cost Line of invoice when copying
Expand Down

0 comments on commit 69aafc1

Please sign in to comment.