changeset 9f2ff3162e1d in modules/production:default
details: 
https://hg.tryton.org/modules/production?cmd=changeset;node=9f2ff3162e1d
description:
        Default to ordering documents by date

        issue10079
        review339831002
diffstat:

 CHANGELOG     |   2 ++
 production.py |  12 ++++++++++++
 2 files changed, 14 insertions(+), 0 deletions(-)

diffs (45 lines):

diff -r d6d6c9b8e0bc -r 9f2ff3162e1d CHANGELOG
--- a/CHANGELOG Tue Feb 09 00:32:17 2021 +0100
+++ b/CHANGELOG Thu Feb 25 21:13:56 2021 +0100
@@ -1,3 +1,5 @@
+* Default to ordering productions by date
+
 Version 5.8.0 - 2020-11-02
 * Bug fixes (see mercurial logs for details)
 * Remove support for Python 3.5
diff -r d6d6c9b8e0bc -r 9f2ff3162e1d production.py
--- a/production.py     Tue Feb 09 00:32:17 2021 +0100
+++ b/production.py     Thu Feb 25 21:13:56 2021 +0100
@@ -6,6 +6,7 @@
 from itertools import chain
 
 from sql import Null
+from sql.conditionals import Coalesce
 
 from trytond.model import ModelView, ModelSQL, Workflow, fields, dualmethod
 from trytond.pyson import Eval, Bool, If
@@ -166,6 +167,10 @@
     @classmethod
     def __setup__(cls):
         super(Production, cls).__setup__()
+        cls._order = [
+            ('effective_date', 'ASC NULLS LAST'),
+            ('id', 'ASC'),
+            ]
         cls._transitions |= set((
                 ('request', 'draft'),
                 ('draft', 'waiting'),
@@ -274,6 +279,13 @@
                 [table.state], ['cancelled'],
                 where=table.state == 'cancel'))
 
+    @classmethod
+    def order_effective_date(cls, tables):
+        table, _ = tables[None]
+        return [Coalesce(
+                table.effective_start_date, table.effective_date,
+                table.planned_start_date, table.planned_date)]
+
     @staticmethod
     def default_state():
         return 'draft'

Reply via email to