diff --git a/addons/mrp/mrp_demo.xml b/addons/mrp/mrp_demo.xml
index 59efae9bfcb..952a5e0e3de 100644
--- a/addons/mrp/mrp_demo.xml
+++ b/addons/mrp/mrp_demo.xml
@@ -666,7 +666,7 @@
-
+
diff --git a/addons/sale_stock/sale_stock_demo.xml b/addons/sale_stock/sale_stock_demo.xml
index f35c8cd967e..2e7b641659d 100644
--- a/addons/sale_stock/sale_stock_demo.xml
+++ b/addons/sale_stock/sale_stock_demo.xml
@@ -35,8 +35,8 @@
-
+
+
make_to_order
diff --git a/addons/stock/procurement.py b/addons/stock/procurement.py
index 1ad13b67aef..e48b757fdea 100644
--- a/addons/stock/procurement.py
+++ b/addons/stock/procurement.py
@@ -19,13 +19,8 @@
#
##############################################################################
-import time
-
-from datetime import datetime
-from dateutil.relativedelta import relativedelta
-
from openerp.osv import fields, osv
-import openerp.addons.decimal_precision as dp
+from openerp.tools.translate import _
class procurement_group(osv.osv):
_inherit = 'procurement.group'
@@ -35,11 +30,13 @@ class procurement_group(osv.osv):
class procurement_rule(osv.osv):
_inherit = 'procurement.rule'
+
def _get_action(self, cr, uid, context=None):
result = super(procurement_rule, self)._get_action(cr, uid, context=context)
- return result + [('move','Move From Another Location')]
+ return result + [('move', 'Move From Another Location')]
+
_columns = {
- 'location_id': fields.many2one('stock.location', 'Destination Location'),
+ 'location_id': fields.many2one('stock.location', 'Destination Location'),
'location_src_id': fields.many2one('stock.location', 'Source Location',
help="Source location is action=move")
}
@@ -47,27 +44,28 @@ class procurement_rule(osv.osv):
class procurement_order(osv.osv):
_inherit = "procurement.order"
_columns = {
- 'location_id': fields.many2one('stock.location', 'Destination Location'),
- 'move_id': fields.many2one('stock.move', 'Move', help="Move created by the procurement"),
+ 'location_id': fields.many2one('stock.location', 'Destination Location'),
+ 'move_id': fields.many2one('stock.move', 'Move', help="Move created by the procurement"),
'move_dest_id': fields.many2one('stock.move', 'Destination Move', help="Move which caused (created) the procurement")
}
- def _assign(self, cr, uid, procurement, context=None):
- rule_obj = self.pool.get('procurement.rule')
- res = rule_obj.search(cr, uid, [('location_id','=',procurement.location_id.id)], context=context)
+ def _find_suitable_rule(self, cr, uid, procurement, context=None):
+ res = super(procurement_order, self)._find_suitable_rule(cr, uid, procurement, context=context)
if not res:
- return super(procurement_order, self)._assign(cr, uid, procurement, context=context)
- return rule_obj.browse(cr, uid, res[0], context=context)
+ rule_obj = self.pool.get('procurement.rule')
+ res = rule_obj.search(cr, uid, [('location_id', '=', procurement.location_id.id)], context=context)
+ res = res and res[0] or False
+ return res
- def _run_move_create(self, cr, uid, procurement, context=None):
+ def _run_move_create(self, cr, uid, procurement, context=None):
return {
'name': procurement.name,
- 'company_id': procurement.company_id.id,
+ 'company_id': procurement.company_id.id,
'product_id': procurement.product_id.id,
'date': procurement.date_planned,
'product_qty': procurement.product_qty,
'product_uom': procurement.product_uom.id,
- 'product_uom_qty': procurement.product_qty,
+ 'product_uom_qty': procurement.product_qty,
'product_uos_qty': (procurement.product_uos and procurement.product_uos_qty)\
or procurement.product_qty,
'product_uos': (procurement.product_uos and procurement.product_uos.id)\
@@ -77,28 +75,28 @@ class procurement_order(osv.osv):
'location_id': procurement.rule_id.location_src_id.id,
'location_dest_id': procurement.rule_id.location_id.id,
'move_dest_id': procurement.move_dest_id and procurement.move_dest_id.id or False,
- 'procure_method': procurement.rule_id and procurement.rule_id.procure_method or 'make_to_stock',
+ 'procure_method': procurement.rule_id and procurement.rule_id.procure_method or 'make_to_stock',
#'cancel_cascade': procurement.rule_id and procurement.rule_id.cancel_cascade or False,
- 'group_id': procurement.group_id and procurement.group_id.id or False,
+ 'group_id': procurement.group_id and procurement.group_id.id or False,
}
def _run(self, cr, uid, procurement, context=None):
- context=context or {}
if procurement.rule_id and procurement.rule_id.action == 'move':
if not procurement.rule_id.location_src_id:
self.message_post(cr, uid, [procurement.id], body=_('No source location defined!'), context=context)
return False
move_obj = self.pool.get('stock.move')
move_dict = self._run_move_create(cr, uid, procurement, context=context)
-
+
move_id = move_obj.create(cr, uid, move_dict, context=context)
- move_obj.action_confirm(cr,uid, [move_id], context=context)
+ move_obj.action_confirm(cr, uid, [move_id], context=context)
self.write(cr, uid, [procurement.id], {'move_id': move_id}, context=context)
return move_id
return super(procurement_order, self)._run(cr, uid, procurement, context)
def _check(self, cr, uid, procurement, context=None):
if procurement.rule_id and procurement.rule_id.action == 'move':
- return procurement.move_id.state=='done'
+ return procurement.move_id.state == 'done'
return super(procurement_order, self)._check(cr, uid, procurement, context)
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: