diff --git a/addons/sale_stock_location/sale_stock_location.py b/addons/sale_stock_location/sale_stock_location.py
index 6cbde59ef2d..212b53c5996 100644
--- a/addons/sale_stock_location/sale_stock_location.py
+++ b/addons/sale_stock_location/sale_stock_location.py
@@ -48,14 +48,14 @@ class sale_order(osv.osv):
class sale_order_line(osv.osv):
_inherit = 'sale.order.line'
_columns = {
- 'route_id': fields.many2one('stock.location.route', 'Route', domain=[('sale', '=', True)]),
+ 'route_id': fields.many2one('stock.location.route', 'Route', domain=[('sale_selectable', '=', True)]),
}
class stock_location_route(osv.osv):
_inherit = "stock.location.route"
_columns = {
- 'sale':fields.boolean("Can be set on sale order line")
+ 'sale_selectable':fields.boolean("Selectable on Sales Order Line")
}
diff --git a/addons/sale_stock_location/sale_stock_location_view.xml b/addons/sale_stock_location/sale_stock_location_view.xml
index 7fd0f1853b2..de643a2f917 100644
--- a/addons/sale_stock_location/sale_stock_location_view.xml
+++ b/addons/sale_stock_location/sale_stock_location_view.xml
@@ -44,10 +44,21 @@
stock.location.route
-
-
+
+
+
+ stock.location.route.tree.inherit
+
+ stock.location.route
+
+
+
+
+
+
+
diff --git a/addons/stock/procurement.py b/addons/stock/procurement.py
index c9d89816983..fbc1fb69f83 100644
--- a/addons/stock/procurement.py
+++ b/addons/stock/procurement.py
@@ -173,7 +173,7 @@ class procurement_order(osv.osv):
'product_uom': product.uom_id.id,
'location_id': location_id,
'company_id': warehouse.company_id.id,
- 'procure_method': 'make_to_order',}
+ }
def create_automatic_op(self, cr, uid, context=None):
"""
@@ -204,7 +204,7 @@ class procurement_order(osv.osv):
product = product_obj.browse(cr, uid, [product_read['id']], context=context)[0]
if product.supply_method == 'buy':
- location_id = warehouse.lot_input_id.id
+ location_id = warehouse.lot_stock_id.id
elif product.supply_method == 'produce':
location_id = warehouse.lot_stock_id.id
else:
@@ -212,8 +212,8 @@ class procurement_order(osv.osv):
proc_id = proc_obj.create(cr, uid,
self._prepare_automatic_op_procurement(cr, uid, product, warehouse, location_id, context=context),
context=context)
- self.signal_button_confirm(cr, uid, [proc_id])
- self.signal_button_check(cr, uid, [proc_id])
+ self.assign(cr, uid, [proc_id])
+ self.run(cr, uid, [proc_id])
return True
def _get_orderpoint_date_planned(self, cr, uid, orderpoint, start_date, context=None):
@@ -229,7 +229,6 @@ class procurement_order(osv.osv):
'company_id': orderpoint.company_id.id,
'product_uom': orderpoint.product_uom.id,
'location_id': orderpoint.location_id.id,
- 'procure_method': 'make_to_order',
'origin': orderpoint.name}
def _product_virtual_get(self, cr, uid, order_point):
diff --git a/addons/stock/stock.py b/addons/stock/stock.py
index 6923044dc4e..5d3c79417e5 100644
--- a/addons/stock/stock.py
+++ b/addons/stock/stock.py
@@ -1950,7 +1950,10 @@ class stock_package(osv.osv):
"""
_name = "stock.quant.package"
_description = "Physical Packages"
- _order = 'name'
+ _parent_name = "parent_id"
+ _parent_store = True
+ _parent_order = 'name'
+ _order = 'parent_left'
def name_get(self, cr, uid, ids, context=None):
res = self._complete_name(cr, uid, ids, 'complete_name', None, context=context)
@@ -1985,16 +1988,20 @@ class stock_package(osv.osv):
res.add(pack.parent_id.id)
return list(res)
+ # TODO: Problem when package is empty!
+ #
def _get_package_info(self, cr, uid, ids, name, args, context=None):
default_company_id = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.id
res = {}.fromkeys(ids, {'location_id': False, 'company_id': default_company_id})
for pack in self.browse(cr, uid, ids, context=context):
if pack.quant_ids:
res[pack.id]['location_id'] = pack.quant_ids[0].location_id.id
+ res[pack.id]['owner_id'] = pack.quant_ids[0].owner_id and pack.quant_ids[0].owner_id.id or False
res[pack.id]['company_id'] = pack.quant_ids[0].company_id.id
elif pack.children_ids:
- res[pack.id]['location_id'] = pack.children_ids[0].location_id.id
- res[pack.id]['company_id'] = pack.children_ids[0].company_id.id
+ res[pack.id]['location_id'] = pack.children_ids[0].location_id and pack.children_ids[0].location_id.id or False
+ res[pack.id]['owner_id'] = pack.children_ids[0].owner_id and pack.children_ids[0].owner_id.id or False
+ res[pack.id]['company_id'] = pack.children_ids[0].company_id and pack.children_ids[0].company_id.id or False
return res
_columns = {
@@ -2006,12 +2013,21 @@ class stock_package(osv.osv):
'location_id': fields.function(_get_package_info, type='many2one', relation='stock.location', string='Location', multi="package",
store={
'stock.quant': (_get_packages, ['location_id'], 10),
- 'stock.quant.package': (_get_packages_to_relocate, ['children_ids', 'quant_ids', 'parent_id'], 10),
+ 'stock.quant.package': (_get_packages_to_relocate, ['quant_ids', 'children_ids', 'parent_id'], 10),
}, readonly=True),
'quant_ids': fields.one2many('stock.quant', 'package_id', 'Bulk Content'),
'parent_id': fields.many2one('stock.quant.package', 'Parent Package', help="The package containing this item"),
'children_ids': fields.one2many('stock.quant.package', 'parent_id', 'Contained Packages'),
- 'company_id': fields.function(_get_package_info, type="many2one", relation='res.company', string='Company', multi="package"),
+ 'company_id': fields.function(_get_package_info, type="many2one", relation='res.company', string='Company', multi="package",
+ store={
+ 'stock.quant': (_get_packages, ['company_id'], 10),
+ 'stock.quant.package': (_get_packages_to_relocate, ['quant_ids', 'children_ids', 'parent_id'], 10),
+ }, readonly=True),
+ 'owner_id': fields.function(_get_package_info, type='many2one', relation='res.partner', string='Owner', multi="package",
+ store={
+ 'stock.quant': (_get_packages, ['owner_id'], 10),
+ 'stock.quant.package': (_get_packages_to_relocate, ['quant_ids', 'children_ids', 'parent_id'], 10),
+ }, readonly=True),
}
_defaults = {
'name': lambda self, cr, uid, context: self.pool.get('ir.sequence').get(cr, uid, 'stock.quant.package') or _('Unknown Pack')
diff --git a/addons/stock/stock_view.xml b/addons/stock/stock_view.xml
index f5f7f6532fb..928d6b2ca21 100644
--- a/addons/stock/stock_view.xml
+++ b/addons/stock/stock_view.xml
@@ -614,7 +614,7 @@
-
+
@@ -1725,6 +1725,7 @@
+
diff --git a/addons/stock_complex_routes/stock_complex_routes.xml b/addons/stock_complex_routes/stock_complex_routes.xml
index 0591622dbe7..496a0144c37 100644
--- a/addons/stock_complex_routes/stock_complex_routes.xml
+++ b/addons/stock_complex_routes/stock_complex_routes.xml
@@ -23,7 +23,8 @@
Drop Shipping
3
- True
+
+
@@ -40,7 +41,9 @@
Crossdock
- True
+
+
+
Supplier → Output
@@ -50,5 +53,7 @@
+
+
diff --git a/addons/stock_complex_routes/test/procurementexception.yml b/addons/stock_complex_routes/test/procurementexception.yml
index e5c7dbfd72c..018795d1fc7 100644
--- a/addons/stock_complex_routes/test/procurementexception.yml
+++ b/addons/stock_complex_routes/test/procurementexception.yml
@@ -60,4 +60,4 @@
sale_id = self.pool.get('sale.order').browse(cr, uid, ref("sale_order_route_crossdock"))
proc_ids = self.search(cr, uid, [('group_id.name', '=', sale_id.name)])
purchase_id = [proc.purchase_id for proc in self.browse(cr, uid, proc_ids) if proc.purchase_id]
- assert purchase_id, 'No Purchase Quotation is created'
+ assert purchase_id, 'No Purchase Quotation is created'
\ No newline at end of file
diff --git a/addons/stock_location/stock_location.py b/addons/stock_location/stock_location.py
index 4b3d32d9fcc..46ecd325f52 100644
--- a/addons/stock_location/stock_location.py
+++ b/addons/stock_location/stock_location.py
@@ -34,6 +34,9 @@ class stock_location_route(osv.osv):
'sequence': fields.integer('Sequence'),
'pull_ids': fields.one2many('procurement.rule', 'route_id', 'Pull Rules'),
'push_ids': fields.one2many('stock.location.path', 'route_id', 'Push Rules'),
+ 'product_selectable': fields.boolean('Selectable on Product'),
+ 'product_categ_selectable': fields.boolean('Selectable on Product Category'),
+ 'warehouse_selectable': fields.boolean('Selectable on Warehouse'),
}
_defaults = {
'sequence': lambda self,cr,uid,ctx: 0,
@@ -42,7 +45,7 @@ class stock_location_route(osv.osv):
class stock_warehouse(osv.osv):
_inherit = 'stock.warehouse'
_columns = {
- 'route_id': fields.many2one('stock.location.route', 'Default Routes', help='Default route through the warehouse', required=True),
+ 'route_id': fields.many2one('stock.location.route', 'Default Routes', domain="[('warehouse_selectable', '=', True)]", help='Default route through the warehouse', required=True),
}
@@ -171,7 +174,7 @@ class procurement_order(osv.osv):
route_ids = [x.id for x in procurement.route_ids] + [x.id for x in procurement.product_id.route_ids]
res = self.pool.get('procurement.rule').search(cr, uid, domain + [('route_id', 'in', route_ids)], order = 'route_sequence, sequence', context=context)
if not res:
- res = self.pool.get('procurement.rule').search(cr, uid, domain, order='sequence', context=context)
+ res = self.pool.get('procurement.rule').search(cr, uid, domain + [('route_id', '=', False)], order='sequence', context=context)
return res
@@ -201,13 +204,13 @@ class product_removal_strategy(osv.osv):
class product_product(osv.osv):
_inherit = 'product.product'
_columns = {
- 'route_ids': fields.many2many('stock.location.route', 'stock_location_route_product', 'product_id', 'route_id', 'Routes'),
+ 'route_ids': fields.many2many('stock.location.route', 'stock_location_route_product', 'product_id', 'route_id', 'Routes', domain="[('product_selectable', '=', True)]"),
}
class product_category(osv.osv):
_inherit = 'product.category'
_columns = {
- 'route_ids': fields.many2many('stock.location.route', 'stock_location_route_categ', 'categ_id', 'route_id', 'Routes'),
+ 'route_ids': fields.many2many('stock.location.route', 'stock_location_route_categ', 'categ_id', 'route_id', 'Routes', domain="[('product_categ_selectable', '=', True)]"),
'removal_strategy_ids': fields.one2many('product.removal', 'product_categ_id', 'Removal Strategies'),
#'putaway_strategy_ids': fields.one2many('product.putaway', 'product_categ_id', 'Put Away Strategies'),
}
diff --git a/addons/stock_location/stock_location_data.xml b/addons/stock_location/stock_location_data.xml
index c5f438b920a..042f9571f3f 100644
--- a/addons/stock_location/stock_location_data.xml
+++ b/addons/stock_location/stock_location_data.xml
@@ -24,6 +24,7 @@
Sale: Ship only
20
+
@@ -49,8 +50,10 @@
- Produce or buy on Customer Order
+ MTO
10
+
+
@@ -66,6 +69,8 @@
Crossdock
9
+
+
@@ -81,6 +86,7 @@
Sale: Pack + Ship
15
+
@@ -130,6 +136,7 @@
Sale: Pick + Pack + Ship
20
+
diff --git a/addons/stock_location/stock_location_view.xml b/addons/stock_location/stock_location_view.xml
index c6d441e6930..cfd5a858d82 100644
--- a/addons/stock_location/stock_location_view.xml
+++ b/addons/stock_location/stock_location_view.xml
@@ -166,6 +166,9 @@
+
+
+
@@ -178,6 +181,11 @@