[IMP] stock misc

bzr revid: fp@openerp.com-20121010194710-m2wkdx5pvknk0hno
This commit is contained in:
Fabien Pinckaers
2012-10-10 21:47:10 +02:00
3 changed files with 12 additions and 20 deletions
+7 -15
View File
@@ -1767,7 +1767,7 @@ class stock_move(osv.osv):
location_id = property_out and property_out.id or False
else:
location_xml_id = False
if picking_type == 'in':
if picking_type in ('in', 'internal'):
location_xml_id = 'stock_location_stock'
elif picking_type == 'out':
location_xml_id = 'stock_location_customers'
@@ -1798,7 +1798,7 @@ class stock_move(osv.osv):
location_xml_id = False
if picking_type == 'in':
location_xml_id = 'stock_location_suppliers'
elif picking_type == 'out':
elif picking_type in ('out', 'internal'):
location_xml_id = 'stock_location_stock'
if location_xml_id:
location_model, location_id = mod_obj.get_object_reference(cr, uid, 'stock', location_xml_id)
@@ -2011,25 +2011,17 @@ class stock_move(osv.osv):
@return: Dictionary of values
"""
mod_obj = self.pool.get('ir.model.data')
location_source_id = False
location_dest_id = False
location_source_id = 'stock_location_stock'
location_dest_id = 'stock_location_stock'
if type == 'in':
location_source_id = 'stock_location_suppliers'
location_dest_id = 'stock_location_stock'
elif type == 'out':
location_source_id = 'stock_location_stock'
location_dest_id = 'stock_location_customers'
if location_source_id:
try:
location_model, location_source_id = mod_obj.get_object_reference(cr, uid, 'stock', location_source_id)
except ValueError, e:
location_source_id = False
if location_dest_id:
try:
location_model, location_dest_id = mod_obj.get_object_reference(cr, uid, 'stock', location_dest_id)
except ValueError, e:
location_dest_id = False
return {'value':{'location_id': location_source_id, 'location_dest_id': location_dest_id}}
source_location = mod_obj.get_object_reference(cr, uid, 'stock', location_source_id)
dest_location = mod_obj.get_object_reference(cr, uid, 'stock', location_dest_id)
return {'value':{'location_id': source_location and source_location[1] or False, 'location_dest_id': dest_location and dest_location[1] or False}}
def onchange_date(self, cr, uid, ids, date, date_expected, context=None):
""" On change of Scheduled Date gives a Move date.
+2 -2
View File
@@ -777,7 +777,7 @@
</group>
<notebook>
<page string="Products">
<field name="move_lines" context="{'address_in_id': partner_id, 'form_view_ref':'view_move_picking_form', 'tree_view_ref':'view_move_picking_tree'}"/>
<field name="move_lines" context="{'address_in_id': partner_id, 'form_view_ref':'view_move_picking_form', 'tree_view_ref':'view_move_picking_tree', 'picking_type': 'internal'}"/>
<field name="note" placeholder="Add an internal note..." class="oe_inline"/>
</page>
<page string="Additional Info">
@@ -1416,7 +1416,7 @@
<field name="act_window_id" ref="action_move_form2"/>
</record>
<menuitem action="action_move_form2" id="menu_action_move_form2" parent="menu_traceability" sequence="3"/>
<menuitem action="action_move_form2" id="menu_action_move_form2" parent="menu_traceability" sequence="3" groups="stock.group_locations"/>
<!--
Reception Picking (By Stock Move)
+3 -3
View File
@@ -72,7 +72,7 @@ class stock_return_picking(osv.osv_memory):
res.update({'invoice_state': 'none'})
return_history = self.get_return_history(cr, uid, record_id, context)
for line in pick.move_lines:
qty = line.product_qty - return_history[line.id]
qty = line.product_qty - return_history.get(line.id, 0)
if qty > 0:
result1.append({'product_id': line.product_id.id, 'quantity': qty,'move_id':line.id})
if 'product_return_moves' in fields:
@@ -100,8 +100,8 @@ class stock_return_picking(osv.osv_memory):
valid_lines = 0
return_history = self.get_return_history(cr, uid, record_id, context)
for m in pick.move_lines:
if m.product_qty * m.product_uom.factor > return_history[m.id]:
valid_lines += 1
if m.state == 'done' and m.product_qty * m.product_uom.factor > return_history.get(m.id, 0):
valid_lines += 1
if not valid_lines:
raise osv.except_osv(_('Warning!'), _("No products to return (only lines in Done state and not fully returned yet can be returned)!"))
return res