From b0ffad195c9ddc1edd0d4e6a8a8932f9b9014480 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sat, 23 Jan 2010 11:47:04 +0100 Subject: [PATCH] Add default search value on inventory, move and shipments --- CHANGELOG | 2 ++ inventory.py | 8 ++++++++ inventory.xml | 2 ++ move.py | 3 +++ move.xml | 4 ++++ shipment.py | 19 +++++++++++++++++++ shipment.xml | 10 ++++++++++ 7 files changed, 48 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 2382afc3b0..5467481e40 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,5 @@ +* Add default search value on inventory, move and shipments + Version 1.4.0 - 2009-10-19 * Bug fixes (see mercurial logs for details) * Add new group "Stock Force Assignment" diff --git a/inventory.py b/inventory.py index 2669051172..30d1c10314 100644 --- a/inventory.py +++ b/inventory.py @@ -4,6 +4,7 @@ from trytond.model import ModelWorkflow, ModelView, ModelSQL, fields from trytond.wizard import Wizard from trytond.pyson import Not, Equal, Eval, Or, Bool +from trytond.backend import TableHandler STATES = { 'readonly': Not(Equal(Eval('state'), 'draft')), @@ -46,6 +47,13 @@ class Inventory(ModelWorkflow, ModelSQL, ModelView): super(Inventory, self).__init__() self._order.insert(0, ('date', 'DESC')) + def init(self, cursor, module_name): + super(Inventory, self).init(cursor, module_name) + + # Add index on create_date + table = TableHandler(cursor, self, module_name) + table.index_action('create_date', action='add') + def default_state(self, cursor, user, context=None): return 'draft' diff --git a/inventory.xml b/inventory.xml index c52bcf5d82..cdd052df50 100644 --- a/inventory.xml +++ b/inventory.xml @@ -59,6 +59,7 @@ this repository contains the full copyright notices and license terms. --> + ]]> @@ -67,6 +68,7 @@ this repository contains the full copyright notices and license terms. --> Inventories stock.inventory form + {'create_date': ['between', Date(delta_years=-1)]} diff --git a/move.py b/move.py index a6a517ae2f..6b5e05efa1 100644 --- a/move.py +++ b/move.py @@ -134,6 +134,9 @@ class Move(ModelSQL, ModelView): table = TableHandler(cursor, self, module_name) table.drop_constraint('check_packing_in_out') + # Add index on create_date + table.index_action('create_date', action='add') + def default_planned_date(self, cursor, user, context=None): if context and context.get('planned_date'): return context.get('planned_date') diff --git a/move.xml b/move.xml index 62eb4418d0..e9bca107a4 100644 --- a/move.xml +++ b/move.xml @@ -51,6 +51,7 @@ this repository contains the full copyright notices and license terms. --> + ]]> @@ -59,6 +60,7 @@ this repository contains the full copyright notices and license terms. --> Moves stock.move form + {'create_date': ['between', Date(delta_years=-1)]} @@ -79,6 +81,7 @@ this repository contains the full copyright notices and license terms. --> stock.move form [('from_location.type', '=', 'supplier')] + {'create_date': ['between', Date(delta_years=-1)]} @@ -121,6 +124,7 @@ this repository contains the full copyright notices and license terms. --> stock.move form [('to_location.type', '=', 'customer')] + {'create_date': ['between', Date(delta_years=-1)]} diff --git a/shipment.py b/shipment.py index 18d0f732d4..41457de17e 100644 --- a/shipment.py +++ b/shipment.py @@ -129,6 +129,10 @@ class ShipmentIn(ModelWorkflow, ModelSQL, ModelView): super(ShipmentIn, self).init(cursor, module_name) + # Add index on create_date + table = TableHandler(cursor, self, module_name) + table.index_action('create_date', action='add') + def default_state(self, cursor, user, context=None): return 'draft' @@ -427,6 +431,10 @@ class ShipmentInReturn(ModelWorkflow, ModelSQL, ModelView): super(ShipmentInReturn, self).init(cursor, module_name) + # Add index on create_date + table = TableHandler(cursor, self, module_name) + table.index_action('create_date', action='add') + def __init__(self): super(ShipmentInReturn, self).__init__() self._rpc.update({ @@ -638,6 +646,9 @@ class ShipmentOut(ModelWorkflow, ModelSQL, ModelView): table = TableHandler(cursor, self, module_name) table.drop_column('customer_location', exception=True) + # Add index on create_date + table.index_action('create_date', action='add') + def default_state(self, cursor, user, context=None): return 'draft' @@ -1066,6 +1077,10 @@ class ShipmentOutReturn(ModelWorkflow, ModelSQL, ModelView): super(ShipmentOutReturn, self).init(cursor, module_name) + # Add index on create_date + table = TableHandler(cursor, self, module_name) + table.index_action('create_date', action='add') + def default_state(self, cursor, user, context=None): return 'draft' @@ -1457,6 +1472,10 @@ class ShipmentInternal(ModelWorkflow, ModelSQL, ModelView): super(ShipmentInternal, self).init(cursor, module_name) + # Add index on create_date + table = TableHandler(cursor, self, module_name) + table.index_action('create_date', action='add') + def default_state(self, cursor, user, context=None): return 'draft' diff --git a/shipment.xml b/shipment.xml index 1698b407fa..7f380d1be4 100644 --- a/shipment.xml +++ b/shipment.xml @@ -80,6 +80,7 @@ this repository contains the full copyright notices and license terms. --> + ]]> @@ -88,6 +89,7 @@ this repository contains the full copyright notices and license terms. --> Supplier Shipments stock.shipment.in form + {'create_date': ['between', Date(delta_years=-1)]} @@ -213,6 +215,7 @@ this repository contains the full copyright notices and license terms. --> + ]]> @@ -221,6 +224,7 @@ this repository contains the full copyright notices and license terms. --> Supplier Return Shipments stock.shipment.in.return form + {'create_date': ['between', Date(delta_years=-1)]} @@ -363,6 +367,7 @@ this repository contains the full copyright notices and license terms. --> + ]]> @@ -383,6 +388,7 @@ this repository contains the full copyright notices and license terms. --> Customer Shipments stock.shipment.out form + {'create_date': ['between', Date(delta_years=-1)]} @@ -556,6 +562,7 @@ this repository contains the full copyright notices and license terms. --> + ]]> @@ -564,6 +571,7 @@ this repository contains the full copyright notices and license terms. --> Internal Shipments stock.shipment.internal form + {'create_date': ['between', Date(delta_years=-1)]} @@ -768,6 +776,7 @@ this repository contains the full copyright notices and license terms. --> + ]]> @@ -777,6 +786,7 @@ this repository contains the full copyright notices and license terms. --> Customer Return Shipments stock.shipment.out.return form + {'create_date': ['between', Date(delta_years=-1)]}