Use sequence_ordered in configuration and account models
Missing from changeset ed566b41e37e
This commit is contained in:
1 parent
cc474f9357
commit
3949ae8d87
2 files changed
+6
-42
No files matched your search
+3
-26
@@ -9,7 +9,7 @@ from sql import Column, Null, Window, Literal
|
||||
from sql.aggregate import Sum, Max
|
||||
from sql.conditionals import Coalesce, Case
|
||||
|
||||
from trytond.model import ModelView, ModelSQL, fields, Unique
|
||||
from trytond.model import ModelView, ModelSQL, fields, Unique, sequence_ordered
|
||||
from trytond.wizard import Wizard, StateView, StateAction, StateTransition, \
|
||||
Button
|
||||
from trytond.report import Report
|
||||
@@ -38,7 +38,7 @@ def inactive_records(func):
|
||||
return wrapper
|
||||
|
||||
|
||||
class TypeTemplate(ModelSQL, ModelView):
|
||||
class TypeTemplate(sequence_ordered(), ModelSQL, ModelView):
|
||||
'Account Type Template'
|
||||
__name__ = 'account.account.type.template'
|
||||
name = fields.Char('Name', required=True)
|
||||
@@ -46,7 +46,6 @@ class TypeTemplate(ModelSQL, ModelView):
|
||||
ondelete="RESTRICT")
|
||||
childs = fields.One2Many('account.account.type.template', 'parent',
|
||||
'Children')
|
||||
sequence = fields.Integer('Sequence')
|
||||
balance_sheet = fields.Boolean('Balance Sheet')
|
||||
income_statement = fields.Boolean('Income Statement')
|
||||
display_balance = fields.Selection([
|
||||
@@ -54,11 +53,6 @@ class TypeTemplate(ModelSQL, ModelView):
|
||||
('credit-debit', 'Credit - Debit'),
|
||||
], 'Display Balance', required=True)
|
||||
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
super(TypeTemplate, cls).__setup__()
|
||||
cls._order.insert(0, ('sequence', 'ASC'))
|
||||
|
||||
@classmethod
|
||||
def __register__(cls, module_name):
|
||||
TableHandler = backend.get('TableHandler')
|
||||
@@ -74,11 +68,6 @@ class TypeTemplate(ModelSQL, ModelView):
|
||||
super(TypeTemplate, cls).validate(records)
|
||||
cls.check_recursion(records, rec_name='name')
|
||||
|
||||
@staticmethod
|
||||
def order_sequence(tables):
|
||||
table, _ = tables[None]
|
||||
return [Case((table.sequence == Null, 0), else_=1), table.sequence]
|
||||
|
||||
@staticmethod
|
||||
def default_balance_sheet():
|
||||
return False
|
||||
@@ -154,7 +143,7 @@ class TypeTemplate(ModelSQL, ModelView):
|
||||
childs = sum((c.childs for c in childs), ())
|
||||
|
||||
|
||||
class Type(ModelSQL, ModelView):
|
||||
class Type(sequence_ordered(), ModelSQL, ModelView):
|
||||
'Account Type'
|
||||
__name__ = 'account.account.type'
|
||||
name = fields.Char('Name', size=None, required=True)
|
||||
@@ -166,8 +155,6 @@ class Type(ModelSQL, ModelView):
|
||||
domain=[
|
||||
('company', '=', Eval('company')),
|
||||
], depends=['company'])
|
||||
sequence = fields.Integer('Sequence',
|
||||
help='Use to order the account type')
|
||||
currency_digits = fields.Function(fields.Integer('Currency Digits'),
|
||||
'get_currency_digits')
|
||||
amount = fields.Function(fields.Numeric('Amount',
|
||||
@@ -186,11 +173,6 @@ class Type(ModelSQL, ModelView):
|
||||
ondelete="RESTRICT")
|
||||
template = fields.Many2One('account.account.type.template', 'Template')
|
||||
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
super(Type, cls).__setup__()
|
||||
cls._order.insert(0, ('sequence', 'ASC'))
|
||||
|
||||
@classmethod
|
||||
def __register__(cls, module_name):
|
||||
TableHandler = backend.get('TableHandler')
|
||||
@@ -206,11 +188,6 @@ class Type(ModelSQL, ModelView):
|
||||
super(Type, cls).validate(types)
|
||||
cls.check_recursion(types, rec_name='name')
|
||||
|
||||
@staticmethod
|
||||
def order_sequence(tables):
|
||||
table, _ = tables[None]
|
||||
return [Case((table.sequence == Null, 0), else_=1), table.sequence]
|
||||
|
||||
@staticmethod
|
||||
def default_balance_sheet():
|
||||
return False
|
||||
|
||||
+3
-16
@@ -1,10 +1,7 @@
|
||||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
from sql import Null
|
||||
from sql.conditionals import Case
|
||||
|
||||
from trytond.model import (ModelView, ModelSQL,
|
||||
ModelSingleton, MatchMixin, fields)
|
||||
ModelSingleton, MatchMixin, fields, sequence_ordered)
|
||||
from trytond.pool import Pool
|
||||
from trytond.transaction import Transaction
|
||||
from trytond.pyson import Eval
|
||||
@@ -101,25 +98,15 @@ class Configuration(ModelSingleton, ModelSQL, ModelView):
|
||||
return self.default_tax_rounding()
|
||||
|
||||
|
||||
class ConfigurationTaxRounding(ModelSQL, ModelView, MatchMixin):
|
||||
class ConfigurationTaxRounding(
|
||||
sequence_ordered(), ModelSQL, ModelView, MatchMixin):
|
||||
'Account Configuration Tax Rounding'
|
||||
__name__ = 'account.configuration.tax_rounding'
|
||||
configuration = fields.Many2One('account.configuration', 'Configuration',
|
||||
required=True, ondelete='CASCADE')
|
||||
sequence = fields.Integer('Sequence')
|
||||
company = fields.Many2One('company.company', 'Company')
|
||||
method = fields.Selection(tax_roundings, 'Method', required=True)
|
||||
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
super(ConfigurationTaxRounding, cls).__setup__()
|
||||
cls._order.insert(0, ('sequence', 'ASC'))
|
||||
|
||||
@classmethod
|
||||
def order_sequence(cls, tables):
|
||||
table, _ = tables[None]
|
||||
return [Case((table.sequence == Null, 0), else_=1), table.sequence]
|
||||
|
||||
@classmethod
|
||||
def default_method(cls):
|
||||
return 'document'
|
||||
Reference in new issue
Block a user