Store directly sequence type to sequence
issue10122 review351381002
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
* Add reconciliation sequence to configuration
|
||||
* Add report for income statement and balance sheet
|
||||
* Allow filtering general ledger by journal
|
||||
* Add journal context to Move.query_get
|
||||
|
||||
@@ -44,6 +44,7 @@ def register():
|
||||
configuration.Configuration,
|
||||
configuration.ConfigurationDefaultAccount,
|
||||
configuration.DefaultTaxRule,
|
||||
configuration.Sequence,
|
||||
period.Period,
|
||||
journal.Journal,
|
||||
journal.JournalSequence,
|
||||
|
||||
+40
-1
@@ -3,7 +3,7 @@
|
||||
from trytond.pool import Pool
|
||||
from trytond.model import ModelView, ModelSQL, ModelSingleton, fields
|
||||
from trytond.transaction import Transaction
|
||||
from trytond.pyson import Eval
|
||||
from trytond.pyson import Eval, Id
|
||||
from trytond.modules.company.model import (
|
||||
CompanyMultiValueMixin, CompanyValueMixin)
|
||||
|
||||
@@ -47,6 +47,15 @@ class Configuration(
|
||||
help="Default supplier tax rule for new parties."))
|
||||
tax_rounding = fields.MultiValue(fields.Selection(
|
||||
tax_roundings, "Tax Rounding"))
|
||||
reconciliation_sequence = fields.MultiValue(fields.Many2One(
|
||||
'ir.sequence', "Reconciliation Sequence", required=True,
|
||||
domain=[
|
||||
('company', 'in',
|
||||
[Eval('context', {}).get('company', -1), None]),
|
||||
('sequence_type', '=',
|
||||
Id('account',
|
||||
'sequence_type_account_move_reconciliation')),
|
||||
]))
|
||||
|
||||
@classmethod
|
||||
def multivalue_model(cls, field):
|
||||
@@ -55,12 +64,19 @@ class Configuration(
|
||||
return pool.get('account.configuration.default_account')
|
||||
if field in {'default_customer_tax_rule', 'default_supplier_tax_rule'}:
|
||||
return pool.get('account.configuration.default_tax_rule')
|
||||
if field == 'reconciliation_sequence':
|
||||
return pool.get('account.configuration.sequence')
|
||||
return super(Configuration, cls).multivalue_model(field)
|
||||
|
||||
@classmethod
|
||||
def default_tax_rounding(cls, **pattern):
|
||||
return cls.multivalue_model('tax_rounding').default_tax_rounding()
|
||||
|
||||
@classmethod
|
||||
def default_reconciliation_sequence(cls, **pattern):
|
||||
return cls.multivalue_model(
|
||||
'reconciliation_sequence').default_reconciliation_sequence()
|
||||
|
||||
|
||||
class ConfigurationDefaultAccount(ModelSQL, CompanyValueMixin):
|
||||
"Account Configuration Default Account"
|
||||
@@ -131,3 +147,26 @@ class ConfigurationTaxRounding(ModelSQL, CompanyValueMixin):
|
||||
@classmethod
|
||||
def default_tax_rounding(cls):
|
||||
return 'document'
|
||||
|
||||
|
||||
class Sequence(ModelSQL, CompanyValueMixin):
|
||||
"Account Configuration Sequence"
|
||||
__name__ = 'account.configuration.sequence'
|
||||
reconciliation_sequence = fields.Many2One(
|
||||
'ir.sequence', "Reconciliation Sequence", required=True,
|
||||
domain=[
|
||||
('company', 'in', [Eval('company', -1), None]),
|
||||
('sequence_type', '=',
|
||||
Id('account', 'sequence_type_account_move_reconciliation')),
|
||||
],
|
||||
depends=['company'])
|
||||
|
||||
@classmethod
|
||||
def default_reconciliation_sequence(cls):
|
||||
pool = Pool()
|
||||
ModelData = pool.get('ir.model.data')
|
||||
try:
|
||||
return ModelData.get_id(
|
||||
'account', 'sequence_account_move_reconciliation')
|
||||
except KeyError:
|
||||
return None
|
||||
|
||||
+9
-12
@@ -7,7 +7,7 @@ from trytond.i18n import gettext
|
||||
from trytond.model import ModelView, ModelSQL, Workflow, fields
|
||||
from trytond.model.exceptions import AccessError
|
||||
from trytond.pool import Pool
|
||||
from trytond.pyson import Eval, If, PYSONEncoder
|
||||
from trytond.pyson import Eval, If, PYSONEncoder, Id
|
||||
from trytond.rpc import RPC
|
||||
from trytond.transaction import Transaction
|
||||
from trytond.wizard import (
|
||||
@@ -43,17 +43,14 @@ class FiscalYear(Workflow, ModelSQL, ModelView):
|
||||
('close', 'Close'),
|
||||
('locked', 'Locked'),
|
||||
], 'State', readonly=True, required=True)
|
||||
post_move_sequence = fields.Many2One('ir.sequence', 'Post Move Sequence',
|
||||
required=True, domain=[('code', '=', 'account.move'),
|
||||
['OR',
|
||||
('company', '=', Eval('company')),
|
||||
('company', '=', None)
|
||||
]],
|
||||
context={
|
||||
'code': 'account.move',
|
||||
'company': Eval('company'),
|
||||
},
|
||||
depends=['company'])
|
||||
post_move_sequence = fields.Many2One(
|
||||
'ir.sequence', "Post Move Sequence", required=True,
|
||||
domain=[
|
||||
('sequence_type', '=',
|
||||
Id('account', 'sequence_type_account_move')),
|
||||
('company', '=', Eval('company')),
|
||||
],
|
||||
depends=['company'])
|
||||
company = fields.Many2One('company.company', 'Company', required=True,
|
||||
domain=[
|
||||
('id', If(Eval('context', {}).contains('company'), '=', '!='),
|
||||
|
||||
+5
-3
@@ -9,7 +9,7 @@ from trytond.i18n import gettext
|
||||
from trytond.model import (
|
||||
ModelView, ModelSQL, Workflow, DeactivableMixin, fields, Unique)
|
||||
from trytond.model.exceptions import AccessError
|
||||
from trytond.pyson import Eval, Bool
|
||||
from trytond.pyson import Eval, Bool, Id
|
||||
from trytond.transaction import Transaction
|
||||
from trytond.pool import Pool
|
||||
from trytond.tools import reduce_ids, grouped_slice, lstrip_wildcard
|
||||
@@ -40,7 +40,8 @@ class Journal(
|
||||
sequence = fields.MultiValue(fields.Many2One(
|
||||
'ir.sequence', "Sequence",
|
||||
domain=[
|
||||
('code', '=', 'account.journal'),
|
||||
('sequence_type', '=',
|
||||
Id('account', 'sequence_type_account_journal')),
|
||||
('company', 'in', [
|
||||
Eval('context', {}).get('company', -1), None]),
|
||||
],
|
||||
@@ -162,7 +163,8 @@ class JournalSequence(ModelSQL, CompanyValueMixin):
|
||||
sequence = fields.Many2One(
|
||||
'ir.sequence', "Sequence",
|
||||
domain=[
|
||||
('code', '=', 'account.journal'),
|
||||
('sequence_type', '=',
|
||||
Id('account', 'sequence_type_account_journal')),
|
||||
('company', 'in', [Eval('company', -1), None]),
|
||||
],
|
||||
depends=['company'])
|
||||
|
||||
+1
-2
@@ -87,7 +87,6 @@ this repository contains the full copyright notices and license terms. -->
|
||||
</record>
|
||||
<record model="ir.sequence.type" id="sequence_type_account_journal">
|
||||
<field name="name">Account Journal</field>
|
||||
<field name="code">account.journal</field>
|
||||
</record>
|
||||
<record model="ir.sequence.type-res.group"
|
||||
id="sequence_type_account_journal_group_admin">
|
||||
@@ -102,7 +101,7 @@ this repository contains the full copyright notices and license terms. -->
|
||||
|
||||
<record model="ir.sequence" id="sequence_account_journal">
|
||||
<field name="name">Default Account Journal</field>
|
||||
<field name="code">account.journal</field>
|
||||
<field name="sequence_type" ref="sequence_type_account_journal"/>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="journal_period_view_form">
|
||||
|
||||
@@ -273,7 +273,6 @@ class Move(ModelSQL, ModelView):
|
||||
@classmethod
|
||||
def create(cls, vlist):
|
||||
pool = Pool()
|
||||
Sequence = pool.get('ir.sequence')
|
||||
Journal = pool.get('account.journal')
|
||||
|
||||
vlist = [x.copy() for x in vlist]
|
||||
@@ -284,7 +283,7 @@ class Move(ModelSQL, ModelView):
|
||||
if journal_id:
|
||||
journal = Journal(journal_id)
|
||||
if journal.sequence:
|
||||
vals['number'] = Sequence.get_id(journal.sequence.id)
|
||||
vals['number'] = journal.sequence.get()
|
||||
|
||||
moves = super(Move, cls).create(vlist)
|
||||
cls.validate_move(moves)
|
||||
@@ -413,7 +412,6 @@ class Move(ModelSQL, ModelView):
|
||||
@ModelView.button
|
||||
def post(cls, moves):
|
||||
pool = Pool()
|
||||
Sequence = pool.get('ir.sequence')
|
||||
Date = pool.get('ir.date')
|
||||
Line = pool.get('account.move.line')
|
||||
|
||||
@@ -435,8 +433,7 @@ class Move(ModelSQL, ModelView):
|
||||
move.state = 'posted'
|
||||
if not move.post_number:
|
||||
move.post_date = Date.today()
|
||||
move.post_number = Sequence.get_id(
|
||||
move.period.post_move_sequence_used.id)
|
||||
move.post_number = move.period.post_move_sequence_used.get()
|
||||
|
||||
def keyfunc(l):
|
||||
return l.party, l.account
|
||||
@@ -490,12 +487,14 @@ class Reconciliation(ModelSQL, ModelView):
|
||||
|
||||
@classmethod
|
||||
def create(cls, vlist):
|
||||
Sequence = Pool().get('ir.sequence')
|
||||
pool = Pool()
|
||||
Configuration = pool.get('account.configuration')
|
||||
configuration = Configuration(1)
|
||||
|
||||
vlist = [x.copy() for x in vlist]
|
||||
for vals in vlist:
|
||||
if 'name' not in vals:
|
||||
vals['name'] = Sequence.get('account.move.reconciliation')
|
||||
vals['name'] = configuration.reconciliation_sequence.get()
|
||||
|
||||
return super(Reconciliation, cls).create(vlist)
|
||||
|
||||
|
||||
@@ -69,7 +69,6 @@ this repository contains the full copyright notices and license terms. -->
|
||||
</record>
|
||||
<record model="ir.sequence.type" id="sequence_type_account_move">
|
||||
<field name="name">Account Move</field>
|
||||
<field name="code">account.move</field>
|
||||
</record>
|
||||
<record model="ir.sequence.type-res.group"
|
||||
id="sequence_type_account_move_group_admin">
|
||||
@@ -131,7 +130,6 @@ this repository contains the full copyright notices and license terms. -->
|
||||
</record>
|
||||
<record model="ir.sequence.type" id="sequence_type_account_move_reconciliation">
|
||||
<field name="name">Account Move Reconciliation</field>
|
||||
<field name="code">account.move.reconciliation</field>
|
||||
</record>
|
||||
<record model="ir.sequence.type-res.group"
|
||||
id="sequence_type_account_move_reconciliation_group_admin">
|
||||
@@ -146,7 +144,7 @@ this repository contains the full copyright notices and license terms. -->
|
||||
|
||||
<record model="ir.sequence" id="sequence_account_move_reconciliation">
|
||||
<field name="name">Default Account Move Reconciliation</field>
|
||||
<field name="code">account.move.reconciliation</field>
|
||||
<field name="sequence_type" ref="sequence_type_account_move_reconciliation"/>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="move_line_view_form">
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
from trytond.i18n import gettext
|
||||
from trytond.model import ModelView, ModelSQL, Workflow, fields
|
||||
from trytond.model.exceptions import AccessError
|
||||
from trytond.pyson import Eval
|
||||
from trytond.pyson import Eval, Id
|
||||
from trytond.transaction import Transaction
|
||||
from trytond.pool import Pool
|
||||
from trytond.const import OPERATORS
|
||||
@@ -37,7 +37,8 @@ class Period(Workflow, ModelSQL, ModelView):
|
||||
], 'State', readonly=True, required=True)
|
||||
post_move_sequence = fields.Many2One('ir.sequence', 'Post Move Sequence',
|
||||
domain=[
|
||||
('code', '=', 'account.move'),
|
||||
('sequence_type', '=',
|
||||
Id('account', 'sequence_type_account_move')),
|
||||
['OR',
|
||||
('company', '=', None),
|
||||
('company', '=', Eval('company', -1)),
|
||||
|
||||
@@ -82,7 +82,8 @@ Create Moves to reconcile::
|
||||
Create a write off method::
|
||||
|
||||
>>> Sequence = Model.get('ir.sequence')
|
||||
>>> sequence_journal, = Sequence.find([('code', '=', 'account.journal')])
|
||||
>>> sequence_journal, = Sequence.find(
|
||||
... [('sequence_type.name', '=', "Account Journal")], limit=1)
|
||||
>>> journal_writeoff = Journal(name='Write-Off', type='write-off',
|
||||
... sequence=sequence_journal)
|
||||
>>> journal_writeoff.save()
|
||||
|
||||
@@ -124,11 +124,12 @@ Create Moves for writeoff reconciliation::
|
||||
>>> move.save()
|
||||
>>> reconcile2, = [l for l in move.lines if l.account == receivable]
|
||||
|
||||
Create a writeof payment method::
|
||||
Create a write-off payment method::
|
||||
|
||||
|
||||
>>> Sequence = Model.get('ir.sequence')
|
||||
>>> sequence_journal, = Sequence.find([('code', '=', 'account.journal')])
|
||||
>>> sequence_journal, = Sequence.find(
|
||||
... [('sequence_type.name', '=', "Account Journal")], limit=1)
|
||||
>>> journal_writeoff = Journal(name='Write-Off', type='write-off',
|
||||
... sequence=sequence_journal)
|
||||
>>> journal_writeoff.save()
|
||||
@@ -140,7 +141,7 @@ Create a writeof payment method::
|
||||
>>> writeoff_method.credit_account = expense
|
||||
>>> writeoff_method.save()
|
||||
|
||||
Reconcile Lines with writeoff::
|
||||
Reconcile Lines with write-off::
|
||||
>>> reconcile_lines = Wizard('account.move.reconcile_lines',
|
||||
... [reconcile1, reconcile2])
|
||||
>>> reconcile_lines.form_state == 'writeoff'
|
||||
|
||||
@@ -86,6 +86,7 @@ def create_chart(company, tax=False, chart='account.account_template_root_en'):
|
||||
def get_fiscalyear(company, today=None, start_date=None, end_date=None):
|
||||
pool = Pool()
|
||||
Sequence = pool.get('ir.sequence')
|
||||
SequenceType = pool.get('ir.sequence.type')
|
||||
FiscalYear = pool.get('account.fiscalyear')
|
||||
|
||||
if not today:
|
||||
@@ -95,9 +96,12 @@ def get_fiscalyear(company, today=None, start_date=None, end_date=None):
|
||||
if not end_date:
|
||||
end_date = today.replace(month=12, day=31)
|
||||
|
||||
sequence_type, = SequenceType.search([
|
||||
('name', '=', "Account Move"),
|
||||
], limit=1)
|
||||
sequence, = Sequence.create([{
|
||||
'name': '%s' % today.year,
|
||||
'code': 'account.move',
|
||||
'sequence_type': sequence_type.id,
|
||||
'company': company.id,
|
||||
}])
|
||||
fiscalyear = FiscalYear(name='%s' % today.year, company=company)
|
||||
@@ -121,8 +125,8 @@ def close_fiscalyear(fiscalyear):
|
||||
|
||||
# Balance non-deferral
|
||||
journal_sequence, = Sequence.search([
|
||||
('code', '=', 'account.journal'),
|
||||
])
|
||||
('sequence_type.name', '=', "Account Journal"),
|
||||
], limit=1)
|
||||
journal_closing, = Journal.create([{
|
||||
'name': 'Closing',
|
||||
'code': 'CLO',
|
||||
|
||||
+6
-1
@@ -16,6 +16,7 @@ def create_fiscalyear(company=None, today=None, config=None):
|
||||
"Create a fiscal year for the company on today"
|
||||
FiscalYear = Model.get('account.fiscalyear', config=config)
|
||||
Sequence = Model.get('ir.sequence', config=config)
|
||||
SequenceType = Model.get('ir.sequence.type', config=config)
|
||||
|
||||
if not company:
|
||||
company = get_company()
|
||||
@@ -28,7 +29,11 @@ def create_fiscalyear(company=None, today=None, config=None):
|
||||
fiscalyear.end_date = today + relativedelta(month=12, day=31)
|
||||
fiscalyear.company = company
|
||||
|
||||
post_move_sequence = Sequence(name=str(today.year), code='account.move',
|
||||
sequence_type, = SequenceType.find(
|
||||
[('name', '=', "Account Move")], limit=1)
|
||||
post_move_sequence = Sequence(
|
||||
name=str(today.year),
|
||||
sequence_type=sequence_type,
|
||||
company=company)
|
||||
post_move_sequence.save()
|
||||
fiscalyear.post_move_sequence = post_move_sequence
|
||||
|
||||
@@ -14,4 +14,7 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<field name="default_supplier_tax_rule"/>
|
||||
<label name="tax_rounding"/>
|
||||
<field name="tax_rounding"/>
|
||||
<separator id="move" string="Move" colspan="4"/>
|
||||
<label name="reconciliation_sequence"/>
|
||||
<field name="reconciliation_sequence"/>
|
||||
</form>
|
||||
|
||||
Reference in New Issue
Block a user