Use sequence_ordered
issue5105
This commit is contained in:
+7
-20
@@ -11,7 +11,8 @@ from sql.aggregate import Count, Sum
|
||||
from sql.conditionals import Coalesce, Case
|
||||
from sql.functions import Round
|
||||
|
||||
from trytond.model import Workflow, ModelView, ModelSQL, fields, Check
|
||||
from trytond.model import Workflow, ModelView, ModelSQL, fields, Check, \
|
||||
sequence_ordered
|
||||
from trytond.report import Report
|
||||
from trytond.wizard import Wizard, StateView, StateTransition, StateAction, \
|
||||
StateReport, Button
|
||||
@@ -1365,7 +1366,7 @@ class InvoicePaymentLine(ModelSQL):
|
||||
ondelete='CASCADE', select=True, required=True)
|
||||
|
||||
|
||||
class InvoiceLine(ModelSQL, ModelView, TaxableMixin):
|
||||
class InvoiceLine(sequence_ordered(), ModelSQL, ModelView, TaxableMixin):
|
||||
'Invoice Line'
|
||||
__name__ = 'account.invoice.line'
|
||||
_rec_name = 'description'
|
||||
@@ -1412,10 +1413,6 @@ class InvoiceLine(ModelSQL, ModelView, TaxableMixin):
|
||||
('id', If(Eval('context', {}).contains('company'), '=', '!='),
|
||||
Eval('context', {}).get('company', -1)),
|
||||
], select=True, states=_states, depends=_depends)
|
||||
sequence = fields.Integer('Sequence',
|
||||
states={
|
||||
'invisible': Bool(Eval('context', {}).get('standalone')),
|
||||
})
|
||||
type = fields.Selection([
|
||||
('line', 'Line'),
|
||||
('subtotal', 'Subtotal'),
|
||||
@@ -1524,7 +1521,6 @@ class InvoiceLine(ModelSQL, ModelView, TaxableMixin):
|
||||
| (t.type == 'line')),
|
||||
'Line without "line" type must have an invoice.'),
|
||||
]
|
||||
cls._order.insert(0, ('sequence', 'ASC'))
|
||||
cls._error_messages.update({
|
||||
'modify': ('You can not modify line "%(line)s" from invoice '
|
||||
'"%(invoice)s" that is posted or paid.'),
|
||||
@@ -1557,6 +1553,9 @@ class InvoiceLine(ModelSQL, ModelView, TaxableMixin):
|
||||
+ cls._account_domain('in'))))),
|
||||
]
|
||||
cls.account.depends += ['company', 'invoice_type']
|
||||
cls.sequence.states.update({
|
||||
'invisible': Bool(Eval('context', {}).get('standalone')),
|
||||
})
|
||||
|
||||
@staticmethod
|
||||
def _account_domain(type_):
|
||||
@@ -1591,11 +1590,6 @@ class InvoiceLine(ModelSQL, ModelView, TaxableMixin):
|
||||
cursor.execute(*sql_table.update([sql_table.company], [company_id],
|
||||
where=sql_table.id == line_id))
|
||||
|
||||
@staticmethod
|
||||
def order_sequence(tables):
|
||||
table, _ = tables[None]
|
||||
return [Case((table.sequence == Null, 0), else_=1), table.sequence]
|
||||
|
||||
@staticmethod
|
||||
def default_currency():
|
||||
Company = Pool().get('company.company')
|
||||
@@ -2002,7 +1996,7 @@ class InvoiceLineTax(ModelSQL):
|
||||
required=True)
|
||||
|
||||
|
||||
class InvoiceTax(ModelSQL, ModelView):
|
||||
class InvoiceTax(sequence_ordered(), ModelSQL, ModelView):
|
||||
'Invoice Tax'
|
||||
__name__ = 'account.invoice.tax'
|
||||
_rec_name = 'description'
|
||||
@@ -2021,7 +2015,6 @@ class InvoiceTax(ModelSQL, ModelView):
|
||||
'on_change_with_invoice_state')
|
||||
description = fields.Char('Description', size=None, required=True,
|
||||
states=_states, depends=_depends)
|
||||
sequence = fields.Integer('Sequence')
|
||||
sequence_number = fields.Function(fields.Integer('Sequence Number'),
|
||||
'get_sequence_number')
|
||||
account = fields.Many2One('account.account', 'Account', required=True,
|
||||
@@ -2067,7 +2060,6 @@ class InvoiceTax(ModelSQL, ModelView):
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
super(InvoiceTax, cls).__setup__()
|
||||
cls._order.insert(0, ('sequence', 'ASC'))
|
||||
cls._error_messages.update({
|
||||
'modify': ('You can not modify tax "%(tax)s" from invoice '
|
||||
'"%(invoice)s" because it is posted or paid.'),
|
||||
@@ -2093,11 +2085,6 @@ class InvoiceTax(ModelSQL, ModelView):
|
||||
# Migration from 2.4: drop required on sequence
|
||||
table.not_null_action('sequence', action='remove')
|
||||
|
||||
@staticmethod
|
||||
def order_sequence(tables):
|
||||
table, _ = tables[None]
|
||||
return [Case((table.sequence == Null, 0), else_=1), table.sequence]
|
||||
|
||||
@staticmethod
|
||||
def default_base():
|
||||
return Decimal('0.0')
|
||||
|
||||
+4
-24
@@ -3,10 +3,9 @@
|
||||
from decimal import Decimal
|
||||
from dateutil.relativedelta import relativedelta
|
||||
|
||||
from sql import Null, Column
|
||||
from sql.conditionals import Case
|
||||
from sql import Column
|
||||
|
||||
from trytond.model import ModelView, ModelSQL, fields
|
||||
from trytond.model import ModelView, ModelSQL, fields, sequence_ordered
|
||||
from trytond import backend
|
||||
from trytond.pyson import Eval
|
||||
from trytond.transaction import Transaction
|
||||
@@ -98,11 +97,9 @@ class PaymentTerm(ModelSQL, ModelView):
|
||||
return res
|
||||
|
||||
|
||||
class PaymentTermLine(ModelSQL, ModelView):
|
||||
class PaymentTermLine(sequence_ordered(), ModelSQL, ModelView):
|
||||
'Payment Term Line'
|
||||
__name__ = 'account.invoice.payment_term.line'
|
||||
sequence = fields.Integer('Sequence',
|
||||
help='Use to order lines in ascending order')
|
||||
payment = fields.Many2One('account.invoice.payment_term', 'Payment Term',
|
||||
required=True, ondelete="CASCADE")
|
||||
type = fields.Selection([
|
||||
@@ -139,7 +136,6 @@ class PaymentTermLine(ModelSQL, ModelView):
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
super(PaymentTermLine, cls).__setup__()
|
||||
cls._order.insert(0, ('sequence', 'ASC'))
|
||||
cls._error_messages.update({
|
||||
'invalid_ratio_and_divisor': ('Ratio and '
|
||||
'Divisor values are not consistent in line "%(line)s" '
|
||||
@@ -186,11 +182,6 @@ class PaymentTermLine(ModelSQL, ModelView):
|
||||
values=[sql_table.percentage / 100]))
|
||||
table.drop_column('percentage')
|
||||
|
||||
@staticmethod
|
||||
def order_sequence(tables):
|
||||
table, _ = tables[None]
|
||||
return [Case((table.sequence == Null, 0), else_=1), table.sequence]
|
||||
|
||||
@staticmethod
|
||||
def default_currency_digits():
|
||||
return 2
|
||||
@@ -291,10 +282,9 @@ class PaymentTermLine(ModelSQL, ModelView):
|
||||
})
|
||||
|
||||
|
||||
class PaymentTermLineRelativeDelta(ModelSQL, ModelView):
|
||||
class PaymentTermLineRelativeDelta(sequence_ordered(), ModelSQL, ModelView):
|
||||
'Payment Term Line Relative Delta'
|
||||
__name__ = 'account.invoice.payment_term.line.delta'
|
||||
sequence = fields.Integer('Sequence')
|
||||
line = fields.Many2One('account.invoice.payment_term.line',
|
||||
'Payment Term Line', required=True, ondelete='CASCADE')
|
||||
day = fields.Integer('Day of Month',
|
||||
@@ -331,11 +321,6 @@ class PaymentTermLineRelativeDelta(ModelSQL, ModelView):
|
||||
weeks = fields.Integer('Number of Weeks', required=True)
|
||||
days = fields.Integer('Number of Days', required=True)
|
||||
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
super(PaymentTermLineRelativeDelta, cls).__setup__()
|
||||
cls._order.insert(0, ('sequence', 'ASC'))
|
||||
|
||||
@classmethod
|
||||
def __register__(cls, module_name):
|
||||
TableHandler = backend.get('TableHandler')
|
||||
@@ -368,11 +353,6 @@ class PaymentTermLineRelativeDelta(ModelSQL, ModelView):
|
||||
for field in fields:
|
||||
line_table.drop_column(field, exception=True)
|
||||
|
||||
@staticmethod
|
||||
def order_sequence(tables):
|
||||
table, _ = tables[None]
|
||||
return [Case((table.sequence == Null, 0), else_=1), table.sequence]
|
||||
|
||||
@staticmethod
|
||||
def default_months():
|
||||
return 0
|
||||
|
||||
Reference in New Issue
Block a user