From 452cc399c5d002e10f0b822c74d7f349c88d092a Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Mon, 12 Apr 2021 21:29:23 +0200 Subject: [PATCH] stock_usability: add button to access stock moves before button to access product moves, because stock moves are more important than product moves --- stock_usability/models/__init__.py | 2 +- stock_usability/models/product.py | 31 ++++++++++++++++++++ stock_usability/models/product_template.py | 15 ---------- stock_usability/views/product.xml | 33 ++++++++++++++++++++++ 4 files changed, 65 insertions(+), 16 deletions(-) create mode 100644 stock_usability/models/product.py delete mode 100644 stock_usability/models/product_template.py diff --git a/stock_usability/models/__init__.py b/stock_usability/models/__init__.py index b6d12d1..494e881 100644 --- a/stock_usability/models/__init__.py +++ b/stock_usability/models/__init__.py @@ -5,5 +5,5 @@ from . import stock_warehouse_orderpoint from . import stock_quant from . import procurement_group from . import procurement_scheduler_log -from . import product_template +from . import product from . import res_partner diff --git a/stock_usability/models/product.py b/stock_usability/models/product.py new file mode 100644 index 0000000..14d1046 --- /dev/null +++ b/stock_usability/models/product.py @@ -0,0 +1,31 @@ +# Copyright 2016-2021 Akretion France +# @author: Alexis de Lattre +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class ProductTemplate(models.Model): + _inherit = 'product.template' + + tracking = fields.Selection(tracking=True) + sale_delay = fields.Float(tracking=True) + # the 'stock' module adds 'product' in type... + # but forgets to make it the default + type = fields.Selection(default='product') + + def action_view_stock_move(self): + action = self.env.ref('stock.stock_move_action').read()[0] + action['domain'] = [('product_id.product_tmpl_id', 'in', self.ids)] + action['context'] = {'search_default_done': True} + return action + + +class ProductProduct(models.Model): + _inherit = 'product.product' + + def action_view_stock_move(self): + action = self.env.ref('stock.stock_move_action').read()[0] + action['domain'] = [('product_id', 'in', self.ids)] + action['context'] = {'search_default_done': True} + return action diff --git a/stock_usability/models/product_template.py b/stock_usability/models/product_template.py deleted file mode 100644 index 0d9c5a2..0000000 --- a/stock_usability/models/product_template.py +++ /dev/null @@ -1,15 +0,0 @@ -# Copyright 2016-2020 Akretion France -# @author: Alexis de Lattre -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). - -from odoo import fields, models - - -class ProductTemplate(models.Model): - _inherit = 'product.template' - - tracking = fields.Selection(tracking=True) - sale_delay = fields.Float(tracking=True) - # the 'stock' module adds 'product' in type... - # but forgets to make it the default - type = fields.Selection(default='product') diff --git a/stock_usability/views/product.xml b/stock_usability/views/product.xml index 1f38e11..7e4c715 100644 --- a/stock_usability/views/product.xml +++ b/stock_usability/views/product.xml @@ -19,5 +19,38 @@ + + stock_usability.product.template.form + product.template + + + + + + + + stock_usability.product.product.form + product.product + + + + +