Add field journal_sequences to fiscalyear

This commit is contained in:
jmartin 2014-11-07 17:55:51 +01:00
parent 595c107cc8
commit d772e5fd9d
4 changed files with 34 additions and 1 deletions

View file

@ -9,5 +9,6 @@ def register():
Pool.register(
AccountJournalInvoiceSequence,
Journal,
FiscalYear,
Invoice,
module='account_invoice_sequence', type_='model')

View file

@ -7,7 +7,7 @@ from trytond.pyson import Eval, If
from trytond.transaction import Transaction
__all__ = ['AccountJournalInvoiceSequence', 'Journal', 'Invoice']
__all__ = ['AccountJournalInvoiceSequence', 'Journal', 'FiscalYear', 'Invoice']
__metaclass__ = PoolMeta
@ -72,6 +72,20 @@ class Journal:
return getattr(sequence, invoice.type + '_sequence')
class FiscalYear:
__name__ = 'account.fiscalyear'
journal_sequences = fields.Function(fields.One2Many('ir.sequence.strict',
None, 'Journal Sequences'), 'get_journal_sequences')
def get_journal_sequences(self, name):
pool = Pool()
InvoiceSequences = pool.get('account.journal.invoice.sequence')
sequences = InvoiceSequences.search([('fiscalyear', '=', self.id)])
result = [s.out_invoice_sequence.id for s in sequences]
result.extend([s.out_credit_note_sequence.id for s in sequences])
return result
class Invoice:
__name__ = 'account.invoice'

View file

@ -16,6 +16,12 @@ copyright notices and license terms. -->
<field name="type">tree</field>
<field name="name">account_journal_invoice_sequence_list</field>
</record>
<!-- account.fiscalyear -->
<record model="ir.ui.view" id="fiscalyear_view_form">
<field name="model">account.fiscalyear</field>
<field name="inherit" ref="account.fiscalyear_view_form"/>
<field name="name">fiscalyear_form</field>
</record>
<!-- account.journal -->
<record model="ir.ui.view" id="journal_view_form">
<field name="model">account.journal</field>

12
view/fiscalyear_form.xml Normal file
View file

@ -0,0 +1,12 @@
<?xml version="1.0"?>
<!-- This file is part of the account_invoice_sequence module for Tryton.
The COPYRIGHT file at the top level of this repository contains the full
copyright notices and license terms. -->
<data>
<xpath
expr="/form/notebook/page[@id='sequences']/field[@name='in_credit_note_sequence']"
position="after">
<newline/>
<field name="journal_sequences" colspan="4"/>
</xpath>
</data>