Prevent to change the type of journal with posted moves

issue11256
review399061002
This commit is contained in:
David Blanco Bautista
2022-04-11 20:19:52 +02:00
parent ef3bc6c231
commit c2d181ef24
3 changed files with 23 additions and 0 deletions
+1
View File
@@ -1,3 +1,4 @@
* Prevent to change the type of journal with posted moves
* Mute reconciled payable/receivable lines
* Add delegated amount on move lines
* Enforce same type for children account as their parent
+19
View File
@@ -151,6 +151,25 @@ class Journal(
debit - credit)
return result
@classmethod
def write(cls, *args):
pool = Pool()
Move = pool.get('account.move')
actions = iter(args)
for journals, values in zip(actions, actions):
if 'type' in values:
for sub_journals in grouped_slice(journals):
moves = Move.search([
('journal', 'in', [j.id for j in sub_journals]),
('state', '=', 'posted')
], order=[], limit=1)
if moves:
move, = moves
raise AccessError(gettext(
'account.msg_journal_account_moves',
journal=move.journal.rec_name))
super().write(*args)
class JournalSequence(ModelSQL, CompanyValueMixin):
"Journal Sequence"
+3
View File
@@ -234,5 +234,8 @@ You may need to cancel its move "%(move)s".</field>
<record model="ir.message" id="msg_close_period_inactive_accounts">
<field name="text">To close period "%(period)s", you must balance the inactive account "%(account)s".</field>
</record>
<record model="ir.message" id="msg_journal_account_moves">
<field name="text">You cannot change the type of journal "%(journal)s" because it has posted moves.</field>
</record>
</data>
</tryton>