diff --git a/stock_account_usability/__init__.py b/stock_account_usability/__init__.py index e69de29..0650744 100644 --- a/stock_account_usability/__init__.py +++ b/stock_account_usability/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/stock_account_usability/__manifest__.py b/stock_account_usability/__manifest__.py index e9fb4ff..b080d46 100644 --- a/stock_account_usability/__manifest__.py +++ b/stock_account_usability/__manifest__.py @@ -22,6 +22,9 @@ This module has been written by Alexis de Lattre from Akretion +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import api, models + + +class ProductTemplate(models.Model): + _inherit = 'product.template' + + def action_open_stock_valuation_layer(self): + self.ensure_one() + ppo = self.env['product.product'] + if len(self.product_variant_ids) == 1: + action = ppo._get_stock_valuation_layer_action(self.product_variant_ids.id) + else: + action = ppo._get_stock_valuation_layer_action() + action["domain"] = [('product_id', 'in', self.product_variant_ids.ids)] + return action + + +class ProductProduct(models.Model): + _inherit = 'product.product' + + def action_open_stock_valuation_layer(self): + self.ensure_one() + return self._get_stock_valuation_layer_action(self.id) + + @api.model + def _get_stock_valuation_layer_action(self, product_id=None): + action = self.env["ir.actions.actions"]._for_xml_id( + "stock_account.stock_valuation_layer_action") + if product_id: + action["context"] = { + 'search_default_product_id': product_id, + 'search_default_group_by_product_id': 1, + } + return action diff --git a/stock_account_usability/views/product.xml b/stock_account_usability/views/product.xml new file mode 100644 index 0000000..b6c3361 --- /dev/null +++ b/stock_account_usability/views/product.xml @@ -0,0 +1,54 @@ + + + + + + + + + product.template + + +
+ +
+
+
+ + + + product.product + + +
+ +
+
+
+ +