Skip to content

Commit f2d9f36

Browse files
mmequignonTDu
authored andcommitted
Add shopfloor_reception_refund_return
1 parent cebf062 commit f2d9f36

File tree

11 files changed

+100
-0
lines changed

11 files changed

+100
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../../shopfloor_reception_refund_return
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import setuptools
2+
3+
setuptools.setup(
4+
setup_requires=['setuptools-odoo'],
5+
odoo_addon=True,
6+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
wait 4 da boat
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import actions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Copyright 2023 Camptocamp SA
2+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)
3+
4+
{
5+
"name": "Shopfloor Reception Refund Return",
6+
"summary": "Mark created return as to refund",
7+
"version": "14.0.1.0.0",
8+
"category": "Inventory, Accounting",
9+
"website": "https://github.com/OCA/wms",
10+
"author": "Camptocamp, BCIM, Odoo Community Association (OCA)",
11+
"maintainers": ["mmequignon"],
12+
"license": "AGPL-3",
13+
"installable": True,
14+
"auto_install": False,
15+
"depends": ["shopfloor", "stock_account"],
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import stock
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Copyright 2023 Camptocamp SA
2+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)
3+
4+
from odoo.addons.component.core import Component
5+
6+
7+
class StockAction(Component):
8+
_inherit = "shopfloor.stock.action"
9+
10+
def _create_return_move__get_vals(self, return_picking, origin_move):
11+
res = super()._create_return_move__get_vals(return_picking, origin_move)
12+
if return_picking.picking_type_code == "incoming":
13+
res["to_refund"] = True
14+
return res
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
* Matthieu Méquignon <[email protected]>
2+
* Jacques-Etienne Baudoux (BCIM) <[email protected]>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Marks returns created by shopfloor as to refund.
2+
3+
Sets `to_refund` to true when when creating a return move.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import test_action_stock
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Copyright 2023 Camptocamp SA
2+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)
3+
4+
from odoo.addons.shopfloor.tests.common import CommonCase
5+
6+
7+
class TestActionsStock(CommonCase):
8+
@classmethod
9+
def setUpClassVars(cls):
10+
super().setUpClassVars()
11+
cls.wh = cls.env.ref("stock.warehouse0")
12+
cls.location_customers = cls.env.ref("stock.stock_location_customers")
13+
cls.picking_type = cls.wh.out_type_id
14+
cls.picking_type.sudo().write(
15+
{"default_location_dest_id": cls.location_customers.id}
16+
)
17+
cls.picking_type_in = cls.picking_type.return_picking_type_id
18+
cls.picking_type_in.sudo().write(
19+
{"default_location_src_id": cls.location_customers.id}
20+
)
21+
22+
@classmethod
23+
def setUpClass(cls):
24+
super().setUpClass()
25+
with cls.work_on_actions(cls) as work:
26+
cls.stock = work.component(usage="stock")
27+
cls.picking = cls._create_picking(
28+
lines=[(cls.product_a, 10), (cls.product_b, 10)], confirm=True
29+
)
30+
cls.move0 = cls.picking.move_lines[0]
31+
cls.move1 = cls.picking.move_lines[1]
32+
cls._fill_stock_for_moves(cls.move0)
33+
cls._fill_stock_for_moves(cls.move1)
34+
cls.picking.action_assign()
35+
cls.picking._action_done()
36+
37+
def test_create_return_move(self):
38+
# For incoming returns, moves are set to `to_refund`
39+
return_picking = self.stock.create_return_picking(
40+
self.picking, self.picking_type_in, "potato"
41+
)
42+
return_moves = self.stock.create_return_move(
43+
return_picking, self.picking.move_lines
44+
)
45+
self.assertTrue(all(move.to_refund for move in return_moves))
46+
return_picking.action_assign()
47+
return_picking._action_done()
48+
49+
# However, on outgoing returns, this field is False
50+
outgoing_return = self.stock.create_return_picking(
51+
return_picking, self.picking_type, "potato"
52+
)
53+
outgoing_moves = self.stock.create_return_move(outgoing_return, return_moves)
54+
self.assertTrue(all(not move.to_refund for move in outgoing_moves))

0 commit comments

Comments
 (0)