diff --git a/account.py b/account.py
index d9717fe2f3..4a0fba2371 100644
--- a/account.py
+++ b/account.py
@@ -10,7 +10,8 @@ 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, sequence_ordered
+from trytond.model import (
+ ModelView, ModelSQL, DeactivableMixin, fields, Unique, sequence_ordered)
from trytond.wizard import Wizard, StateView, StateAction, StateTransition, \
Button
from trytond.report import Report
@@ -588,17 +589,15 @@ class AccountTemplateTaxTemplate(ModelSQL):
ondelete='RESTRICT', select=True, required=True)
-class Account(ModelSQL, ModelView):
+class Account(DeactivableMixin, ModelSQL, ModelView):
'Account'
__name__ = 'account.account'
-
_states = {
'readonly': (Bool(Eval('template', -1)) &
~Eval('template_override', False)),
}
name = fields.Char('Name', required=True, select=True, states=_states)
code = fields.Char('Code', select=True, states=_states)
- active = fields.Boolean('Active', select=True)
company = fields.Many2One('company.company', 'Company', required=True,
ondelete="RESTRICT")
currency = fields.Function(fields.Many2One('currency.currency',
@@ -1272,14 +1271,13 @@ class OpenChartAccount(Wizard):
return 'end'
-class GeneralLedgerAccount(ModelSQL, ModelView):
+class GeneralLedgerAccount(DeactivableMixin, ModelSQL, ModelView):
'General Ledger Account'
__name__ = 'account.general_ledger.account'
# TODO reuse rec_name of Account
name = fields.Char('Name')
code = fields.Char('Code')
- active = fields.Boolean('Active')
company = fields.Many2One('company.company', 'Company')
type = fields.Many2One('account.account.type', 'Type')
start_debit = fields.Function(fields.Numeric('Start Debit',
diff --git a/journal.py b/journal.py
index f5ee56714c..89593e8154 100644
--- a/journal.py
+++ b/journal.py
@@ -5,7 +5,8 @@ from decimal import Decimal
from sql import Null
from sql.aggregate import Sum
-from trytond.model import ModelView, ModelSQL, Workflow, fields, Unique
+from trytond.model import (
+ ModelView, ModelSQL, Workflow, DeactivableMixin, fields, Unique)
from trytond import backend
from trytond.pyson import Eval, Bool
from trytond.transaction import Transaction
@@ -41,12 +42,12 @@ class JournalType(ModelSQL, ModelView):
cls._order.insert(0, ('code', 'ASC'))
-class Journal(ModelSQL, ModelView, CompanyMultiValueMixin):
+class Journal(
+ DeactivableMixin, ModelSQL, ModelView, CompanyMultiValueMixin):
'Journal'
__name__ = 'account.journal'
name = fields.Char('Name', size=None, required=True, translate=True)
code = fields.Char('Code', size=None)
- active = fields.Boolean('Active', select=True)
type = fields.Selection('get_types', 'Type', required=True)
sequence = fields.MultiValue(fields.Many2One(
'ir.sequence', "Sequence",
@@ -131,10 +132,6 @@ class Journal(ModelSQL, ModelView, CompanyMultiValueMixin):
return pool.get('account.journal.account')
return super(Journal, cls).multivalue_model(field)
- @staticmethod
- def default_active():
- return True
-
@classmethod
def default_sequence(cls, **pattern):
return None
@@ -306,7 +303,8 @@ class JournalCashContext(ModelView):
default_end_date = default_start_date
-class JournalPeriod(Workflow, ModelSQL, ModelView):
+class JournalPeriod(
+ DeactivableMixin, Workflow, ModelSQL, ModelView):
'Journal - Period'
__name__ = 'account.journal.period'
journal = fields.Many2One('account.journal', 'Journal', required=True,
@@ -314,8 +312,6 @@ class JournalPeriod(Workflow, ModelSQL, ModelView):
period = fields.Many2One('account.period', 'Period', required=True,
ondelete='CASCADE', states=STATES, depends=DEPENDS)
icon = fields.Function(fields.Char('Icon'), 'get_icon')
- active = fields.Boolean('Active', select=True, states=STATES,
- depends=DEPENDS)
state = fields.Selection([
('open', 'Open'),
('close', 'Close'),
@@ -353,6 +349,8 @@ class JournalPeriod(Workflow, ModelSQL, ModelView):
'depends': ['state'],
},
})
+ cls.active.states = STATES
+ cls.active.depends = DEPENDS
@classmethod
def __register__(cls, module_name):
@@ -364,10 +362,6 @@ class JournalPeriod(Workflow, ModelSQL, ModelView):
# Migration from 4.2: remove name column
table.drop_column('name')
- @staticmethod
- def default_active():
- return True
-
@staticmethod
def default_state():
return 'open'
diff --git a/move_template.py b/move_template.py
index b6a4728a5b..a211f09c1f 100644
--- a/move_template.py
+++ b/move_template.py
@@ -6,7 +6,8 @@ from decimal import Decimal
from simpleeval import simple_eval
from trytond import backend
-from trytond.model import ModelSQL, ModelView, fields, sequence_ordered
+from trytond.model import (
+ ModelSQL, ModelView, DeactivableMixin, fields, sequence_ordered)
from trytond.pyson import Eval
from trytond.wizard import (Wizard, StateView, StateAction, StateTransition,
Button)
@@ -19,7 +20,7 @@ __all__ = ['MoveTemplate', 'MoveTemplateKeyword',
'CreateMove', 'CreateMoveTemplate', 'CreateMoveKeywords']
-class MoveTemplate(ModelSQL, ModelView):
+class MoveTemplate(DeactivableMixin, ModelSQL, ModelView):
'Account Move Template'
__name__ = 'account.move.template'
name = fields.Char('Name', required=True, translate=True)
@@ -36,16 +37,11 @@ class MoveTemplate(ModelSQL, ModelView):
('account.company', '=', Eval('company', -1)),
],
depends=['company'])
- active = fields.Boolean('Active')
@staticmethod
def default_company():
return Transaction().context.get('company')
- @staticmethod
- def default_active():
- return True
-
def get_move(self, values):
'Return the move for the keyword values'
pool = Pool()
diff --git a/tax.py b/tax.py
index e33e4e5cc4..f1e0ef3329 100644
--- a/tax.py
+++ b/tax.py
@@ -9,8 +9,9 @@ from sql import Literal, Cast
from sql.aggregate import Sum
from sql.conditionals import Case
-from trytond.model import ModelView, ModelSQL, MatchMixin, fields, \
- sequence_ordered
+from trytond.model import (
+ ModelView, ModelSQL, MatchMixin, DeactivableMixin, fields,
+ sequence_ordered)
from trytond.wizard import Wizard, StateView, StateAction, Button
from trytond import backend
from trytond.pyson import Eval, If, Bool, PYSONEncoder
@@ -133,7 +134,7 @@ class TaxCodeTemplate(ModelSQL, ModelView):
childs = sum((c.childs for c in childs), ())
-class TaxCode(ModelSQL, ModelView):
+class TaxCode(DeactivableMixin, ModelSQL, ModelView):
'Tax Code'
__name__ = 'account.tax.code'
_states = {
@@ -142,7 +143,6 @@ class TaxCode(ModelSQL, ModelView):
}
name = fields.Char('Name', required=True, select=True, states=_states)
code = fields.Char('Code', select=True, states=_states)
- active = fields.Boolean('Active', select=True)
company = fields.Many2One('company.company', 'Company', required=True,
select=True)
parent = fields.Many2One('account.tax.code', 'Parent', select=True,
@@ -178,10 +178,6 @@ class TaxCode(ModelSQL, ModelView):
super(TaxCode, cls).validate(codes)
cls.check_recursion(codes)
- @staticmethod
- def default_active():
- return True
-
@staticmethod
def default_company():
return Transaction().context.get('company')
@@ -647,7 +643,7 @@ class TaxTemplate(sequence_ordered(), ModelSQL, ModelView):
childs = sum((c.childs for c in childs), ())
-class Tax(sequence_ordered(), ModelSQL, ModelView):
+class Tax(sequence_ordered(), ModelSQL, ModelView, DeactivableMixin):
'''
Account Tax
@@ -669,7 +665,6 @@ class Tax(sequence_ordered(), ModelSQL, ModelView):
'invisible': Bool(Eval('parent')),
'readonly': _states['readonly'],
}, depends=['parent'])
- active = fields.Boolean('Active')
start_date = fields.Date('Starting Date', states=_states)
end_date = fields.Date('Ending Date', states=_states)
amount = fields.Numeric('Amount', digits=(16, 8),
@@ -802,10 +797,6 @@ class Tax(sequence_ordered(), ModelSQL, ModelView):
'tax': self.rec_name,
})
- @staticmethod
- def default_active():
- return True
-
@staticmethod
def default_type():
return 'percentage'
diff --git a/view/account_list.xml b/view/account_list.xml
index 4fe4069d75..6884d1da7a 100644
--- a/view/account_list.xml
+++ b/view/account_list.xml
@@ -5,5 +5,4 @@ this repository contains the full copyright notices and license terms. -->
-
diff --git a/view/account_tree.xml b/view/account_tree.xml
index ad3147a75e..67d3fdf008 100644
--- a/view/account_tree.xml
+++ b/view/account_tree.xml
@@ -7,5 +7,4 @@ this repository contains the full copyright notices and license terms. -->
-
diff --git a/view/journal_period_tree.xml b/view/journal_period_tree.xml
index f15c2203d7..8608fd1700 100644
--- a/view/journal_period_tree.xml
+++ b/view/journal_period_tree.xml
@@ -5,5 +5,4 @@ this repository contains the full copyright notices and license terms. -->
-
diff --git a/view/journal_tree.xml b/view/journal_tree.xml
index 47cb4168bd..881d3eff3d 100644
--- a/view/journal_tree.xml
+++ b/view/journal_tree.xml
@@ -5,5 +5,4 @@ this repository contains the full copyright notices and license terms. -->
-
diff --git a/view/move_template_list.xml b/view/move_template_list.xml
index d4b1161349..c4a7efd3e8 100644
--- a/view/move_template_list.xml
+++ b/view/move_template_list.xml
@@ -3,5 +3,4 @@
this repository contains the full copyright notices and license terms. -->
-
diff --git a/view/tax_code_list.xml b/view/tax_code_list.xml
index a695397da4..cd3aed2b09 100644
--- a/view/tax_code_list.xml
+++ b/view/tax_code_list.xml
@@ -5,5 +5,4 @@ this repository contains the full copyright notices and license terms. -->
-
diff --git a/view/tax_code_tree.xml b/view/tax_code_tree.xml
index f1c0a2ceb0..443b72dc8e 100644
--- a/view/tax_code_tree.xml
+++ b/view/tax_code_tree.xml
@@ -5,7 +5,6 @@ this repository contains the full copyright notices and license terms. -->
-
diff --git a/view/tax_list.xml b/view/tax_list.xml
index eed55d9c7e..a45303229d 100644
--- a/view/tax_list.xml
+++ b/view/tax_list.xml
@@ -5,5 +5,4 @@ this repository contains the full copyright notices and license terms. -->
-