[12.0][IMP] stock_orderpoint_move_link: View transfers on orderpoint

This commit is contained in:
hveficent
2019-04-24 13:48:16 +02:00
committed by Guewen Baconnier
parent e2761eca43
commit 4c4da239f1
10 changed files with 57 additions and 9 deletions

View File

@@ -56,6 +56,7 @@ Contributors
* Jordi Ballester Alomar <jordi.ballester@eficent.com>
* Kitti Upariphutthiphong <kittiu@ecosoft.co.th>
* Héctor Villarreal Ortega <hector.villarreal@eficent.com>
Maintainers
~~~~~~~~~~~

View File

@@ -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

View File

@@ -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).
{

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -1,2 +1,3 @@
* Jordi Ballester Alomar <jordi.ballester@eficent.com>
* Kitti Upariphutthiphong <kittiu@ecosoft.co.th>
* Héctor Villarreal Ortega <hector.villarreal@eficent.com>

View File

@@ -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)

View File

@@ -25,4 +25,20 @@
</field>
</record>
<record id="view_warehouse_orderpoint_move_form" model="ir.ui.view">
<field name="name">stock.warehouse.orderpoint.move.form</field>
<field name="model">stock.warehouse.orderpoint</field>
<field name="inherit_id" ref="stock.view_warehouse_orderpoint_form"/>
<field name="arch" type="xml">
<div name="button_box" position="inside">
<button type="object"
name="action_view_stock_picking"
class="oe_stat_button"
string="Transfers"
icon="fa-arrows-h">
</button>
</div>
</field>
</record>
</odoo>