summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorJosse Colpaert <jco@openerp.com>2013-09-11 10:24:31 +0200
committerJosse Colpaert <jco@openerp.com>2013-09-11 10:24:31 +0200
commitd35dda29b47a0d4476dffdd4e8a4cd5d7dcc4221 (patch)
treee9b467d0f32f96115313fba90a5ff17730c1ae6d /addons
parent8e6866efee824be4417bbf0647d4ed9c948be456 (diff)
[IMP] Add routes on category logic
bzr revid: jco@openerp.com-20130911082431-mlhe6hq54l29dktl
Diffstat (limited to 'addons')
-rw-r--r--addons/sale_stock/test/picking_order_policy.yml1
-rw-r--r--addons/stock_location/stock_location.py24
-rw-r--r--addons/stock_location/stock_location_data.xml1
-rw-r--r--addons/stock_location/stock_location_view.xml3
4 files changed, 23 insertions, 6 deletions
diff --git a/addons/sale_stock/test/picking_order_policy.yml b/addons/sale_stock/test/picking_order_policy.yml
index 4251c7a98a8..e119d84fcfb 100644
--- a/addons/sale_stock/test/picking_order_policy.yml
+++ b/addons/sale_stock/test/picking_order_policy.yml
@@ -38,7 +38,6 @@
assert procurement.product_id.id == order_line.product_id.id, "Product is not correspond."
assert procurement.product_qty == order_line.product_uom_qty, "Qty is not correspond."
assert procurement.product_uom.id == order_line.product_uom.id, "UOM is not correspond."
- assert procurement.move_ids[0].procure_method == order_line.type, "Procurement method is not correspond."
-
I check the details of delivery order after confirmed quotation.
-
diff --git a/addons/stock_location/stock_location.py b/addons/stock_location/stock_location.py
index e269563e9d0..2247cd282a3 100644
--- a/addons/stock_location/stock_location.py
+++ b/addons/stock_location/stock_location.py
@@ -41,7 +41,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', domain="[('warehouse_selectable', '=', True)]", 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'), #TODO: required = True?
}
@@ -151,7 +151,9 @@ class procurement_order(osv.osv):
def _search_suitable_rule(self, cr, uid, procurement, domain, context=None):
'''we try to first find a rule among the ones defined on the procurement order group and if none is found, we try on the routes defined for the product, and finally we fallback on the default behavior'''
- route_ids = [x.id for x in procurement.route_ids] + [x.id for x in procurement.product_id.route_ids]
+ categ_obj = self.pool.get("product.category")
+ categ_id = procurement.product_id.categ_id.id
+ route_ids = [x.id for x in procurement.route_ids] + [x.id for x in procurement.product_id.route_ids] + categ_obj.calculate_total_routes(cr, uid, [categ_id], False, False, context=context)[categ_id]
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 + [('route_id', '=', False)], order='sequence', context=context)
@@ -184,17 +186,33 @@ 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', domain="[('product_selectable', '=', True)]"),
+ 'route_ids': fields.many2many('stock.location.route', 'stock_location_route_product', 'product_id', 'route_id', 'Routes', domain="[('product_selectable', '=', True)]"), #Adds domain
}
class product_category(osv.osv):
_inherit = 'product.category'
+
+
+ def calculate_total_routes(self, cr, uid, ids, name, args, context=None):
+ res = {}
+ route_obj = self.pool.get("stock.location.route")
+ for categ in self.browse(cr, uid, ids, context=context):
+ categ2 = categ
+ routes = [x.id for x in categ.route_ids]
+ while categ2.parent_id:
+ categ2 = categ2.parent_id
+ routes += [x.id for x in categ2.route_ids]
+ res[categ.id] = routes
+ return res
+
_columns = {
'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'),
+ 'total_route_ids': fields.function(calculate_total_routes, relation='stock.location.route', type='many2many', string='Total routes', readonly=True),
}
+
class stock_move_putaway(osv.osv):
_name = 'stock.move.putaway'
diff --git a/addons/stock_location/stock_location_data.xml b/addons/stock_location/stock_location_data.xml
index e46d4863227..aae66787828 100644
--- a/addons/stock_location/stock_location_data.xml
+++ b/addons/stock_location/stock_location_data.xml
@@ -71,7 +71,6 @@
<field name="name">Crossdock</field>
<field name="sequence">9</field>
<field name="product_categ_selectable" eval="True"/>
- <field name="sale_selectable" eval="True"/>
<field name="warehouse_selectable" eval="True"/>
<field name="product_selectable" eval="False"/>
</record>
diff --git a/addons/stock_location/stock_location_view.xml b/addons/stock_location/stock_location_view.xml
index 616e0b3e6ed..061ec88003f 100644
--- a/addons/stock_location/stock_location_view.xml
+++ b/addons/stock_location/stock_location_view.xml
@@ -137,7 +137,8 @@
<field name="arch" type="xml">
<xpath expr="//sheet" position="inside">
<group string="Strategy" colspan="4">
- <field name="route_ids" colspan="4" nolabel="1" widget="many2many_tags"/>
+ <field name="route_ids" colspan="4" widget="many2many_tags"/>
+ <field name="total_route_ids" widget="many2many_tags"/>
</group>
</xpath>
</field>