mirror of
https://github.com/NaN-tic/trytond-analytic_line_state.git
synced 2023-12-14 03:33:02 +01:00
Add again the function "check_modify" in the account.move.line module.
Prepare the function delete to only delte when the account.move.line move is not posted. Task #158863
This commit is contained in:
parent
7a90745971
commit
43245fd3df
19
account.py
19
account.py
|
@ -7,6 +7,7 @@ from trytond.pool import Pool, PoolMeta
|
||||||
from trytond.pyson import Eval, Bool
|
from trytond.pyson import Eval, Bool
|
||||||
from trytond.i18n import gettext
|
from trytond.i18n import gettext
|
||||||
from trytond.exceptions import UserError
|
from trytond.exceptions import UserError
|
||||||
|
from trytond.model.exceptions import AccessError
|
||||||
|
|
||||||
__all__ = ['Configuration', 'Account', 'Move', 'MoveLine']
|
__all__ = ['Configuration', 'Account', 'Move', 'MoveLine']
|
||||||
|
|
||||||
|
@ -178,6 +179,16 @@ class Move(metaclass=PoolMeta):
|
||||||
class MoveLine(metaclass=PoolMeta):
|
class MoveLine(metaclass=PoolMeta):
|
||||||
__name__ = 'account.move.line'
|
__name__ = 'account.move.line'
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def check_modify(cls, lines, modified_fields=None):
|
||||||
|
'''
|
||||||
|
Check if the lines can be modified
|
||||||
|
'''
|
||||||
|
if modified_fields is None:
|
||||||
|
return
|
||||||
|
|
||||||
|
super(MoveLine, cls).check_modify(lines, modified_fields)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def validate(cls, lines):
|
def validate(cls, lines):
|
||||||
super(MoveLine, cls).validate(lines)
|
super(MoveLine, cls).validate(lines)
|
||||||
|
@ -245,6 +256,14 @@ class MoveLine(metaclass=PoolMeta):
|
||||||
AnalyticLine.write(todraft_lines, {
|
AnalyticLine.write(todraft_lines, {
|
||||||
'state': 'draft',
|
'state': 'draft',
|
||||||
})
|
})
|
||||||
|
|
||||||
|
for line in lines:
|
||||||
|
if line.move.state == 'posted':
|
||||||
|
raise AccessError(gettext(
|
||||||
|
'account.msg_modify_line_posted_move',
|
||||||
|
line=line.rec_name,
|
||||||
|
move=line.move.rec_name,
|
||||||
|
))
|
||||||
super(MoveLine, cls).delete(lines)
|
super(MoveLine, cls).delete(lines)
|
||||||
|
|
||||||
@dualmethod
|
@dualmethod
|
||||||
|
|
Loading…
Reference in a new issue