-
Notifications
You must be signed in to change notification settings - Fork 7
/
account.py
45 lines (35 loc) · 1.36 KB
/
account.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
from trytond.i18n import gettext
from trytond.model import ModelView
from trytond.modules.account.exceptions import PostError
from trytond.pool import Pool, PoolMeta
class Journal(metaclass=PoolMeta):
__name__ = 'account.journal'
@classmethod
def __setup__(cls):
super(Journal, cls).__setup__()
cls.type.selection.append(('statement', "Statement"))
class Move(metaclass=PoolMeta):
__name__ = 'account.move'
@classmethod
def _get_origin(cls):
return super(Move, cls)._get_origin() + ['account.statement']
@classmethod
@ModelView.button
def post(cls, moves):
pool = Pool()
Statement = pool.get('account.statement')
for move in moves:
if (isinstance(move.origin, Statement)
and move.origin.state != 'posted'):
raise PostError(
gettext('account_statement.msg_post_statement_move',
move=move.rec_name,
statement=move.origin.rec_name))
super().post(moves)
class MoveLine(metaclass=PoolMeta):
__name__ = 'account.move.line'
@classmethod
def _get_origin(cls):
return super()._get_origin() + ['account.statement.line']