From 4c4da239f1aa6b4fb105236883bda2a6b7638a8e Mon Sep 17 00:00:00 2001 From: hveficent Date: Wed, 24 Apr 2019 13:48:16 +0200 Subject: [PATCH] [12.0][IMP] stock_orderpoint_move_link: View transfers on orderpoint --- stock_orderpoint_move_link/README.rst | 1 + stock_orderpoint_move_link/__init__.py | 2 +- stock_orderpoint_move_link/__manifest__.py | 2 +- stock_orderpoint_move_link/models/__init__.py | 3 ++- stock_orderpoint_move_link/models/stock.py | 2 +- .../models/stock_move.py | 2 +- .../models/stock_warehouse_orderpoint.py | 19 +++++++++++++++++++ .../readme/CONTRIBUTORS.rst | 1 + .../tests/test_stock_orderpoint_move_link.py | 18 ++++++++++++++---- .../views/stock_move_views.xml | 16 ++++++++++++++++ 10 files changed, 57 insertions(+), 9 deletions(-) create mode 100644 stock_orderpoint_move_link/models/stock_warehouse_orderpoint.py diff --git a/stock_orderpoint_move_link/README.rst b/stock_orderpoint_move_link/README.rst index 7629d0122..a8df3129f 100644 --- a/stock_orderpoint_move_link/README.rst +++ b/stock_orderpoint_move_link/README.rst @@ -56,6 +56,7 @@ Contributors * Jordi Ballester Alomar * Kitti Upariphutthiphong +* Héctor Villarreal Ortega Maintainers ~~~~~~~~~~~ diff --git a/stock_orderpoint_move_link/__init__.py b/stock_orderpoint_move_link/__init__.py index dc045bf6a..2fb88af91 100644 --- a/stock_orderpoint_move_link/__init__.py +++ b/stock_orderpoint_move_link/__init__.py @@ -1,3 +1,3 @@ -# Copyright 2017 Eficent Business and IT Consulting Services, S.L. +# Copyright 2019 Eficent Business and IT Consulting Services, S.L. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from . import models diff --git a/stock_orderpoint_move_link/__manifest__.py b/stock_orderpoint_move_link/__manifest__.py index f537b9752..85a39fc02 100644 --- a/stock_orderpoint_move_link/__manifest__.py +++ b/stock_orderpoint_move_link/__manifest__.py @@ -1,4 +1,4 @@ -# Copyright 2017 Eficent Business and IT Consulting Services, S.L. +# Copyright 2019 Eficent Business and IT Consulting Services, S.L. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). { diff --git a/stock_orderpoint_move_link/models/__init__.py b/stock_orderpoint_move_link/models/__init__.py index 197db3d45..7f2c64d3c 100644 --- a/stock_orderpoint_move_link/models/__init__.py +++ b/stock_orderpoint_move_link/models/__init__.py @@ -1,4 +1,5 @@ -# Copyright 2017 Eficent Business and IT Consulting Services, S.L. +# Copyright 2019 Eficent Business and IT Consulting Services, S.L. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from . import stock from . import stock_move +from . import stock_warehouse_orderpoint diff --git a/stock_orderpoint_move_link/models/stock.py b/stock_orderpoint_move_link/models/stock.py index b1706a75f..937fdf2c8 100644 --- a/stock_orderpoint_move_link/models/stock.py +++ b/stock_orderpoint_move_link/models/stock.py @@ -1,4 +1,4 @@ -# Copyright 2017 Eficent Business, IT Consulting Services, S.L., Ecosoft +# Copyright 2019 Eficent Business, IT Consulting Services, S.L., Ecosoft # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from odoo import models diff --git a/stock_orderpoint_move_link/models/stock_move.py b/stock_orderpoint_move_link/models/stock_move.py index 7c5f8f309..29c989783 100644 --- a/stock_orderpoint_move_link/models/stock_move.py +++ b/stock_orderpoint_move_link/models/stock_move.py @@ -1,4 +1,4 @@ -# Copyright 2017 Eficent Business, IT Consulting Services, S.L. +# Copyright 2019 Eficent Business, IT Consulting Services, S.L. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from odoo import fields, models diff --git a/stock_orderpoint_move_link/models/stock_warehouse_orderpoint.py b/stock_orderpoint_move_link/models/stock_warehouse_orderpoint.py new file mode 100644 index 000000000..4d0d4c4fe --- /dev/null +++ b/stock_orderpoint_move_link/models/stock_warehouse_orderpoint.py @@ -0,0 +1,19 @@ +# Copyright 2019 Eficent Business and IT Consulting Services S.L. +# (http://www.eficent.com) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from odoo import api, models + + +class StockWarehouseOrderpoint(models.Model): + _inherit = 'stock.warehouse.orderpoint' + + @api.multi + def action_view_stock_picking(self): + action = self.env.ref('stock.action_picking_tree_all') + result = action.read()[0] + result['context'] = {} + picking_ids = self.env['stock.move'].search( + [('orderpoint_ids', 'in', self.id)]).mapped('picking_id') + result['domain'] = "[('id','in',%s)]" % picking_ids.ids + return result diff --git a/stock_orderpoint_move_link/readme/CONTRIBUTORS.rst b/stock_orderpoint_move_link/readme/CONTRIBUTORS.rst index 7ac2aa759..7906762c1 100644 --- a/stock_orderpoint_move_link/readme/CONTRIBUTORS.rst +++ b/stock_orderpoint_move_link/readme/CONTRIBUTORS.rst @@ -1,2 +1,3 @@ * Jordi Ballester Alomar * Kitti Upariphutthiphong +* Héctor Villarreal Ortega diff --git a/stock_orderpoint_move_link/tests/test_stock_orderpoint_move_link.py b/stock_orderpoint_move_link/tests/test_stock_orderpoint_move_link.py index d479712da..e50166db0 100644 --- a/stock_orderpoint_move_link/tests/test_stock_orderpoint_move_link.py +++ b/stock_orderpoint_move_link/tests/test_stock_orderpoint_move_link.py @@ -1,6 +1,6 @@ # Copyright 2019 Eficent Business and IT Consulting Services S.L. # License LGPL-3.0 or later (http://www.gnu.org/licenses/agpl). - +import ast from odoo.tests.common import SavepointCase @@ -16,6 +16,7 @@ class TestStockOrderpointMoveLink(SavepointCase): cls.route_obj = cls.env['stock.location.route'] cls.group_obj = cls.env['procurement.group'] cls.move_obj = cls.env['stock.move'] + cls.picking_obj = cls.env['stock.picking'] cls.warehouse = cls.env.ref('stock.warehouse0') cls.stock_loc = cls.env.ref('stock.stock_location_stock') @@ -26,7 +27,7 @@ class TestStockOrderpointMoveLink(SavepointCase): 'usage': 'internal', 'location_id': cls.warehouse.view_location_id.id, }) - test_route = cls.route_obj.create({ + cls.test_route = cls.route_obj.create({ 'name': 'Stock -> Test 1', 'product_selectable': True, 'rule_ids': [(0, 0, { @@ -45,7 +46,7 @@ class TestStockOrderpointMoveLink(SavepointCase): 'usage': 'internal', 'location_id': cls.warehouse.view_location_id.id, }) - test_route_2 = cls.route_obj.create({ + cls.test_route_2 = cls.route_obj.create({ 'name': 'Test 1 -> Test 2', 'product_selectable': True, 'rule_ids': [(0, 0, { @@ -61,7 +62,7 @@ class TestStockOrderpointMoveLink(SavepointCase): }) # Prepare Products: - routes = test_route_2 + test_route + routes = cls.test_route_2 + cls.test_route cls.product = cls.product_obj.create({ 'name': 'Test Product', 'route_ids': [(6, 0, routes.ids)], @@ -83,3 +84,12 @@ class TestStockOrderpointMoveLink(SavepointCase): move = self.move_obj.search([ ('orderpoint_ids', '=', self.orderpoint_need_loc.id)]) self.assertTrue(len(move), 2) + + def test_02_stock_orderpoint_move_link_action_view(self): + sp_orderpoint = self.move_obj.search( + [('orderpoint_ids', 'in', self.orderpoint_need_loc.id)]).mapped( + 'picking_id') + result = self.orderpoint_need_loc.action_view_stock_picking() + sp_action = self.picking_obj.search( + ast.literal_eval(result['domain'])) + self.assertEquals(sp_orderpoint, sp_action) diff --git a/stock_orderpoint_move_link/views/stock_move_views.xml b/stock_orderpoint_move_link/views/stock_move_views.xml index 7975bdedc..82eae7fb5 100644 --- a/stock_orderpoint_move_link/views/stock_move_views.xml +++ b/stock_orderpoint_move_link/views/stock_move_views.xml @@ -25,4 +25,20 @@ + + stock.warehouse.orderpoint.move.form + stock.warehouse.orderpoint + + +
+ +
+
+
+