← Back to team overview

openerp-community-reviewer team mailing list archive

[Merge] lp:~camptocamp/stock-logistic-flows/7.0-stock_picking_priority-selection-extendable into lp:stock-logistic-flows

 

Guewen Baconnier @ Camptocamp has proposed merging lp:~camptocamp/stock-logistic-flows/7.0-stock_picking_priority-selection-extendable into lp:stock-logistic-flows.

Requested reviews:
  Stock and Logistic Core Editors (stock-logistic-core-editors)

For more details, see:
https://code.launchpad.net/~camptocamp/stock-logistic-flows/7.0-stock_picking_priority-selection-extendable/+merge/208747

Allow to extend or change the selection without duplicating the entire field definition.
-- 
https://code.launchpad.net/~camptocamp/stock-logistic-flows/7.0-stock_picking_priority-selection-extendable/+merge/208747
Your team Stock and Logistic Core Editors is requested to review the proposed merge of lp:~camptocamp/stock-logistic-flows/7.0-stock_picking_priority-selection-extendable into lp:stock-logistic-flows.
=== modified file 'stock_picking_priority/picking_priority.py'
--- stock_picking_priority/picking_priority.py	2014-02-02 21:43:11 +0000
+++ stock_picking_priority/picking_priority.py	2014-02-28 08:50:05 +0000
@@ -27,10 +27,23 @@
 
 class StockPicking(orm.Model):
     _inherit = "stock.picking"
+
+    def get_selection_priority(self, cr, uid, context=None):
+        """ Inherit to extend the selection.
+
+        The field in `_columns` does not need to be duplicated in the
+        inheriting class.
+        """
+        return [('0', 'Normal'), ('1', 'Urgent'), ('2', 'Very Urgent')]
+
+    def __selection_priority(self, cr, uid, context=None):
+        """ Do not touch me. Extend `get_selection_priority` to modify
+        the selection
+        """
+        return self.get_selection_priority(cr, uid, context=context)
+
     _columns = {
-        'priority': fields.selection([('0', 'Normal'),
-                                      ('1', 'Urgent'),
-                                      ('2', 'Very Urgent')],
+        'priority': fields.selection(__selection_priority,
                                      'Priority',
                                      required=True,
                                      help='The priority of the picking'),
@@ -74,10 +87,13 @@
 
 class StockPickingOut(orm.Model):
     _inherit = 'stock.picking.out'
+
+    def __selection_priority(self, cr, uid, context=None):
+        picking_obj = self.pool['stock.picking']
+        return picking_obj.get_selection_priority(cr, uid, context=context)
+
     _columns = {
-        'priority': fields.selection([('0', 'Normal'),
-                                      ('1', 'Urgent'),
-                                      ('2', 'Very Urgent')],
+        'priority': fields.selection(__selection_priority,
                                      'Priority',
                                      required=True,
                                      help='The priority of the picking'),
@@ -93,10 +109,13 @@
 
 class StockPickingIn(orm.Model):
     _inherit = 'stock.picking.in'
+
+    def __selection_priority(self, cr, uid, context=None):
+        picking_obj = self.pool['stock.picking']
+        return picking_obj.get_selection_priority(cr, uid, context=context)
+
     _columns = {
-        'priority': fields.selection([('0', 'Normal'),
-                                      ('1', 'Urgent'),
-                                      ('2', 'Very Urgent')],
+        'priority': fields.selection(__selection_priority,
                                      'Priority',
                                      required=True,
                                      help='The priority of the picking'),


Follow ups