[WIP] Remove workflow from picking and change state towards a calculated field, make sure scheduler assigns the confirmed moves(=mts) that are possible, correction in search rule with routes, add complex routes
bzr revid: jco@openerp.com-20130717152903-713fdbklmxw0zxwb
This commit is contained in:
parent
850498c289
commit
f6c0f28189
|
@ -80,7 +80,7 @@ Dashboard / Reports for Warehouse Management will include:
|
|||
'wizard/make_procurement_view.xml',
|
||||
'wizard/mrp_procurement_view.xml',
|
||||
'wizard/orderpoint_procurement_view.xml',
|
||||
'stock_workflow.xml',
|
||||
# 'stock_workflow.xml',
|
||||
'stock_incoterms.xml',
|
||||
'stock_report.xml',
|
||||
'stock_view.xml',
|
||||
|
|
|
@ -135,6 +135,8 @@ class procurement_order(osv.osv):
|
|||
#Search all confirmed stock_moves and try to assign them
|
||||
confirmed_ids = move_obj.search(cr, uid, [('state', '=', 'confirmed'), ('company_id','=', company.id)], context=context) #Type = stockable product?
|
||||
move_obj.action_assign(cr, uid, confirmed_ids, context=context)
|
||||
if use_new_cursor:
|
||||
cr.commit()
|
||||
finally:
|
||||
if use_new_cursor:
|
||||
try:
|
||||
|
|
|
@ -408,6 +408,33 @@ class stock_picking(osv.osv):
|
|||
vals['name'] = self.pool.get('ir.sequence').get(cr, user, self._name)
|
||||
return super(stock_picking, self).create(cr, user, vals, context)
|
||||
|
||||
|
||||
def _get_state(self, cr, uid, ids, field_name, arg, context=None):
|
||||
res = {}
|
||||
for pick in self.browse(cr, uid, ids, context=context):
|
||||
states = [x.state for x in pick.move_lines]
|
||||
res[pick.id] = 'draft'
|
||||
if not 'draft' in states:
|
||||
if 'confirmed' in states:
|
||||
res[pick.id] = 'confirmed'
|
||||
elif 'waiting' in states:
|
||||
res[pick.id] = 'auto'
|
||||
elif 'assigned' in states:
|
||||
res[pick.id] = 'assigned'
|
||||
elif 'done' in states:
|
||||
res[pick.id] = 'done'
|
||||
if all([x == 'cancel' for x in states]):
|
||||
res[pick.id] = 'cancel'
|
||||
return res
|
||||
|
||||
def _get_pickings(self, cr, uid, ids, context=None):
|
||||
res = set()
|
||||
for move in self.browse(cr, uid, ids, context=context):
|
||||
if move.picking_id:
|
||||
res.add(move.picking_id.id)
|
||||
return list(res)
|
||||
|
||||
|
||||
_columns = {
|
||||
'name': fields.char('Reference', size=64, select=True, states={'done':[('readonly', True)], 'cancel':[('readonly',True)]}),
|
||||
'origin': fields.char('Source Document', size=64, states={'done':[('readonly', True)], 'cancel':[('readonly',True)]}, help="Reference of the document", select=True),
|
||||
|
@ -416,14 +443,14 @@ class stock_picking(osv.osv):
|
|||
'note': fields.text('Notes', states={'done':[('readonly', True)], 'cancel':[('readonly',True)]}),
|
||||
'stock_journal_id': fields.many2one('stock.journal','Stock Journal', select=True, states={'done':[('readonly', True)], 'cancel':[('readonly',True)]}),
|
||||
'move_type': fields.selection([('direct', 'Partial'), ('one', 'All at once')], 'Delivery Method', required=True, states={'done':[('readonly', True)], 'cancel':[('readonly',True)]}, help="It specifies goods to be deliver partially or all at once"),
|
||||
'state': fields.selection([
|
||||
'state': fields.function(_get_state, type="selection", store = {'stock.move': (_get_pickings, ['state'], 20)}, selection = [
|
||||
('draft', 'Draft'),
|
||||
('cancel', 'Cancelled'),
|
||||
('auto', 'Waiting Another Operation'),
|
||||
('confirmed', 'Waiting Availability'),
|
||||
('assigned', 'Ready to Transfer'),
|
||||
('done', 'Transferred'),
|
||||
], 'Status', readonly=True, select=True, track_visibility='onchange', help="""
|
||||
], string='Status', readonly=True, select=True, track_visibility='onchange', help="""
|
||||
* Draft: not confirmed yet and will not be scheduled until confirmed\n
|
||||
* Waiting Another Operation: waiting for another move to proceed before it becomes automatically available (e.g. in Make-To-Order flows)\n
|
||||
* Waiting Availability: still waiting for the availability of products\n
|
||||
|
@ -1626,7 +1653,6 @@ class stock_move(osv.osv):
|
|||
quant_obj = self.pool.get("stock.quant")
|
||||
uom_obj = self.pool.get("product.uom")
|
||||
done = []
|
||||
pickings = set()
|
||||
for move in self.browse(cr, uid, ids, context=context):
|
||||
if move.state not in ('confirmed', 'waiting'):
|
||||
continue
|
||||
|
@ -1646,13 +1672,7 @@ class stock_move(osv.osv):
|
|||
# the total quantity is provided by existing quants
|
||||
if all(map(lambda x:x[0], quants)):
|
||||
done.append(move.id)
|
||||
pickings.add(move.picking_id and move.picking_id.id or False)
|
||||
self.write(cr, uid, done, {'state': 'assigned'})
|
||||
#TODO: More elegant way to solve this
|
||||
pick_obj = self.pool.get("stock.picking")
|
||||
for pick in list(pickings):
|
||||
if pick_obj.test_assigned(cr, uid, [pick]):
|
||||
pick_obj.write(cr, uid, [pick], {'state': 'assigned'})
|
||||
return done
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
@ -0,0 +1,45 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
{
|
||||
'name': 'Complex routes when using stock locations, purchase and sale',
|
||||
'version': '1.0',
|
||||
'category': 'Hidden',
|
||||
'summary': 'Complex routes',
|
||||
'description': """
|
||||
Manage sales quotations and stock_location
|
||||
==========================================
|
||||
|
||||
This adds a route on the sales order and sales order line (mini module)
|
||||
|
||||
""",
|
||||
'author': 'OpenERP SA',
|
||||
'website': 'http://www.openerp.com',
|
||||
'images': [],
|
||||
'depends': ['purchase', 'sale_stock_location'],
|
||||
'init_xml': [],
|
||||
'update_xml': ['stock_complex_routes.xml'],
|
||||
'demo_xml': [],
|
||||
'test': [],
|
||||
'installable': True,
|
||||
'auto_install': True,
|
||||
}
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
@ -0,0 +1,29 @@
|
|||
<?xml version="1.0"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<!-- Drop Shipping-->
|
||||
<record id="route_drop_shipping" model='stock.location.route'>
|
||||
<field name="name">Drop Shipping</field>
|
||||
<field name="sequence">3</field>
|
||||
</record>
|
||||
|
||||
<record id="procurement_rule_drop_shipping" model="procurement.rule">
|
||||
<field name="name">Supplier → Customer</field>
|
||||
<field name="action">buy</field>
|
||||
<field name="location_id" ref="stock.stock_location_customers"/>
|
||||
<field name="location_src_id" ref="stock.stock_location_suppliers"/>
|
||||
<field name="procure_method">make_to_stock</field>
|
||||
<field name="route_id" ref="route_drop_shipping"/>
|
||||
</record>
|
||||
|
||||
|
||||
<!-- Crossdock -->
|
||||
<record id="procurement_rule_customer0_xdock" model="procurement.rule">
|
||||
<field name="name"> Supplier → Output</field>
|
||||
<field name="action">buy</field>
|
||||
<field name="location_id" ref="stock.stock_location_output"/>
|
||||
<field name="location_src_id" ref="stock.stock_location_suppliers"/>
|
||||
<field name="route_id" ref="stock_location.route_warehouse0_crossdock"/>
|
||||
</record>
|
||||
</data>
|
||||
</openerp>
|
|
@ -171,9 +171,9 @@ class procurement_order(osv.osv):
|
|||
res = self.pool.get('procurement.rule').search(cr, uid, domain + [('route_id', 'in', route_ids)], context=context)
|
||||
if not res:
|
||||
route_ids = [x.id for x in procurement.product_id.route_ids]
|
||||
self.pool.get('procurement.rule').search(cr, uid, domain + [('route_id', 'in', route_ids)], context=context)
|
||||
res = self.pool.get('procurement.rule').search(cr, uid, domain + [('route_id', 'in', route_ids)], context=context)
|
||||
if not res:
|
||||
self.pool.get('procurement.rule').search(cr, uid, domain, context=context)
|
||||
res = self.pool.get('procurement.rule').search(cr, uid, domain, context=context)
|
||||
return res
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue