diff --git a/addons/stock/__openerp__.py b/addons/stock/__openerp__.py index 14335a7fdbd..1491ee237ce 100644 --- a/addons/stock/__openerp__.py +++ b/addons/stock/__openerp__.py @@ -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', diff --git a/addons/stock/procurement.py b/addons/stock/procurement.py index cdf11ebdd90..7653b63fe28 100644 --- a/addons/stock/procurement.py +++ b/addons/stock/procurement.py @@ -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: diff --git a/addons/stock/stock.py b/addons/stock/stock.py index b9b0d644045..a1efc5724e3 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -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 diff --git a/addons/stock_complex_routes/__init__.py b/addons/stock_complex_routes/__init__.py new file mode 100644 index 00000000000..1529644d61e --- /dev/null +++ b/addons/stock_complex_routes/__init__.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL (). +# +# 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 . +# +############################################################################## + + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file diff --git a/addons/stock_complex_routes/__openerp__.py b/addons/stock_complex_routes/__openerp__.py new file mode 100644 index 00000000000..5426e2c7aca --- /dev/null +++ b/addons/stock_complex_routes/__openerp__.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL (). +# +# 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 . +# +############################################################################## + +{ + '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: diff --git a/addons/stock_complex_routes/stock_complex_routes.xml b/addons/stock_complex_routes/stock_complex_routes.xml new file mode 100644 index 00000000000..c3a3cf14364 --- /dev/null +++ b/addons/stock_complex_routes/stock_complex_routes.xml @@ -0,0 +1,29 @@ + + + + + + Drop Shipping + 3 + + + + Supplier → Customer + buy + + + make_to_stock + + + + + + + Supplier → Output + buy + + + + + + diff --git a/addons/stock_location/stock_location.py b/addons/stock_location/stock_location.py index 3f039d1c1b5..de27cd57eb5 100644 --- a/addons/stock_location/stock_location.py +++ b/addons/stock_location/stock_location.py @@ -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