odoo-addon-stock-request 16.0.1.0.0.3__py3-none-any.whl → 17.0.1.0.0.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- odoo/addons/stock_request/README.rst +41 -41
- odoo/addons/stock_request/__manifest__.py +1 -1
- odoo/addons/stock_request/i18n/ca.po +31 -36
- odoo/addons/stock_request/i18n/de.po +77 -49
- odoo/addons/stock_request/i18n/el_GR.po +31 -36
- odoo/addons/stock_request/i18n/es.po +38 -60
- odoo/addons/stock_request/i18n/es_ES.po +31 -36
- odoo/addons/stock_request/i18n/eu.po +31 -36
- odoo/addons/stock_request/i18n/fi.po +31 -36
- odoo/addons/stock_request/i18n/fr.po +31 -36
- odoo/addons/stock_request/i18n/fr_CH.po +31 -36
- odoo/addons/stock_request/i18n/fr_FR.po +31 -36
- odoo/addons/stock_request/i18n/gl.po +31 -36
- odoo/addons/stock_request/i18n/hr.po +31 -36
- odoo/addons/stock_request/i18n/hr_HR.po +31 -36
- odoo/addons/stock_request/i18n/it.po +31 -36
- odoo/addons/stock_request/i18n/ja.po +31 -36
- odoo/addons/stock_request/i18n/ja_JP.po +31 -36
- odoo/addons/stock_request/i18n/nl.po +31 -36
- odoo/addons/stock_request/i18n/nl_NL.po +31 -36
- odoo/addons/stock_request/i18n/pt.po +31 -36
- odoo/addons/stock_request/i18n/pt_BR.po +31 -36
- odoo/addons/stock_request/i18n/ro.po +31 -36
- odoo/addons/stock_request/i18n/ru.po +31 -36
- odoo/addons/stock_request/i18n/sl.po +31 -36
- odoo/addons/stock_request/i18n/stock_request.pot +14 -31
- odoo/addons/stock_request/i18n/tr.po +31 -36
- odoo/addons/stock_request/i18n/tr_TR.po +31 -36
- odoo/addons/stock_request/i18n/vi_VN.po +31 -36
- odoo/addons/stock_request/i18n/zh_CN.po +75 -52
- odoo/addons/stock_request/models/stock_move.py +2 -2
- odoo/addons/stock_request/models/stock_move_line.py +4 -4
- odoo/addons/stock_request/models/stock_request.py +50 -43
- odoo/addons/stock_request/models/stock_request_abstract.py +2 -1
- odoo/addons/stock_request/models/stock_request_order.py +0 -13
- odoo/addons/stock_request/models/stock_rule.py +1 -1
- odoo/addons/stock_request/readme/CONFIGURE.md +16 -0
- odoo/addons/stock_request/readme/CONTRIBUTORS.md +13 -0
- odoo/addons/stock_request/readme/{DESCRIPTION.rst → DESCRIPTION.md} +2 -1
- odoo/addons/stock_request/readme/{ROADMAP.rst → ROADMAP.md} +3 -3
- odoo/addons/stock_request/readme/USAGE.md +16 -0
- odoo/addons/stock_request/security/stock_request_security.xml +5 -1
- odoo/addons/stock_request/static/description/index.html +17 -17
- odoo/addons/stock_request/tests/test_stock_request.py +171 -149
- odoo/addons/stock_request/views/res_config_settings_views.xml +72 -108
- odoo/addons/stock_request/views/stock_picking_views.xml +1 -1
- odoo/addons/stock_request/views/stock_request_order_views.xml +40 -36
- odoo/addons/stock_request/views/stock_request_views.xml +40 -39
- {odoo_addon_stock_request-16.0.1.0.0.3.dist-info → odoo_addon_stock_request-17.0.1.0.0.2.dist-info}/METADATA +47 -50
- odoo_addon_stock_request-17.0.1.0.0.2.dist-info/RECORD +71 -0
- {odoo_addon_stock_request-16.0.1.0.0.3.dist-info → odoo_addon_stock_request-17.0.1.0.0.2.dist-info}/WHEEL +1 -1
- odoo_addon_stock_request-17.0.1.0.0.2.dist-info/top_level.txt +1 -0
- odoo/addons/stock_request/readme/CONFIGURE.rst +0 -17
- odoo/addons/stock_request/readme/CONTRIBUTORS.rst +0 -15
- odoo/addons/stock_request/readme/USAGE.rst +0 -16
- odoo_addon_stock_request-16.0.1.0.0.3.dist-info/RECORD +0 -71
- odoo_addon_stock_request-16.0.1.0.0.3.dist-info/top_level.txt +0 -1
@@ -1,136 +1,137 @@
|
|
1
1
|
# Copyright 2017 ForgeFlow S.L.
|
2
|
+
# Copyright 2022-2023 Tecnativa - Víctor Martínez
|
2
3
|
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl-3.0).
|
4
|
+
|
3
5
|
from collections import Counter
|
4
6
|
from datetime import datetime
|
5
7
|
|
6
8
|
from odoo import exceptions, fields
|
7
|
-
from odoo.tests import new_test_user
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
9
|
+
from odoo.tests import common, new_test_user
|
10
|
+
|
11
|
+
|
12
|
+
class TestStockRequest(common.TransactionCase):
|
13
|
+
def setUp(self):
|
14
|
+
super().setUp()
|
15
|
+
self.env = self.env(
|
16
|
+
context=dict(
|
17
|
+
self.env.context,
|
18
|
+
mail_create_nolog=True,
|
19
|
+
mail_create_nosubscribe=True,
|
20
|
+
mail_notrack=True,
|
21
|
+
no_reset_password=True,
|
22
|
+
tracking_disable=True,
|
23
|
+
)
|
24
|
+
)
|
17
25
|
# common models
|
18
|
-
|
19
|
-
|
20
|
-
|
26
|
+
self.stock_request = self.env["stock.request"]
|
27
|
+
self.request_order = self.env["stock.request.order"]
|
21
28
|
# refs
|
22
|
-
|
29
|
+
self.stock_request_user_group = self.env.ref(
|
23
30
|
"stock_request.group_stock_request_user"
|
24
31
|
)
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
32
|
+
self.main_company = self.env.ref("base.main_company")
|
33
|
+
self.warehouse = self.env.ref("stock.warehouse0")
|
34
|
+
self.categ_unit = self.env.ref("uom.product_uom_categ_unit")
|
35
|
+
self.virtual_loc = self.env.ref("stock.stock_location_customers")
|
30
36
|
# common data
|
31
|
-
|
32
|
-
{"name": "Comp2", "parent_id":
|
37
|
+
self.company_2 = self.env["res.company"].create(
|
38
|
+
{"name": "Comp2", "parent_id": self.main_company.id}
|
33
39
|
)
|
34
|
-
|
35
|
-
|
36
|
-
.with_context(company_id=
|
40
|
+
self.company_2_address = (
|
41
|
+
self.env["res.partner"]
|
42
|
+
.with_context(company_id=self.company_2.id)
|
37
43
|
.create({"name": "Peñiscola"})
|
38
44
|
)
|
39
|
-
|
40
|
-
[("company_id", "=",
|
45
|
+
self.wh2 = self.env["stock.warehouse"].search(
|
46
|
+
[("company_id", "=", self.company_2.id)], limit=1
|
41
47
|
)
|
42
|
-
|
43
|
-
|
44
|
-
)
|
45
|
-
cls.stock_request_user = new_test_user(
|
46
|
-
cls.env,
|
48
|
+
self.stock_request_user = new_test_user(
|
49
|
+
self.env,
|
47
50
|
login="stock_request_user",
|
48
51
|
groups="stock_request.group_stock_request_user",
|
49
|
-
company_ids=[(
|
52
|
+
company_ids=[(6, 0, [self.main_company.id, self.company_2.id])],
|
50
53
|
)
|
51
|
-
|
52
|
-
|
54
|
+
self.stock_request_manager = new_test_user(
|
55
|
+
self.env,
|
53
56
|
login="stock_request_manager",
|
54
57
|
groups="stock_request.group_stock_request_manager",
|
55
|
-
company_ids=[(
|
58
|
+
company_ids=[(6, 0, [self.main_company.id, self.company_2.id])],
|
56
59
|
)
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
60
|
+
self.product = self._create_product("SH", "Shoes", False)
|
61
|
+
self.product_company_2 = self._create_product(
|
62
|
+
"SH_2", "Shoes", self.company_2.id
|
63
|
+
)
|
64
|
+
self.ressuply_loc = self._create_location(
|
61
65
|
name="Ressuply",
|
62
|
-
location_id=
|
63
|
-
company_id=
|
66
|
+
location_id=self.warehouse.view_location_id.id,
|
67
|
+
company_id=self.main_company.id,
|
64
68
|
)
|
65
|
-
|
69
|
+
self.ressuply_loc_2 = self._create_location(
|
66
70
|
name="Ressuply",
|
67
|
-
location_id=
|
68
|
-
company_id=
|
71
|
+
location_id=self.wh2.view_location_id.id,
|
72
|
+
company_id=self.company_2.id,
|
69
73
|
)
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
74
|
+
self.route = self._create_location_route(
|
75
|
+
name="Transfer", company_id=self.main_company.id
|
76
|
+
)
|
77
|
+
self.route_2 = self._create_location_route(
|
78
|
+
name="Transfer", company_id=self.company_2.id
|
79
|
+
)
|
80
|
+
self.uom_dozen = self.env["uom.uom"].create(
|
75
81
|
{
|
76
82
|
"name": "Test-DozenA",
|
77
|
-
"category_id":
|
83
|
+
"category_id": self.categ_unit.id,
|
78
84
|
"factor_inv": 12,
|
79
85
|
"uom_type": "bigger",
|
80
86
|
"rounding": 0.001,
|
81
87
|
}
|
82
88
|
)
|
83
|
-
|
84
|
-
cls.env["stock.rule"].create(
|
89
|
+
self.env["stock.rule"].create(
|
85
90
|
{
|
86
91
|
"name": "Transfer",
|
87
|
-
"route_id":
|
88
|
-
"location_src_id":
|
89
|
-
"location_dest_id":
|
92
|
+
"route_id": self.route.id,
|
93
|
+
"location_src_id": self.ressuply_loc.id,
|
94
|
+
"location_dest_id": self.warehouse.lot_stock_id.id,
|
90
95
|
"action": "pull",
|
91
|
-
"picking_type_id":
|
96
|
+
"picking_type_id": self.warehouse.int_type_id.id,
|
92
97
|
"procure_method": "make_to_stock",
|
93
|
-
"warehouse_id":
|
94
|
-
"company_id":
|
98
|
+
"warehouse_id": self.warehouse.id,
|
99
|
+
"company_id": self.main_company.id,
|
95
100
|
}
|
96
101
|
)
|
97
|
-
|
98
|
-
cls.env["stock.rule"].create(
|
102
|
+
self.env["stock.rule"].create(
|
99
103
|
{
|
100
104
|
"name": "Transfer",
|
101
|
-
"route_id":
|
102
|
-
"location_src_id":
|
103
|
-
"location_dest_id":
|
105
|
+
"route_id": self.route_2.id,
|
106
|
+
"location_src_id": self.ressuply_loc_2.id,
|
107
|
+
"location_dest_id": self.wh2.lot_stock_id.id,
|
104
108
|
"action": "pull",
|
105
|
-
"picking_type_id":
|
109
|
+
"picking_type_id": self.wh2.int_type_id.id,
|
106
110
|
"procure_method": "make_to_stock",
|
107
|
-
"warehouse_id":
|
108
|
-
"company_id":
|
111
|
+
"warehouse_id": self.wh2.id,
|
112
|
+
"company_id": self.company_2.id,
|
109
113
|
}
|
110
114
|
)
|
111
|
-
|
112
|
-
cls.env["ir.config_parameter"].sudo().set_param(
|
115
|
+
self.env["ir.config_parameter"].sudo().set_param(
|
113
116
|
"stock.no_auto_scheduler", "True"
|
114
117
|
)
|
115
118
|
|
116
|
-
|
117
|
-
|
118
|
-
return cls.env["product.product"].create(
|
119
|
+
def _create_product(self, default_code, name, company_id, **vals):
|
120
|
+
return self.env["product.product"].create(
|
119
121
|
dict(
|
120
122
|
name=name,
|
121
123
|
default_code=default_code,
|
122
|
-
uom_id=
|
124
|
+
uom_id=self.env.ref("uom.product_uom_unit").id,
|
123
125
|
company_id=company_id,
|
124
|
-
|
125
|
-
**vals
|
126
|
+
detailed_type="product",
|
127
|
+
**vals,
|
126
128
|
)
|
127
129
|
)
|
128
130
|
|
129
|
-
@classmethod
|
130
131
|
def _create_product_template_attribute_line(
|
131
|
-
|
132
|
+
self, product_tmpl_id, attribute_id, value_id
|
132
133
|
):
|
133
|
-
return
|
134
|
+
return self.env["product.template.attribute.line"].create(
|
134
135
|
{
|
135
136
|
"product_tmpl_id": product_tmpl_id,
|
136
137
|
"attribute_id": attribute_id,
|
@@ -138,33 +139,32 @@ class TestStockRequest(BaseCommon):
|
|
138
139
|
}
|
139
140
|
)
|
140
141
|
|
141
|
-
|
142
|
-
|
143
|
-
return cls.env["product.attribute.value"].create(
|
142
|
+
def _create_product_attribute_value(self, name, attribute):
|
143
|
+
return self.env["product.attribute.value"].create(
|
144
144
|
{"name": name, "attribute_id": attribute}
|
145
145
|
)
|
146
146
|
|
147
|
-
|
148
|
-
|
149
|
-
return cls.env["product.attribute"].create({"name": name})
|
147
|
+
def _create_product_attribute(self, name):
|
148
|
+
return self.env["product.attribute"].create({"name": name})
|
150
149
|
|
151
|
-
|
152
|
-
|
153
|
-
return cls.env["stock.location"].create(dict(usage="internal", **vals))
|
150
|
+
def _create_location(self, **vals):
|
151
|
+
return self.env["stock.location"].create(dict(usage="internal", **vals))
|
154
152
|
|
155
|
-
|
156
|
-
|
157
|
-
return cls.env["stock.route"].create(
|
153
|
+
def _create_location_route(self, **vals):
|
154
|
+
return self.env["stock.route"].create(
|
158
155
|
dict(
|
159
156
|
product_categ_selectable=False,
|
160
157
|
product_selectable=True,
|
161
158
|
sequence=10,
|
162
|
-
**vals
|
159
|
+
**vals,
|
163
160
|
)
|
164
161
|
)
|
165
162
|
|
166
163
|
|
167
164
|
class TestStockRequestBase(TestStockRequest):
|
165
|
+
def setUp(self):
|
166
|
+
super().setUp()
|
167
|
+
|
168
168
|
def _create_stock_quant(self, product, location, qty):
|
169
169
|
self.env["stock.quant"].create(
|
170
170
|
{"product_id": product.id, "location_id": location.id, "quantity": qty}
|
@@ -176,17 +176,30 @@ class TestStockRequestBase(TestStockRequest):
|
|
176
176
|
"product_uom_id": self.product.uom_id.id,
|
177
177
|
"product_uom_qty": 5.0,
|
178
178
|
}
|
179
|
-
|
180
|
-
|
179
|
+
stock_request = (
|
180
|
+
self.stock_request.with_user(self.stock_request_user)
|
181
|
+
.with_context(company_id=self.main_company.id)
|
182
|
+
.create(vals)
|
183
|
+
)
|
184
|
+
|
181
185
|
self.assertEqual(stock_request.requested_by, self.stock_request_user)
|
186
|
+
|
182
187
|
self.assertEqual(stock_request.warehouse_id, self.warehouse)
|
188
|
+
|
183
189
|
self.assertEqual(stock_request.location_id, self.warehouse.lot_stock_id)
|
184
190
|
|
185
191
|
def test_defaults_order(self):
|
186
|
-
|
187
|
-
order =
|
192
|
+
vals = {}
|
193
|
+
order = (
|
194
|
+
self.request_order.with_user(self.stock_request_user)
|
195
|
+
.with_context(company_id=self.main_company.id)
|
196
|
+
.create(vals)
|
197
|
+
)
|
198
|
+
|
188
199
|
self.assertEqual(order.requested_by, self.stock_request_user)
|
200
|
+
|
189
201
|
self.assertEqual(order.warehouse_id, self.warehouse)
|
202
|
+
|
190
203
|
self.assertEqual(order.location_id, self.warehouse.lot_stock_id)
|
191
204
|
|
192
205
|
def test_onchanges_order(self):
|
@@ -215,6 +228,7 @@ class TestStockRequestBase(TestStockRequest):
|
|
215
228
|
order = self.request_order.with_user(self.stock_request_user).new(vals)
|
216
229
|
self.stock_request_user.company_id = self.company_2
|
217
230
|
order.company_id = self.company_2
|
231
|
+
|
218
232
|
order.onchange_company_id()
|
219
233
|
|
220
234
|
stock_request = order.stock_request_ids
|
@@ -250,7 +264,6 @@ class TestStockRequestBase(TestStockRequest):
|
|
250
264
|
def test_onchanges(self):
|
251
265
|
self.product.route_ids = [(6, 0, self.route.ids)]
|
252
266
|
vals = {
|
253
|
-
"product_id": self.product.id,
|
254
267
|
"product_uom_id": self.product.uom_id.id,
|
255
268
|
"product_uom_qty": 5.0,
|
256
269
|
"company_id": self.main_company.id,
|
@@ -290,7 +303,7 @@ class TestStockRequestBase(TestStockRequest):
|
|
290
303
|
# Test onchange_warehouse_id
|
291
304
|
wh2_2 = (
|
292
305
|
self.env["stock.warehouse"]
|
293
|
-
.
|
306
|
+
.with_context(company_id=self.company_2.id)
|
294
307
|
.create(
|
295
308
|
{
|
296
309
|
"name": "C2_2",
|
@@ -702,7 +715,8 @@ class TestStockRequestBase(TestStockRequest):
|
|
702
715
|
picking.with_user(self.stock_request_manager).action_assign()
|
703
716
|
self.assertEqual(picking.origin, order.name)
|
704
717
|
packout1 = picking.move_line_ids[0]
|
705
|
-
packout1.
|
718
|
+
packout1.quantity = 5
|
719
|
+
packout1.picked = True
|
706
720
|
picking.with_user(self.stock_request_manager)._action_done()
|
707
721
|
self.assertEqual(stock_request.qty_in_progress, 0.0)
|
708
722
|
self.assertEqual(stock_request.qty_done, stock_request.product_uom_qty)
|
@@ -747,7 +761,8 @@ class TestStockRequestBase(TestStockRequest):
|
|
747
761
|
self.assertEqual(stock_request.qty_done, 0.0)
|
748
762
|
picking.with_user(self.stock_request_manager).action_assign()
|
749
763
|
packout1 = picking.move_line_ids[0]
|
750
|
-
packout1.
|
764
|
+
packout1.quantity = 1
|
765
|
+
packout1.picked = True
|
751
766
|
picking.with_user(self.stock_request_manager)._action_done()
|
752
767
|
self.assertEqual(stock_request.qty_in_progress, 0.0)
|
753
768
|
self.assertEqual(stock_request.qty_done, stock_request.product_uom_qty)
|
@@ -763,15 +778,14 @@ class TestStockRequestBase(TestStockRequest):
|
|
763
778
|
"warehouse_id": self.warehouse.id,
|
764
779
|
"location_id": self.warehouse.lot_stock_id.id,
|
765
780
|
}
|
781
|
+
|
766
782
|
stock_request_1 = (
|
767
|
-
self.env["stock.request"]
|
768
|
-
.with_user(self.stock_request_user)
|
769
|
-
.create(vals.copy())
|
783
|
+
self.env["stock.request"].with_user(self.stock_request_user).create(vals)
|
770
784
|
)
|
771
785
|
stock_request_2 = (
|
772
786
|
self.env["stock.request"]
|
773
787
|
.with_user(self.stock_request_manager.id)
|
774
|
-
.create(vals
|
788
|
+
.create(vals)
|
775
789
|
)
|
776
790
|
stock_request_2.product_uom_qty = 6.0
|
777
791
|
self.product.route_ids = [(6, 0, self.route.ids)]
|
@@ -801,7 +815,8 @@ class TestStockRequestBase(TestStockRequest):
|
|
801
815
|
self.assertEqual(stock_request_2.qty_done, 0)
|
802
816
|
self.assertEqual(stock_request_2.qty_cancelled, 0)
|
803
817
|
packout1 = picking.move_line_ids[0]
|
804
|
-
packout1.
|
818
|
+
packout1.quantity = 4
|
819
|
+
packout1.picked = True
|
805
820
|
self.env["stock.backorder.confirmation"].with_context(
|
806
821
|
button_validate_picking_ids=[picking.id]
|
807
822
|
).create({"pick_ids": [(4, picking.id)]}).process_cancel_backorder()
|
@@ -903,10 +918,10 @@ class TestStockRequestBase(TestStockRequest):
|
|
903
918
|
],
|
904
919
|
}
|
905
920
|
|
906
|
-
order = self.request_order.
|
921
|
+
order = self.request_order.create(vals)
|
907
922
|
self.product.route_ids = [(6, 0, self.route.ids)]
|
908
923
|
|
909
|
-
order.action_confirm()
|
924
|
+
order.with_user(self.stock_request_manager).action_confirm()
|
910
925
|
stock_request = order.stock_request_ids
|
911
926
|
self.assertTrue(stock_request.picking_ids)
|
912
927
|
self.assertTrue(order.picking_ids)
|
@@ -1125,9 +1140,9 @@ class TestStockRequestBase(TestStockRequest):
|
|
1125
1140
|
group = self.env["procurement.group"].create({"name": "Procurement group"})
|
1126
1141
|
product2 = self._create_product("SH2", "Shoes2", False)
|
1127
1142
|
product3 = self._create_product("SH3", "Shoes3", False)
|
1128
|
-
self.product.
|
1129
|
-
product2.
|
1130
|
-
product3.
|
1143
|
+
self.product.detailed_type = "consu"
|
1144
|
+
product2.detailed_type = "consu"
|
1145
|
+
product3.detailed_type = "consu"
|
1131
1146
|
vals = {
|
1132
1147
|
"company_id": self.main_company.id,
|
1133
1148
|
"warehouse_id": self.warehouse.id,
|
@@ -1183,9 +1198,10 @@ class TestStockRequestBase(TestStockRequest):
|
|
1183
1198
|
picking = order.picking_ids
|
1184
1199
|
self.assertEqual(1, len(picking))
|
1185
1200
|
picking.action_assign()
|
1186
|
-
self.assertEqual(3, len(picking.
|
1187
|
-
line = picking.
|
1188
|
-
line.
|
1201
|
+
self.assertEqual(3, len(picking.move_ids))
|
1202
|
+
line = picking.move_ids.filtered(lambda r: r.product_id == self.product)
|
1203
|
+
line.quantity = 1
|
1204
|
+
line.picked = True
|
1189
1205
|
sr1 = order.stock_request_ids.filtered(lambda r: r.product_id == self.product)
|
1190
1206
|
sr2 = order.stock_request_ids.filtered(lambda r: r.product_id == product2)
|
1191
1207
|
sr3 = order.stock_request_ids.filtered(lambda r: r.product_id == product3)
|
@@ -1195,9 +1211,9 @@ class TestStockRequestBase(TestStockRequest):
|
|
1195
1211
|
self.env["stock.backorder.confirmation"].with_context(
|
1196
1212
|
button_validate_picking_ids=[picking.id]
|
1197
1213
|
).create({"pick_ids": [(4, picking.id)]}).process()
|
1198
|
-
sr1.
|
1199
|
-
sr2.
|
1200
|
-
sr3.
|
1214
|
+
sr1.invalidate_recordset()
|
1215
|
+
sr2.invalidate_recordset()
|
1216
|
+
sr3.invalidate_recordset()
|
1201
1217
|
self.assertNotEqual(sr1.state, "done")
|
1202
1218
|
self.assertNotEqual(sr2.state, "done")
|
1203
1219
|
self.assertNotEqual(sr3.state, "done")
|
@@ -1206,58 +1222,64 @@ class TestStockRequestBase(TestStockRequest):
|
|
1206
1222
|
)
|
1207
1223
|
self.assertEqual(1, len(picking))
|
1208
1224
|
picking.action_assign()
|
1209
|
-
self.assertEqual(3, len(picking.
|
1210
|
-
line = picking.
|
1211
|
-
line.
|
1212
|
-
line =
|
1213
|
-
line
|
1225
|
+
self.assertEqual(3, len(picking.move_ids))
|
1226
|
+
line = picking.move_ids.filtered(lambda r: r.product_id == self.product)
|
1227
|
+
line.quantity = 4
|
1228
|
+
line.picked = True
|
1229
|
+
line = picking.move_ids.filtered(lambda r: r.product_id == product2)
|
1230
|
+
line.quantity = 1
|
1231
|
+
line.picked = True
|
1214
1232
|
self.env["stock.backorder.confirmation"].with_context(
|
1215
1233
|
button_validate_picking_ids=[picking.id]
|
1216
1234
|
).create({"pick_ids": [(4, picking.id)]}).process_cancel_backorder()
|
1217
|
-
sr1.
|
1218
|
-
sr2.
|
1219
|
-
sr3.
|
1235
|
+
sr1.invalidate_recordset()
|
1236
|
+
sr2.invalidate_recordset()
|
1237
|
+
sr3.invalidate_recordset()
|
1220
1238
|
self.assertEqual(sr1.state, "done")
|
1239
|
+
self.assertEqual(sr1.qty_done, 5)
|
1221
1240
|
self.assertEqual(sr1.qty_cancelled, 0)
|
1222
1241
|
self.assertEqual(sr2.state, "cancel")
|
1242
|
+
self.assertEqual(sr2.qty_done, 1)
|
1223
1243
|
self.assertEqual(sr2.qty_cancelled, 4)
|
1224
1244
|
self.assertEqual(sr3.state, "cancel")
|
1245
|
+
self.assertEqual(sr3.qty_done, 0)
|
1225
1246
|
self.assertEqual(sr3.qty_cancelled, 5)
|
1247
|
+
# Set the request order to done if there are any delivered lines
|
1248
|
+
self.assertEqual(order.state, "done")
|
1226
1249
|
|
1227
1250
|
|
1228
1251
|
class TestStockRequestOrderState(TestStockRequest):
|
1229
|
-
|
1230
|
-
|
1231
|
-
|
1232
|
-
cls.product_a = cls._create_product(
|
1252
|
+
def setUp(self):
|
1253
|
+
super().setUp()
|
1254
|
+
self.product_a = self._create_product(
|
1233
1255
|
"CODEA",
|
1234
1256
|
"Product A",
|
1235
|
-
|
1257
|
+
self.main_company.id,
|
1236
1258
|
)
|
1237
|
-
|
1238
|
-
|
1259
|
+
self.product_a.route_ids = [(6, 0, self.route.ids)]
|
1260
|
+
self.product_b = self._create_product(
|
1239
1261
|
"CODEB",
|
1240
1262
|
"Product B",
|
1241
|
-
|
1263
|
+
self.main_company.id,
|
1242
1264
|
)
|
1243
|
-
|
1265
|
+
self.product_b.route_ids = [(6, 0, self.route.ids)]
|
1244
1266
|
expected_date = fields.Datetime.now()
|
1245
1267
|
vals = {
|
1246
|
-
"company_id":
|
1247
|
-
"warehouse_id":
|
1248
|
-
"location_id":
|
1268
|
+
"company_id": self.main_company.id,
|
1269
|
+
"warehouse_id": self.warehouse.id,
|
1270
|
+
"location_id": self.warehouse.lot_stock_id.id,
|
1249
1271
|
"expected_date": expected_date,
|
1250
1272
|
"stock_request_ids": [
|
1251
1273
|
(
|
1252
1274
|
0,
|
1253
1275
|
0,
|
1254
1276
|
{
|
1255
|
-
"product_id":
|
1256
|
-
"product_uom_id":
|
1277
|
+
"product_id": self.product_a.id,
|
1278
|
+
"product_uom_id": self.product_a.uom_id.id,
|
1257
1279
|
"product_uom_qty": 1.0,
|
1258
|
-
"company_id":
|
1259
|
-
"warehouse_id":
|
1260
|
-
"location_id":
|
1280
|
+
"company_id": self.main_company.id,
|
1281
|
+
"warehouse_id": self.warehouse.id,
|
1282
|
+
"location_id": self.warehouse.lot_stock_id.id,
|
1261
1283
|
"expected_date": expected_date,
|
1262
1284
|
},
|
1263
1285
|
),
|
@@ -1265,23 +1287,23 @@ class TestStockRequestOrderState(TestStockRequest):
|
|
1265
1287
|
0,
|
1266
1288
|
0,
|
1267
1289
|
{
|
1268
|
-
"product_id":
|
1269
|
-
"product_uom_id":
|
1290
|
+
"product_id": self.product_b.id,
|
1291
|
+
"product_uom_id": self.product_b.uom_id.id,
|
1270
1292
|
"product_uom_qty": 1.0,
|
1271
|
-
"company_id":
|
1272
|
-
"warehouse_id":
|
1273
|
-
"location_id":
|
1293
|
+
"company_id": self.main_company.id,
|
1294
|
+
"warehouse_id": self.warehouse.id,
|
1295
|
+
"location_id": self.warehouse.lot_stock_id.id,
|
1274
1296
|
"expected_date": expected_date,
|
1275
1297
|
},
|
1276
1298
|
),
|
1277
1299
|
],
|
1278
1300
|
}
|
1279
|
-
|
1280
|
-
|
1281
|
-
lambda x: x.product_id ==
|
1301
|
+
self.order = self.request_order.new(vals)
|
1302
|
+
self.request_a = self.order.stock_request_ids.filtered(
|
1303
|
+
lambda x: x.product_id == self.product_a
|
1282
1304
|
)
|
1283
|
-
|
1284
|
-
lambda x: x.product_id ==
|
1305
|
+
self.request_b = self.order.stock_request_ids.filtered(
|
1306
|
+
lambda x: x.product_id == self.product_b
|
1285
1307
|
)
|
1286
1308
|
|
1287
1309
|
def test_stock_request_order_state_01(self):
|