From 92929ec6a7d4c31f353bb5c4fd5452452df8670b Mon Sep 17 00:00:00 2001 From: Dhaval Panchal Date: Wed, 20 Jul 2016 13:02:57 +0530 Subject: [PATCH] [IMP] account/stock_account: Add a clickable history on journal entries chatters Purpose: In a perpetual inventory mode, it is not possible to reach the picking from the journal entry view because the ref field is not clickable. I propose to show a chatter to get the history (which doc created the move) and being able to go to the move from the chatter. Specification: In journal entry view add chatter and generate message(clickable) that link to its Origin (i.e Supplier Invoice , Customer Invoice, Picking in case of Perpetual Inventory) --- addons/account/models/account_invoice.py | 3 +++ addons/account/models/account_move.py | 1 + addons/account/views/account_view.xml | 4 ++++ addons/stock_account/models/stock.py | 3 +++ 4 files changed, 11 insertions(+) diff --git a/addons/account/models/account_invoice.py b/addons/account/models/account_invoice.py index 8028355d76e..c2719b9e21b 100644 --- a/addons/account/models/account_invoice.py +++ b/addons/account/models/account_invoice.py @@ -894,6 +894,9 @@ class AccountInvoice(models.Model): 'move_name': move.name, } inv.with_context(ctx).write(vals) + move.message_post_with_view('mail.message_origin_link', + values={'self': move, 'origin': inv}, + subtype_id=self.env.ref('mail.mt_note').id) return True @api.multi diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index 8d11a5bd9bd..4ecf315dedf 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -18,6 +18,7 @@ from lxml import etree class AccountMove(models.Model): _name = "account.move" _description = "Account Entry" + _inherit = ['mail.thread'] _order = 'date desc, id desc' @api.multi diff --git a/addons/account/views/account_view.xml b/addons/account/views/account_view.xml index 7ff88c73014..a5f343fc6b5 100644 --- a/addons/account/views/account_view.xml +++ b/addons/account/views/account_view.xml @@ -1349,6 +1349,10 @@ +
+ + +
diff --git a/addons/stock_account/models/stock.py b/addons/stock_account/models/stock.py index 634c3cfbdd0..a48fc4a6a9d 100644 --- a/addons/stock_account/models/stock.py +++ b/addons/stock_account/models/stock.py @@ -137,6 +137,9 @@ class StockQuant(models.Model): 'date': date, 'ref': move.picking_id.name}) new_account_move.post() + new_account_move.message_post_with_view('mail.message_origin_link', + values={'self': new_account_move, 'origin': move.picking_id}, + subtype_id=self.env.ref('mail.mt_note').id) def _quant_create_from_move(self, qty, move, lot_id=False, owner_id=False, src_package_id=False, dest_package_id=False, force_location_from=False, force_location_to=False): quant = super(StockQuant, self)._quant_create_from_move(qty, move, lot_id=lot_id, owner_id=owner_id, src_package_id=src_package_id, dest_package_id=dest_package_id, force_location_from=force_location_from, force_location_to=force_location_to)