Prevent to change the type of journal with posted moves
issue11256 review399061002
This commit is contained in:
@@ -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
@@ -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"
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user