Store directly sequence type to sequence
issue10122 review351381002
This commit is contained in:
1 parent
e9d9721435
commit
6d5d2470da
8 files changed
+32
-29
No files matched your search
+13
-21
@@ -8,7 +8,7 @@ from sql.conditionals import Coalesce
|
||||
from trytond.i18n import gettext
|
||||
from trytond.model import (fields, ModelView, ModelSQL, Workflow, MatchMixin,
|
||||
sequence_ordered)
|
||||
from trytond.pyson import Eval, If, Bool
|
||||
from trytond.pyson import Eval, If, Bool, Id
|
||||
from trytond.pool import Pool, PoolMeta
|
||||
from trytond.tools import grouped_slice
|
||||
from trytond.transaction import Transaction
|
||||
@@ -179,41 +179,33 @@ class InvoiceSequence(sequence_ordered(), ModelSQL, ModelView, MatchMixin):
|
||||
in_invoice_sequence = fields.Many2One('ir.sequence.strict',
|
||||
'Supplier Invoice Sequence', required=True,
|
||||
domain=[
|
||||
('code', '=', 'account.invoice'),
|
||||
['OR',
|
||||
('company', '=', Eval('company')),
|
||||
('company', '=', None),
|
||||
],
|
||||
('sequence_type', '=',
|
||||
Id('account_invoice', 'sequence_type_account_invoice')),
|
||||
('company', '=', Eval('company')),
|
||||
],
|
||||
depends=['company'])
|
||||
in_credit_note_sequence = fields.Many2One('ir.sequence.strict',
|
||||
'Supplier Credit Note Sequence', required=True,
|
||||
domain=[
|
||||
('code', '=', 'account.invoice'),
|
||||
['OR',
|
||||
('company', '=', Eval('company')),
|
||||
('company', '=', None),
|
||||
],
|
||||
('sequence_type', '=',
|
||||
Id('account_invoice', 'sequence_type_account_invoice')),
|
||||
('company', '=', Eval('company')),
|
||||
],
|
||||
depends=['company'])
|
||||
out_invoice_sequence = fields.Many2One('ir.sequence.strict',
|
||||
'Customer Invoice Sequence', required=True,
|
||||
domain=[
|
||||
('code', '=', 'account.invoice'),
|
||||
['OR',
|
||||
('company', '=', Eval('company')),
|
||||
('company', '=', None),
|
||||
],
|
||||
('sequence_type', '=',
|
||||
Id('account_invoice', 'sequence_type_account_invoice')),
|
||||
('company', '=', Eval('company')),
|
||||
],
|
||||
depends=['company'])
|
||||
out_credit_note_sequence = fields.Many2One('ir.sequence.strict',
|
||||
'Customer Credit Note Sequence', required=True,
|
||||
domain=[
|
||||
('code', '=', 'account.invoice'),
|
||||
['OR',
|
||||
('company', '=', Eval('company')),
|
||||
('company', '=', None),
|
||||
],
|
||||
('sequence_type', '=',
|
||||
Id('account_invoice', 'sequence_type_account_invoice')),
|
||||
('company', '=', Eval('company')),
|
||||
],
|
||||
depends=['company'])
|
||||
|
||||
|
||||
+1
-2
@@ -1084,7 +1084,6 @@ class Invoice(Workflow, ModelSQL, ModelView, TaxableMixin):
|
||||
def get_next_number(self, pattern=None):
|
||||
"Return invoice number and sequence id used"
|
||||
pool = Pool()
|
||||
Sequence = pool.get('ir.sequence.strict')
|
||||
Period = pool.get('account.period')
|
||||
|
||||
if pattern is None:
|
||||
@@ -1114,7 +1113,7 @@ class Invoice(Workflow, ModelSQL, ModelView, TaxableMixin):
|
||||
invoice=self.rec_name,
|
||||
fiscalyear=fiscalyear.rec_name))
|
||||
with Transaction().set_context(date=accounting_date):
|
||||
return Sequence.get_id(sequence.id), sequence.id
|
||||
return sequence.get(), sequence.id
|
||||
|
||||
@property
|
||||
def _sequence_field(self):
|
||||
|
||||
@@ -230,7 +230,6 @@ this repository contains the full copyright notices and license terms. -->
|
||||
|
||||
<record model="ir.sequence.type" id="sequence_type_account_invoice">
|
||||
<field name="name">Invoice</field>
|
||||
<field name="code">account.invoice</field>
|
||||
</record>
|
||||
<record model="ir.sequence.type-res.group"
|
||||
id="sequence_type_account_invoice_group_admin">
|
||||
|
||||
@@ -78,7 +78,8 @@ Create payment method::
|
||||
Create Write Off method::
|
||||
|
||||
>>> WriteOff = Model.get('account.move.reconcile.write_off')
|
||||
>>> 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()
|
||||
|
||||
@@ -80,7 +80,8 @@ Create payment method::
|
||||
Create writeoff method::
|
||||
|
||||
>>> WriteOff = Model.get('account.move.reconcile.write_off')
|
||||
>>> sequence_journal, = Sequence.find([('code', '=', 'account.journal')])
|
||||
>>> sequence_journal, = Sequence.find(
|
||||
... [('sequence_type.name', '=', "Account Journal")])
|
||||
>>> journal_writeoff = Journal(name='Write-Off', type='write-off',
|
||||
... sequence=sequence_journal)
|
||||
>>> journal_writeoff.save()
|
||||
|
||||
@@ -51,7 +51,8 @@ Create payment method::
|
||||
Create write-off method::
|
||||
|
||||
>>> WriteOff = Model.get('account.move.reconcile.write_off')
|
||||
>>> 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()
|
||||
|
||||
@@ -20,9 +20,13 @@ from ..exceptions import PaymentTermValidationError
|
||||
def set_invoice_sequences(fiscalyear):
|
||||
pool = Pool()
|
||||
Sequence = pool.get('ir.sequence.strict')
|
||||
SequenceType = pool.get('ir.sequence.type')
|
||||
InvoiceSequence = pool.get('account.fiscalyear.invoice_sequence')
|
||||
|
||||
sequence = Sequence(name=fiscalyear.name, code='account.invoice')
|
||||
sequence_type, = SequenceType.search([
|
||||
('name', '=', "Invoice"),
|
||||
], limit=1)
|
||||
sequence = Sequence(name=fiscalyear.name, sequence_type=sequence_type)
|
||||
sequence.company = fiscalyear.company
|
||||
sequence.save()
|
||||
fiscalyear.invoice_sequences = []
|
||||
|
||||
+7
-1
@@ -8,8 +8,14 @@ __all__ = ['set_fiscalyear_invoice_sequences']
|
||||
def set_fiscalyear_invoice_sequences(fiscalyear, config=None):
|
||||
"Set invoice sequences to fiscalyear"
|
||||
SequenceStrict = Model.get('ir.sequence.strict', config=config)
|
||||
SequenceType = Model.get('ir.sequence.type', config=config)
|
||||
|
||||
invoice_seq = SequenceStrict(name=fiscalyear.name, code='account.invoice',
|
||||
sequence_type, = SequenceType.find([
|
||||
('name', '=', "Invoice"),
|
||||
], limit=1)
|
||||
invoice_seq = SequenceStrict(
|
||||
name=fiscalyear.name,
|
||||
sequence_type=sequence_type,
|
||||
company=fiscalyear.company)
|
||||
invoice_seq.save()
|
||||
seq, = fiscalyear.invoice_sequences
|
||||
|
||||
Reference in new issue
Block a user