diff --git a/__init__.py b/__init__.py index 9a663d3..d1743f6 100644 --- a/__init__.py +++ b/__init__.py @@ -2,6 +2,8 @@ from trytond.pool import Pool from . import party from . import country from . import rut +from . import configuration +from . import account __all__ = ['register'] @@ -14,6 +16,8 @@ def register(): party.Address, country.Subdivision, rut.TaxLevelCode, + configuration.Configuration, + account.Move, module='account_co_co', type_='model') Pool.register( module='account_co_co', type_='wizard') diff --git a/account.py b/account.py new file mode 100644 index 0000000..d4c33f3 --- /dev/null +++ b/account.py @@ -0,0 +1,29 @@ +from trytond.pool import Pool, PoolMeta + +__all__ = ['Move'] + +class Move(metaclass=PoolMeta): + __name__ = 'account.move' + + @classmethod + def create(cls, vlist): + pool = Pool() + Sequence = pool.get('ir.sequence') + Journal = pool.get('account.journal') + Account_Configuration = pool.get('account.configuration') + configuration = Account_Configuration(1) + draft_default = configuration.default_draft_sequence + + vlist = [x.copy() for x in vlist] + for vals in vlist: + if not vals.get('number'): + journal_id = (vals.get('journal') + or Transaction().context.get('journal')) + if journal_id: + journal = Journal(journal_id) + if journal.sequence: + vals['number'] = Sequence.get_id(draft_default.id) + + moves = super(Move, cls).create(vlist) + cls.validate_move(moves) + return moves diff --git a/configuration.py b/configuration.py new file mode 100644 index 0000000..2e386a0 --- /dev/null +++ b/configuration.py @@ -0,0 +1,10 @@ +from trytond.model import fields +from trytond.pool import PoolMeta + +__all__ = ['Configuration'] + +class Configuration(metaclass=PoolMeta): + __name__ = 'account.configuration' + + default_draft_sequence = fields.Many2One( + 'ir.sequence', "Draft Sequence") diff --git a/configuration.xml b/configuration.xml new file mode 100644 index 0000000..3208e50 --- /dev/null +++ b/configuration.xml @@ -0,0 +1,10 @@ + + + + + account.configuration + + configuration_form + + + diff --git a/locale/es.po b/locale/es.po index 9f703c7..12adb23 100644 --- a/locale/es.po +++ b/locale/es.po @@ -50,6 +50,10 @@ msgctxt "field:party.party,type_person:" msgid "Type Person" msgstr "Tipo de Persona" +msgctxt "field:account.configuration,default_draft_sequence:" +msgid "Draft Sequence" +msgstr "Secuencia Borrador" + msgctxt "view:party.party:" msgid "Economic Activity" msgstr "Actividad Económica" diff --git a/tryton.cfg b/tryton.cfg index 5834222..318d0c4 100644 --- a/tryton.cfg +++ b/tryton.cfg @@ -4,6 +4,7 @@ depends: ir party country + account xml: party.xml address.xml @@ -13,3 +14,4 @@ xml: municipalities_colombia.xml address_subdivision_types_colombia.xml tipo_responsabilidad.xml + configuration.xml \ No newline at end of file diff --git a/view/configuration_form.xml b/view/configuration_form.xml new file mode 100644 index 0000000..32b4013 --- /dev/null +++ b/view/configuration_form.xml @@ -0,0 +1,10 @@ + + + + + +