Creación de secuencia por defectado para asientos borradores y mantener el consecutivo de las otras secuencias

This commit is contained in:
Alnus Tmp 2021-02-02 12:43:54 -05:00
parent fa61a1776e
commit f380f6a45c
7 changed files with 69 additions and 0 deletions

View file

@ -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')

29
account.py Normal file
View file

@ -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

10
configuration.py Normal file
View file

@ -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")

10
configuration.xml Normal file
View file

@ -0,0 +1,10 @@
<?xml version='1.0'?>
<tryton>
<data>
<record model="ir.ui.view" id="configuration_view_form">
<field name="model">account.configuration</field>
<field name="inherit" ref="account.configuration_view_form"/>
<field name="name">configuration_form</field>
</record>
</data>
</tryton>

View file

@ -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"

View file

@ -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

View file

@ -0,0 +1,10 @@
<?xml version="1.0"?>
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<data>
<xpath expr="/form/field[@name='default_supplier_tax_rule']"
position="after">
<label name="default_draft_sequence"/>
<field name="default_draft_sequence"/>
</xpath>
</data>