From 9d29805055b33aa5f338a3f9858e15302a36c132 Mon Sep 17 00:00:00 2001 From: Alnus Tmp Date: Sun, 7 Feb 2021 18:39:18 -0500 Subject: [PATCH] Permitir terceros en cuentas de Ingresos y Gastos --- __init__.py | 2 ++ account.py | 34 +++++++++++++++++++++++++++++++++- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/__init__.py b/__init__.py index d1743f6..e478d16 100644 --- a/__init__.py +++ b/__init__.py @@ -17,7 +17,9 @@ def register(): country.Subdivision, rut.TaxLevelCode, configuration.Configuration, + account.Account, account.Move, + account.Line, module='account_co_co', type_='model') Pool.register( module='account_co_co', type_='wizard') diff --git a/account.py b/account.py index d4c33f3..0e0a750 100644 --- a/account.py +++ b/account.py @@ -1,6 +1,17 @@ from trytond.pool import Pool, PoolMeta -__all__ = ['Move'] +__all__ = ['Account','Move','Line'] + + +class Account(metaclass=PoolMeta): + __name__ = 'account.account' + + @classmethod + def __setup__(cls): + super(Account, cls).__setup__() + cls.party_required.domain = [()] + cls.party_required.states = {} + class Move(metaclass=PoolMeta): __name__ = 'account.move' @@ -27,3 +38,24 @@ class Move(metaclass=PoolMeta): moves = super(Move, cls).create(vlist) cls.validate_move(moves) return moves + + +class Line(metaclass=PoolMeta): + __name__ = 'account.move.line' + @classmethod + def __setup__(cls): + super(Line, cls).__setup__() + cls.party.states = {} + + def check_account(self): + if not self.account.type or self.account.closed: + raise AccessError( + gettext('account.msg_line_closed_account', + account=self.account.rec_name)) + if self.account.party_required: + if bool(self.party) != bool(self.account.party_required): + error = 'party_set' if self.party else 'party_required' + raise AccessError( + gettext('account.msg_line_%s' % error, + account=self.account.rec_name, + line=self.rec_name))