[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:
parent
0b92f7e150
commit
212be5e67c
|
@ -152,6 +152,9 @@ class product_product(osv.osv):
|
||||||
class sale_order(osv.osv):
|
class sale_order(osv.osv):
|
||||||
_inherit = 'sale.order'
|
_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):
|
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,
|
proc_data = super(sale_order, self)._prepare_order_line_procurement(cr,
|
||||||
uid, order, line, group_id = group_id, context=context)
|
uid, order, line, group_id = group_id, context=context)
|
||||||
|
|
|
@ -653,6 +653,9 @@ class sale_order(osv.osv):
|
||||||
def _check_create_procurement(self, cr, uid, order, line, context=None):
|
def _check_create_procurement(self, cr, uid, order, line, context=None):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def _can_create_procurement(self, cr, uid, ids, context=None):
|
||||||
|
return False
|
||||||
|
|
||||||
def action_ship_create(self, cr, uid, ids, context=None):
|
def action_ship_create(self, cr, uid, ids, context=None):
|
||||||
"""Create the required procurements to supply sales order lines, also connecting
|
"""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
|
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)
|
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_id = procurement_obj.create(cr, uid, vals, context=context)
|
||||||
proc_ids.append(proc_id)
|
proc_ids.append(proc_id)
|
||||||
|
#Confirm procurement order such that rules will be applied on it
|
||||||
#Confirm procurement order such that rules will be applied on it
|
procurement_obj.run(cr, uid, proc_ids, context=context)
|
||||||
procurement_obj.run(cr, uid, proc_ids, context=context)
|
|
||||||
# FP NOTE: do we need this? isn't it the workflow that should set this
|
# FP NOTE: do we need this? isn't it the workflow that should set this
|
||||||
val = {}
|
val = {}
|
||||||
if order.state == 'shipping_except':
|
if order.state == 'shipping_except':
|
||||||
|
@ -713,7 +715,14 @@ class sale_order(osv.osv):
|
||||||
canceled = False
|
canceled = False
|
||||||
write_done_ids = []
|
write_done_ids = []
|
||||||
write_cancel_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={}):
|
for order in self.browse(cr, uid, ids, context={}):
|
||||||
|
|
||||||
#TODO: Need to rethink what happens when cancelling
|
#TODO: Need to rethink what happens when cancelling
|
||||||
for line in order.order_line:
|
for line in order.order_line:
|
||||||
states = [x.state for x in line.procurement_ids]
|
states = [x.state for x in line.procurement_ids]
|
||||||
|
|
|
@ -30,6 +30,10 @@ from openerp import SUPERUSER_ID
|
||||||
|
|
||||||
class sale_order(osv.osv):
|
class sale_order(osv.osv):
|
||||||
_inherit = "sale.order"
|
_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):
|
def copy(self, cr, uid, id, default=None, context=None):
|
||||||
if not default:
|
if not default:
|
||||||
default = {}
|
default = {}
|
||||||
|
@ -157,6 +161,7 @@ class sale_order(osv.osv):
|
||||||
})
|
})
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
# TODO: FP Note: I guess it's better to do:
|
# TODO: FP Note: I guess it's better to do:
|
||||||
# if order_policy<>picking: super()
|
# if order_policy<>picking: super()
|
||||||
# else: call invoice_on_picking_method()
|
# 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['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['price_unit'] = sale_line.price_unit
|
||||||
res['discount'] = sale_line.discount
|
res['discount'] = sale_line.discount
|
||||||
return res
|
return res
|
Loading…
Reference in New Issue