changeset c6a5f2f36624 in modules/sale:default
details: https://hg.tryton.org/modules/sale?cmd=changeset;node=c6a5f2f36624
description:
        Add default order on reporting

        issue9693
        review312501002
diffstat:

 sale_reporting.py  |  43 +++++++++++++++++++++++++++++++++++++++++++
 sale_reporting.xml |   5 +++++
 2 files changed, 48 insertions(+), 0 deletions(-)

diffs (138 lines):

diff -r 01df1c4401a8 -r c6a5f2f36624 sale_reporting.py
--- a/sale_reporting.py Fri Oct 09 19:09:05 2020 +0200
+++ b/sale_reporting.py Mon Oct 12 17:48:33 2020 +0200
@@ -298,6 +298,11 @@
         'sale.reporting.customer.time_series', 'customer', "Time Series")
 
     @classmethod
+    def __setup__(cls):
+        super().__setup__()
+        cls._order.insert(0, ('customer', 'ASC'))
+
+    @classmethod
     def _column_id(cls, tables):
         sale = tables['line.sale']
         return sale.party
@@ -342,6 +347,11 @@
         'sale.reporting.product.time_series', 'product', "Time Series")
 
     @classmethod
+    def __setup__(cls):
+        super().__setup__()
+        cls._order.insert(0, ('product', 'ASC'))
+
+    @classmethod
     def _column_id(cls, tables):
         line = tables['line']
         return line.product
@@ -421,6 +431,11 @@
         'sale.reporting.category.time_series', 'category', "Time Series")
 
     @classmethod
+    def __setup__(cls):
+        super().__setup__()
+        cls._order.insert(0, ('category', 'ASC'))
+
+    @classmethod
     def _column_id(cls, tables):
         template_category = tables['line.product.template_category']
         return template_category.category
@@ -447,6 +462,11 @@
         fields.Integer("Currency Digits"), 'get_currency_digits')
 
     @classmethod
+    def __setup__(cls):
+        super().__setup__()
+        cls._order.insert(0, ('name', 'ASC'))
+
+    @classmethod
     def table_query(cls):
         pool = Pool()
         Category = pool.get('product.category')
@@ -459,6 +479,19 @@
         categories = Category.browse(categories)
         return {c.id: c.name for c in categories}
 
+    @classmethod
+    def order_name(cls, tables):
+        pool = Pool()
+        Category = pool.get('product.category')
+        table, _ = tables[None]
+        if 'category' not in tables:
+            category = Category.__table__()
+            tables['category'] = {
+                None: (category, table.id == category.id),
+                }
+        return Category.name.convert_order(
+                'name', tables['category'], Category)
+
     def time_series_all(self):
         return []
 
@@ -569,6 +602,11 @@
         'sale.reporting.country.time_series', 'country', "Time Series")
 
     @classmethod
+    def __setup__(cls):
+        super().__setup__()
+        cls._order.insert(0, ('country', 'ASC'))
+
+    @classmethod
     def _column_id(cls, tables):
         address = tables['line.sale.shipment_address']
         return address.country
@@ -615,6 +653,11 @@
         "Time Series")
 
     @classmethod
+    def __setup__(cls):
+        super().__setup__()
+        cls._order.insert(0, ('subdivision', 'ASC'))
+
+    @classmethod
     def _column_id(cls, tables):
         address = tables['line.sale.shipment_address']
         return address.subdivision
diff -r 01df1c4401a8 -r c6a5f2f36624 sale_reporting.xml
--- a/sale_reporting.xml        Fri Oct 09 19:09:05 2020 +0200
+++ b/sale_reporting.xml        Mon Oct 12 17:48:33 2020 +0200
@@ -103,6 +103,7 @@
                 name="domain"
                 eval="[('customer', '=', Eval('active_id', -1))]"
                 pyson="1"/>
+            <field name="order" eval="[('date', 'DESC')]" pyson="1"/>
         </record>
         <record model="ir.action.act_window.view" 
id="act_reporting_customer_time_series_list_view1">
             <field name="sequence" eval="10"/>
@@ -228,6 +229,7 @@
             <field name="domain"
                 eval="[('product', '=', Eval('active_id', -1))]"
                 pyson="1"/>
+            <field name="order" eval="[('date', 'DESC')]" pyson="1"/>
         </record>
         <record model="ir.action.act_window.view" 
id="act_reporting_product_time_series_list_view1">
             <field name="sequence" eval="10"/>
@@ -360,6 +362,7 @@
                 name="domain"
                 eval="[('category', '=', Eval('active_id', -1))]"
                 pyson="1"/>
+            <field name="order" eval="[('date', 'DESC')]" pyson="1"/>
         </record>
         <record model="ir.action.act_window.view" 
id="act_reporting_category_time_series_list_view1">
             <field name="sequence" eval="10"/>
@@ -465,6 +468,7 @@
             <field name="domain"
                 eval="[('country', '=', Eval('active_id', -1))]"
                 pyson="1"/>
+            <field name="order" eval="[('date', 'DESC')]" pyson="1"/>
         </record>
         <record model="ir.action.act_window.view" 
id="act_reporting_country_time_series_view1">
             <field name="sequence" eval="10"/>
@@ -524,6 +528,7 @@
                 name="domain"
                 eval="[('subdivision', '=', Eval('active_id', -1))]"
                 pyson="1"/>
+            <field name="order" eval="[('date', 'DESC')]" pyson="1"/>
         </record>
         <record model="ir.action.act_window.view" 
id="act_reporting_country_subdivision_time_series_view1">
             <field name="sequence" eval="10"/>

Reply via email to