diff options
| author | ptr <ptr@openerp.com> | 2015-02-03 16:04:21 +0530 |
|---|---|---|
| committer | David Monjoie <dmo@odoo.com> | 2015-06-30 15:05:31 +0200 |
| commit | 7cf73f5314ddc9c573d7b4846a773395be3dfebb (patch) | |
| tree | 68a449b37510a37b8ff9bf63de0ab636eacfa0ae | |
| parent | 1e446f13a7455f5ea61961082e7d3438e8e038a4 (diff) | |
[IMP] purchase: generate so to po line, broadcast message in chatter
| -rw-r--r-- | addons/purchase/purchase.py | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index 914d825efb5..77edbc07196 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -1519,20 +1519,34 @@ class procurement_order(osv.osv): qty = uom_obj._compute_qty_obj(cr, uid, proc.product_uom, proc.product_qty, uom_id) if lines_to_update.get(po_line): - lines_to_update[po_line] += [(proc.id, qty)] + lines_to_update[po_line] += [(proc, qty)] else: - lines_to_update[po_line] = [(proc.id, qty)] + lines_to_update[po_line] = [(proc, qty)] else: procs_to_create.append(proc) procs = [] + + # FIXME: these are not real tracking values, it should be fixed if tracking values for one2many + # are managed + def format_message(message_description, tracked_values): + message = '' + if message_description: + message = '<span>%s</span>' % message_description + for name, values in tracked_values.iteritems(): + message += '<div> • <b>%s</b>: ' % name + message += '%s</div>' % values + return message + # Update the quantities of the lines that need to for line in lines_to_update.keys(): tot_qty = 0 for proc, qty in lines_to_update[line]: tot_qty += qty - self.message_post(cr, uid, proc, body=_("Quantity added in existing Purchase Order Line"), context=context) - line_values += [(1, line.id, {'product_qty': line.product_qty + tot_qty, 'procurement_ids': [(4, x[0]) for x in lines_to_update[line]]})] + self.message_post(cr, uid, proc.id, body=_("Quantity added in existing Purchase Order Line"), context=context) + msg = format_message(_('Quantity added in existing Purchase Order Line'), {'Product': proc.product_id.name, 'Quantity': proc.product_qty, 'Procurement': proc.origin}) + po_obj.message_post(cr, uid, [add_purchase], body=msg, context=context) + line_values += [(1, line.id, {'product_qty': line.product_qty + tot_qty, 'procurement_ids': [(4, x[0].id) for x in lines_to_update[line]]})] # Create lines for which no line exists yet if procs_to_create: @@ -1542,6 +1556,8 @@ class procurement_order(osv.osv): line_values += [(0, 0, value_lines[x]) for x in value_lines.keys()] for proc in procs_to_create: self.message_post(cr, uid, [proc.id], body=_("Purchase line created and linked to an existing Purchase Order"), context=context) + msg = format_message(_('Purchase order line added'), {'Product': proc.product_id.name, 'Quantity': proc.product_qty, 'Procurement': proc.origin}) + po_obj.message_post(cr, uid, [add_purchase], body=msg, context=context) po_obj.write(cr, uid, [add_purchase], {'order_line': line_values},context=context) |
