From 0f7d2d7cf7aaf8f3349c9733e970f9ae8e2b90b4 Mon Sep 17 00:00:00 2001
From: Pratima Gupta
Date: Tue, 5 Sep 2017 12:47:34 +0530
Subject: [PATCH] [IMP] stock_account: add valuation stat button for products
---
addons/stock_account/models/product.py | 26 +++++++++++++++++++
addons/stock_account/views/product_views.xml | 22 ++++++++++++++++
.../views/stock_account_views.xml | 5 ++--
3 files changed, 50 insertions(+), 3 deletions(-)
diff --git a/addons/stock_account/models/product.py b/addons/stock_account/models/product.py
index d8f631e975e..f306bc5606f 100644
--- a/addons/stock_account/models/product.py
+++ b/addons/stock_account/models/product.py
@@ -74,6 +74,19 @@ class ProductTemplate(models.Model):
})
return accounts
+ @api.multi
+ def action_open_product_moves(self):
+ self.ensure_one()
+ action = self.env.ref('stock_account.stock_move_valuation_action').read()[0]
+ action['domain'] = [('product_id.product_tmpl_id', '=', self.id)]
+ action['context'] = {
+ 'search_default_outgoing': True,
+ 'search_default_incoming': True,
+ 'search_default_done': True,
+ 'is_avg': self.cost_method == 'average',
+ }
+ return action
+
@api.multi
def get_product_accounts(self, fiscal_pos=None):
""" Add the stock journal related to product to the result of super()
@@ -156,6 +169,19 @@ class ProductProduct(models.Model):
moves = StockMove.search(domain)
product.stock_value = sum(moves.mapped('value'))
+ @api.multi
+ def action_open_product_moves(self):
+ self.ensure_one()
+ action = self.env.ref('stock_account.stock_move_valuation_action').read()[0]
+ action['domain'] = [('product_id', '=', self.id)]
+ action['context'] = {
+ 'search_default_outgoing': True,
+ 'search_default_incoming': True,
+ 'search_default_done': True,
+ 'is_avg': self.cost_method == 'average',
+ }
+ return action
+
class ProductCategory(models.Model):
_inherit = 'product.category'
diff --git a/addons/stock_account/views/product_views.xml b/addons/stock_account/views/product_views.xml
index 7e264eeb2d4..d3da286241b 100644
--- a/addons/stock_account/views/product_views.xml
+++ b/addons/stock_account/views/product_views.xml
@@ -115,5 +115,27 @@
+
+
+ product.product
+ product.product
+
+
+
+
+
+
+
+
+
+ product.template
+ product.template
+
+
+
+
+
+
+
diff --git a/addons/stock_account/views/stock_account_views.xml b/addons/stock_account/views/stock_account_views.xml
index 7579cea5b45..a8a0dc723af 100644
--- a/addons/stock_account/views/stock_account_views.xml
+++ b/addons/stock_account/views/stock_account_views.xml
@@ -68,13 +68,12 @@
-
-
+
+
-
Stock Moves
stock.move