Skip to content

Commit

Permalink
[FIX] account_multic_fix: don't change journal if invoice is cancelled
Browse files Browse the repository at this point in the history
closes #112

Ticket: 56784
Signed-off-by: Katherine Zaoral <kz@adhoc.com.ar>
  • Loading branch information
pablohmontenegro committed Nov 24, 2022
1 parent 49c00b7 commit f14015c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions account_multic_fix/README.rst
Expand Up @@ -16,6 +16,7 @@ Account Multi Company Fixes

#. Add check_company on account.move and account.move.line (backported from odoo master https://github.com/odoo/odoo/commit/847889b49768db290f86ab5c5f48e8134fa29266) (TODO remove on v14)
#. Some fixes so that you can change to a journal of different company and everthing is updated correctly
#. Don´t allow to change the journal if the state of the invoice is cancelled.

TODO (Viejo):
arreglar para los statments, por ahora no pudismo hacer que nade bien, sobre todo la parte de que
Expand Down
10 changes: 9 additions & 1 deletion account_multic_fix/models/account_move.py
Expand Up @@ -2,7 +2,8 @@
# For copyright and license notices, see __manifest__.py file in module root
# directory
##############################################################################
from odoo import models, api
from odoo import models, api, _
from odoo.exceptions import UserError


class AccountMove(models.Model):
Expand Down Expand Up @@ -76,3 +77,10 @@ def _compute_suitable_journal_ids(self):
company_ids = self.env.companies.ids
domain = [('company_id', 'in', company_ids), ('type', '=', journal_type)]
m.suitable_journal_ids = self.env['account.journal'].search(domain)

@api.constrains('journal_id')
def _check_invoice_state(self):
"""This method don´t allow to change the journal if the state of the invoice is 'cancel'"""
for inv in self:
if inv.state == 'cancel':
raise UserError(_('It is not possible to change the journal if the invoice is cancelled. You can edit it changing the invoice state to draft.'))

0 comments on commit f14015c

Please sign in to comment.