WMS usability (part) + WMS Merge PO
bzr revid: jke@openerp.com-20131002134242-w76s6p03p66wbk16
This commit is contained in:
parent
3c047b2332
commit
f13f1ebbce
|
@ -88,16 +88,16 @@
|
|||
</record>
|
||||
|
||||
<!--
|
||||
TODO-JKE
|
||||
|
||||
<record id="do_view_pickings" model="ir.actions.act_window">
|
||||
<field name="name">Pickings for Groups </field>
|
||||
<field name="res_model">stock.move</field>
|
||||
<field name="res_model">stock.picking</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="domain">[('group_id','=',active_id)]</field>
|
||||
</record>
|
||||
-->
|
||||
<button name="%(do_view_pickings)d" string="View all procurements" type="action" />
|
||||
-->
|
||||
|
||||
|
||||
<record id="procurement_group_form_view" model="ir.ui.view">
|
||||
<field name="name">procurement.group.form</field>
|
||||
|
@ -107,7 +107,6 @@
|
|||
<sheet>
|
||||
<div class="oe_right oe_button_box">
|
||||
<button name="%(do_view_procurements)d" string="View all procurements" type="action" />
|
||||
|
||||
</div>
|
||||
<group>
|
||||
<field name="name"/>
|
||||
|
|
|
@ -832,6 +832,7 @@ class purchase_order(osv.osv):
|
|||
@return: new purchase order id
|
||||
|
||||
"""
|
||||
|
||||
#TOFIX: merged order line should be unlink
|
||||
def make_key(br, fields):
|
||||
list_key = []
|
||||
|
@ -854,14 +855,15 @@ class purchase_order(osv.osv):
|
|||
context = {}
|
||||
|
||||
# Compute what the new orders should contain
|
||||
|
||||
new_orders = {}
|
||||
|
||||
order_lines_to_move = []
|
||||
for porder in [order for order in self.browse(cr, uid, ids, context=context) if order.state == 'draft']:
|
||||
order_key = make_key(porder, ('partner_id', 'location_id', 'pricelist_id'))
|
||||
new_order = new_orders.setdefault(order_key, ({}, []))
|
||||
new_order[1].append(porder.id)
|
||||
order_infos = new_order[0]
|
||||
|
||||
if not order_infos:
|
||||
order_infos.update({
|
||||
'origin': porder.origin,
|
||||
|
@ -884,22 +886,9 @@ class purchase_order(osv.osv):
|
|||
if porder.origin:
|
||||
order_infos['origin'] = (order_infos['origin'] or '') + ' ' + porder.origin
|
||||
|
||||
|
||||
for order_line in porder.order_line:
|
||||
line_key = make_key(order_line, ('name', 'date_planned', 'taxes_id', 'price_unit', 'product_id', 'move_dest_id', 'account_analytic_id'))
|
||||
o_line = order_infos['order_line'].setdefault(line_key, {})
|
||||
if o_line:
|
||||
# merge the line with an existing line
|
||||
o_line['product_qty'] += order_line.product_qty * order_line.product_uom.factor / o_line['uom_factor']
|
||||
else:
|
||||
# append a new "standalone" line
|
||||
for field in ('product_qty', 'product_uom'):
|
||||
field_val = getattr(order_line, field)
|
||||
if isinstance(field_val, browse_record):
|
||||
field_val = field_val.id
|
||||
o_line[field] = field_val
|
||||
o_line['uom_factor'] = order_line.product_uom and order_line.product_uom.factor or 1.0
|
||||
|
||||
|
||||
order_lines_to_move += [order_line.id]
|
||||
|
||||
allorders = []
|
||||
orders_info = {}
|
||||
|
@ -913,7 +902,7 @@ class purchase_order(osv.osv):
|
|||
for key, value in order_data['order_line'].iteritems():
|
||||
del value['uom_factor']
|
||||
value.update(dict(key))
|
||||
order_data['order_line'] = [(0, 0, value) for value in order_data['order_line'].itervalues()]
|
||||
order_data['order_line'] = [(6, 0, order_lines_to_move)]
|
||||
|
||||
# create the new order
|
||||
context.update({'mail_create_nolog': True})
|
||||
|
@ -926,6 +915,7 @@ class purchase_order(osv.osv):
|
|||
for old_id in old_ids:
|
||||
self.redirect_workflow(cr, uid, [(old_id, neworder_id)])
|
||||
self.signal_purchase_cancel(cr, uid, [old_id]) # TODO Is it necessary to interleave the calls?
|
||||
|
||||
return orders_info
|
||||
|
||||
|
||||
|
|
|
@ -66,12 +66,7 @@ class purchase_order_group(osv.osv_memory):
|
|||
id = mod_obj.read(cr, uid, result, ['res_id'])
|
||||
|
||||
allorders = order_obj.do_merge(cr, uid, context.get('active_ids',[]), context)
|
||||
for new_order in allorders:
|
||||
proc_ids = proc_obj.search(cr, uid, [('purchase_id', 'in', allorders[new_order])], context=context)
|
||||
for proc in proc_obj.browse(cr, uid, proc_ids, context=context):
|
||||
if proc.purchase_id:
|
||||
proc_obj.write(cr, uid, [proc.id], {'purchase_id': new_order}, context)
|
||||
|
||||
|
||||
return {
|
||||
'domain': "[('id','in', [" + ','.join(map(str, allorders.keys())) + "])]",
|
||||
'name': _('Purchase Orders'),
|
||||
|
|
|
@ -33,9 +33,10 @@ This module adds the picking wave option in warehouse management.
|
|||
'data': ['security/ir.model.access.csv',
|
||||
'stock_picking_wave_view.xml',
|
||||
'stock_picking_wave_sequence.xml',
|
||||
'wizard/picking_to_wave_view.xml'],
|
||||
'wizard/picking_to_wave_view.xml',
|
||||
],
|
||||
'demo': [
|
||||
'stock_picking_wave_data.xml',
|
||||
'stock_picking_wave_demo.xml',
|
||||
],
|
||||
|
||||
'installable': True,
|
||||
|
|
Loading…
Reference in New Issue