[IMP] Add routes on category logic

bzr revid: jco@openerp.com-20130911082431-mlhe6hq54l29dktl
This commit is contained in:
Josse Colpaert
2013-09-11 10:24:31 +02:00
parent 8e6866efee
commit d35dda29b4
4 changed files with 23 additions and 6 deletions
@@ -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.
-
+21 -3
View File
@@ -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'
@@ -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>
@@ -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>