[WIP]fix sale workflow in the case we only have sale and not stock installed.

bzr revid: csn@openerp.com-20130913093815-m6luad9cnhykbcha
This commit is contained in:
Cedric Snauwaert 2013-09-13 11:38:15 +02:00
parent 0b92f7e150
commit 212be5e67c
3 changed files with 21 additions and 4 deletions

View File

@ -152,6 +152,9 @@ class product_product(osv.osv):
class sale_order(osv.osv):
_inherit = 'sale.order'
def _can_create_procurement(self, cr, uid, ids, context=None):
return True
def _prepare_order_line_procurement(self, cr, uid, order, line, group_id=False, context=None):
proc_data = super(sale_order, self)._prepare_order_line_procurement(cr,
uid, order, line, group_id = group_id, context=context)

View File

@ -653,6 +653,9 @@ class sale_order(osv.osv):
def _check_create_procurement(self, cr, uid, order, line, context=None):
return True
def _can_create_procurement(self, cr, uid, ids, context=None):
return False
def action_ship_create(self, cr, uid, ids, context=None):
"""Create the required procurements to supply sales order lines, also connecting
the procurements to appropriate stock moves in order to bring the goods to the
@ -678,9 +681,8 @@ class sale_order(osv.osv):
vals = self._prepare_order_line_procurement(cr, uid, order, line, group_id=group_id, context=context)
proc_id = procurement_obj.create(cr, uid, vals, context=context)
proc_ids.append(proc_id)
#Confirm procurement order such that rules will be applied on it
procurement_obj.run(cr, uid, proc_ids, context=context)
#Confirm procurement order such that rules will be applied on it
procurement_obj.run(cr, uid, proc_ids, context=context)
# FP NOTE: do we need this? isn't it the workflow that should set this
val = {}
if order.state == 'shipping_except':
@ -713,7 +715,14 @@ class sale_order(osv.osv):
canceled = False
write_done_ids = []
write_cancel_ids = []
if not self._can_create_procurement(cr, uid, ids, context={}):
for order in self.browse(cr, uid, ids, context={}):
for line in order.order_line:
write_done_ids.append(line.id)
self.pool.get('sale.order.line').write(cr, uid, write_done_ids, {'state': 'done'})
return True
for order in self.browse(cr, uid, ids, context={}):
#TODO: Need to rethink what happens when cancelling
for line in order.order_line:
states = [x.state for x in line.procurement_ids]

View File

@ -30,6 +30,10 @@ from openerp import SUPERUSER_ID
class sale_order(osv.osv):
_inherit = "sale.order"
def _can_create_procurement(self, cr, uid, ids, context=None):
return True
def copy(self, cr, uid, id, default=None, context=None):
if not default:
default = {}
@ -157,6 +161,7 @@ class sale_order(osv.osv):
})
return result
# TODO: FP Note: I guess it's better to do:
# if order_policy<>picking: super()
# else: call invoice_on_picking_method()
@ -402,4 +407,4 @@ class stock_move(osv.osv):
res['account_analytic_id'] = sale_line.order_id.project_id and sale_line.order_id.project_id.id or False
res['price_unit'] = sale_line.price_unit
res['discount'] = sale_line.discount
return res
return res