diff --git a/addons/mrp/mrp.py b/addons/mrp/mrp.py
index 1f06815078e..a260efc8e36 100644
--- a/addons/mrp/mrp.py
+++ b/addons/mrp/mrp.py
@@ -714,9 +714,9 @@ class mrp_production(osv.osv):
if production_mode == 'consume_produce':
# To produce remaining qty of final product
vals = {'state':'confirmed'}
- final_product_todo = [x.id for x in production.move_created_ids]
+ #final_product_todo = [x.id for x in production.move_created_ids]
#stock_mov_obj.write(cr, uid, final_product_todo, vals)
- stock_mov_obj.action_confirm(cr, uid, final_product_todo, context)
+ #stock_mov_obj.action_confirm(cr, uid, final_product_todo, context)
produced_products = {}
for produced_product in production.move_created_ids2:
if produced_product.scrapped:
diff --git a/addons/mrp/mrp_view.xml b/addons/mrp/mrp_view.xml
index 26a8c643573..ec9bf58061c 100644
--- a/addons/mrp/mrp_view.xml
+++ b/addons/mrp/mrp_view.xml
@@ -343,6 +343,54 @@
+
@@ -412,6 +460,28 @@
+
+ mrp.bom.component.tree
+ mrp.bom
+ tree
+ child_complete_ids
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Bill of Materials
ir.actions.act_window
@@ -426,6 +496,7 @@
ir.actions.act_window
mrp.bom
form
+
[('bom_id','!=',False)]
Bills of materials components are components and sub-products used to create master bills of materials. Use this menu to search in which BoM a specific component is used.
@@ -616,7 +687,6 @@
-
@@ -646,7 +716,6 @@
-
-
+
diff --git a/addons/sale/sale.py b/addons/sale/sale.py
index 60c5a1e263f..04068b5bd7e 100644
--- a/addons/sale/sale.py
+++ b/addons/sale/sale.py
@@ -705,7 +705,6 @@ class sale_order(osv.osv):
#'state': 'waiting',
'note': line.notes,
'company_id': order.company_id.id,
- 'returned_price': line.price_unit,
})
if line.product_id:
diff --git a/addons/sale/sale_view.xml b/addons/sale/sale_view.xml
index 3d1a14edd53..15bf57bff9a 100644
--- a/addons/sale/sale_view.xml
+++ b/addons/sale/sale_view.xml
@@ -172,6 +172,7 @@
+
diff --git a/addons/stock/stock.py b/addons/stock/stock.py
index 4dea848c190..68b6edb5f8d 100644
--- a/addons/stock/stock.py
+++ b/addons/stock/stock.py
@@ -1223,8 +1223,6 @@ class stock_picking(osv.osv):
{'price_unit': product_price,
'price_currency_id': product_currency})
- if not move.returned_price:
- move_obj.write(cr, uid, [move.id], {'returned_price': move.price_unit})
for move in too_few:
product_qty = move_product_qty[move.id]
@@ -1545,7 +1543,6 @@ class stock_move(osv.osv):
# used for colors in tree views:
'scrapped': fields.related('location_dest_id','scrap_location',type='boolean',relation='stock.location',string='Scrapped', readonly=True),
- 'returned_price': fields.float('Returned product price', digits_compute= dp.get_precision('Sale Price')),
}
_constraints = [
(_check_tracking,
@@ -1794,6 +1791,51 @@ class stock_move(osv.osv):
'date': picking.date,
})
return pick_id
+ def create_chained_picking(self, cr, uid, moves, context=None):
+ res_obj = self.pool.get('res.company')
+ location_obj = self.pool.get('stock.location')
+ move_obj = self.pool.get('stock.move')
+ wf_service = netsvc.LocalService("workflow")
+ new_moves = []
+ if context is None:
+ context = {}
+ seq_obj = self.pool.get('ir.sequence')
+ for picking, todo in self._chain_compute(cr, uid, moves, context=context).items():
+ ptype = todo[0][1][5] and todo[0][1][5] or location_obj.picking_type_get(cr, uid, todo[0][0].location_dest_id, todo[0][1][0])
+ if picking:
+ # name of new picking according to its type
+ new_pick_name = seq_obj.get(cr, uid, 'stock.picking.' + ptype)
+ pickid = self._create_chained_picking(cr, uid, new_pick_name, picking, ptype, todo, context=context)
+ # Need to check name of old picking because it always considers picking as "OUT" when created from Sale Order
+ old_ptype = location_obj.picking_type_get(cr, uid, picking.move_lines[0].location_id, picking.move_lines[0].location_dest_id)
+ if old_ptype != picking.type:
+ old_pick_name = seq_obj.get(cr, uid, 'stock.picking.' + old_ptype)
+ self.pool.get('stock.picking').write(cr, uid, picking.id, {'name': old_pick_name}, context=context)
+ else:
+ pickid = False
+ for move, (loc, dummy, delay, dummy, company_id, ptype) in todo:
+ new_id = move_obj.copy(cr, uid, move.id, {
+ 'location_id': move.location_dest_id.id,
+ 'location_dest_id': loc.id,
+ 'date_moved': time.strftime('%Y-%m-%d'),
+ 'picking_id': pickid,
+ 'state': 'waiting',
+ 'company_id': company_id or res_obj._company_default_get(cr, uid, 'stock.company', context=context) ,
+ 'move_history_ids': [],
+ 'date': (datetime.strptime(move.date, '%Y-%m-%d %H:%M:%S') + relativedelta(days=delay or 0)).strftime('%Y-%m-%d'),
+ 'move_history_ids2': []}
+ )
+ move_obj.write(cr, uid, [move.id], {
+ 'move_dest_id': new_id,
+ 'move_history_ids': [(4, new_id)]
+ })
+ new_moves.append(self.browse(cr, uid, [new_id])[0])
+ if pickid:
+ wf_service.trg_validate(uid, 'stock.picking', pickid, 'button_confirm', cr)
+ if new_moves:
+ new_moves += self.create_chained_picking(cr, uid, new_moves, context)
+ return new_moves
+
def action_confirm(self, cr, uid, ids, context=None):
""" Confirms stock move.
@return: List of ids.
@@ -1805,46 +1847,7 @@ class stock_move(osv.osv):
move_obj = self.pool.get('stock.move')
wf_service = netsvc.LocalService("workflow")
- def create_chained_picking(self, cr, uid, moves, context=None):
- new_moves = []
- if context is None:
- context = {}
- seq_obj = self.pool.get('ir.sequence')
- for picking, todo in self._chain_compute(cr, uid, moves, context=context).items():
- ptype = todo[0][1][5] and todo[0][1][5] or location_obj.picking_type_get(cr, uid, todo[0][0].location_dest_id, todo[0][1][0])
- if picking:
- # name of new picking according to its type
- new_pick_name = seq_obj.get(cr, uid, 'stock.picking.' + ptype)
- pickid = self._create_chained_picking(cr, uid, new_pick_name, picking, ptype, todo, context=context)
- # Need to check name of old picking because it always considers picking as "OUT" when created from Sale Order
- old_ptype = location_obj.picking_type_get(cr, uid, picking.move_lines[0].location_id, picking.move_lines[0].location_dest_id)
- if old_ptype != picking.type:
- old_pick_name = seq_obj.get(cr, uid, 'stock.picking.' + old_ptype)
- self.pool.get('stock.picking').write(cr, uid, picking.id, {'name': old_pick_name}, context=context)
- else:
- pickid = False
- for move, (loc, dummy, delay, dummy, company_id, ptype) in todo:
- new_id = move_obj.copy(cr, uid, move.id, {
- 'location_id': move.location_dest_id.id,
- 'location_dest_id': loc.id,
- 'date_moved': time.strftime('%Y-%m-%d'),
- 'picking_id': pickid,
- 'state': 'waiting',
- 'company_id': company_id or res_obj._company_default_get(cr, uid, 'stock.company', context=context) ,
- 'move_history_ids': [],
- 'date': (datetime.strptime(move.date, '%Y-%m-%d %H:%M:%S') + relativedelta(days=delay or 0)).strftime('%Y-%m-%d'),
- 'move_history_ids2': []}
- )
- move_obj.write(cr, uid, [move.id], {
- 'move_dest_id': new_id,
- 'move_history_ids': [(4, new_id)]
- })
- new_moves.append(self.browse(cr, uid, [new_id])[0])
- if pickid:
- wf_service.trg_validate(uid, 'stock.picking', pickid, 'button_confirm', cr)
- if new_moves:
- create_chained_picking(self, cr, uid, new_moves, context)
- create_chained_picking(self, cr, uid, moves, context)
+ self.create_chained_picking(cr, uid, moves, context)
return []
def action_assign(self, cr, uid, ids, *args):
@@ -2112,6 +2115,8 @@ class stock_move(osv.osv):
prodlot_id = partial_datas and partial_datas.get('move%s_prodlot_id' % (move.id), False)
if prodlot_id:
self.write(cr, uid, [move.id], {'prodlot_id': prodlot_id}, context=context)
+ if move.state not in ('confirmed','done'):
+ self.action_confirm(cr, uid, move_ids, context=context)
self.write(cr, uid, move_ids, {'state': 'done', 'date_planned': time.strftime('%Y-%m-%d %H:%M:%S')}, context=context)
for id in move_ids:
diff --git a/addons/stock/wizard/stock_return_picking.py b/addons/stock/wizard/stock_return_picking.py
index d71e6361b32..918c519a1e4 100644
--- a/addons/stock/wizard/stock_return_picking.py
+++ b/addons/stock/wizard/stock_return_picking.py
@@ -53,10 +53,8 @@ class stock_return_picking(osv.osv_memory):
res['invoice_state'] = 'none'
for line in pick.move_lines:
return_id = 'return%s'%(line.id)
- return_price = 'return_price%s'%(line.id)
if return_id in fields:
res[return_id] = line.product_qty
- res[return_price]=line.price_unit
return res
def view_init(self, cr, uid, fields_list, context=None):
@@ -88,11 +86,8 @@ class stock_return_picking(osv.osv_memory):
valid_lines += 1
if 'return%s'%(m.id) not in self._columns:
self._columns['return%s'%(m.id)] = fields.float(string=m.name, required=True)
- if 'return_price%s'%(m.id) not in self._columns:
- self._columns['return_price%s'%(m.id)] = fields.float(string=m.name, required=True)
if 'invoice_state' not in self._columns:
self._columns['invoice_state'] = fields.selection([('2binvoiced', 'To be refunded/invoiced'), ('none', 'No invoicing')], string='Invoicing', required=True)
-
if not valid_lines:
raise osv.except_osv(_('Warning !'), _("There are no products to return (only lines in Done state and not fully returned yet can be returned)!"))
return res
@@ -126,10 +121,6 @@ class stock_return_picking(osv.osv_memory):
if m.state=='done' and quantity > return_history[m.id]:
arch_lst.append('\n' % (m.id,))
res['fields']['return%s' % m.id]={'string':m.name, 'type':'float', 'required':True}
-
- if m.product_id.cost_method == 'average' and pick.type == 'in':
- arch_lst.append('\n' % (m.id,))
- res['fields']['return_price%s' % m.id]={'string':'Price', 'type':'float', 'required':True}
res.setdefault('returns', []).append(m.id)
arch_lst.append('\n')
res['fields']['invoice_state']={'string':_('Invoicing'), 'type':'selection','required':True, 'selection':[('2binvoiced', _('To be refunded/invoiced')), ('none', _('No invoicing'))]}
@@ -142,7 +133,7 @@ class stock_return_picking(osv.osv_memory):
return res
def create_returns(self, cr, uid, ids, context=None):
- """
+ """
Creates return picking.
@param self: The object pointer.
@param cr: A database cursor
@@ -152,13 +143,13 @@ class stock_return_picking(osv.osv_memory):
@return: A dictionary which of fields with values.
"""
if context is None:
- context = {}
+ context = {}
record_id = context and context.get('active_id', False) or False
move_obj = self.pool.get('stock.move')
pick_obj = self.pool.get('stock.picking')
uom_obj = self.pool.get('product.uom')
wf_service = netsvc.LocalService("workflow")
-
+
pick = pick_obj.browse(cr, uid, record_id, context=context)
data = self.read(cr, uid, ids[0])
new_picking = None
@@ -180,7 +171,6 @@ class stock_return_picking(osv.osv_memory):
new_location=move.location_dest_id.id
if move.state=='done':
new_qty = data['return%s' % move.id]
- price_unit = data['return_price%s' % move.id]
returned_qty = move.product_qty
for rec in move.move_history_ids2:
@@ -188,6 +178,7 @@ class stock_return_picking(osv.osv_memory):
if returned_qty != new_qty:
set_invoice_state_to_none = False
+
if new_qty:
returned_lines += 1
new_move=move_obj.copy(cr, uid, move.id, {
@@ -196,8 +187,7 @@ class stock_return_picking(osv.osv_memory):
new_qty, move.product_uos.id),
'picking_id':new_picking, 'state':'draft',
'location_id':new_location, 'location_dest_id':move.location_id.id,
- 'date':date_cur,
- 'price_unit':price_unit})
+ 'date':date_cur,})
move_obj.write(cr, uid, [move.id], {'move_history_ids2':[(4,new_move)]})
if not returned_lines: