1
1
# Copyright 2018 Tecnativa - Sergio Teruel
2
2
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3
- from odoo .tests .common import Form , TransactionCase , tagged
3
+ from odoo .tests import Form
4
+ from odoo .tests .common import TransactionCase , tagged
4
5
5
6
6
7
@tagged ("post_install" , "-at_install" )
@@ -18,23 +19,24 @@ def setUpClass(cls):
18
19
tracking_disable = True ,
19
20
)
20
21
)
21
- if not cls .env .company .chart_template_id :
22
- # Load a CoA if there's none in current company
23
- coa = cls .env .ref ("l10n_generic_coa.configurable_chart_template" , False )
24
- if not coa :
25
- # Load the first available CoA
26
- coa = cls .env ["account.chart.template" ].search (
27
- [("visible" , "=" , True )], limit = 1
28
- )
29
- coa .try_loading (company = cls .env .company , install_demo = False )
30
22
cls .partner = cls .env ["res.partner" ].create (
31
23
{"name" : "Test" , "customer_rank" : 1 , "supplier_rank" : 1 }
32
24
)
33
25
cls .product = cls .env ["product.product" ].create (
34
- {"name" : "test_product" , "type" : "product" , "invoice_policy" : "delivery" }
26
+ {
27
+ "name" : "test_product" ,
28
+ "type" : "consu" ,
29
+ "is_storable" : True ,
30
+ "invoice_policy" : "delivery" ,
31
+ }
35
32
)
36
33
cls .product2 = cls .env ["product.product" ].create (
37
- {"name" : "test_product_2" , "type" : "product" , "invoice_policy" : "delivery" }
34
+ {
35
+ "name" : "test_product_2" ,
36
+ "type" : "consu" ,
37
+ "is_storable" : True ,
38
+ "invoice_policy" : "delivery" ,
39
+ }
38
40
)
39
41
with Form (cls .env ["sale.order" ]) as order_form :
40
42
order_form .partner_id = cls .partner
@@ -50,7 +52,7 @@ def setUpClass(cls):
50
52
move_line_vals_list = []
51
53
for move in cls .picking .move_ids :
52
54
move_line_vals = move ._prepare_move_line_vals ()
53
- move_line_vals ["qty_done " ] = 1
55
+ move_line_vals ["quantity " ] = 1
54
56
move_line_vals_list .append (move_line_vals )
55
57
cls .env ["stock.move.line" ].create (move_line_vals_list )
56
58
cls .picking .button_validate ()
@@ -73,8 +75,10 @@ def return_picking_wiz(self, picking):
73
75
74
76
def test_return_to_refund_values (self ):
75
77
return_wizard = self .return_picking_wiz (self .picking )
76
- return_pick = self .picking .browse (return_wizard .create_returns ()["res_id" ])
77
- return_pick .move_line_ids .write ({"qty_done" : 1.0 })
78
+ return_pick = self .picking .browse (
79
+ return_wizard .action_create_returns ()["res_id" ]
80
+ )
81
+ return_pick .move_line_ids .write ({"quantity" : 1.0 })
78
82
return_pick .button_validate ()
79
83
self .assertEqual (return_pick .to_refund_lines , "no_refund" )
80
84
return_pick .move_ids .write ({"to_refund" : True })
@@ -85,8 +89,10 @@ def test_return_to_refund_values(self):
85
89
def test_return_so_wo_to_refund (self ):
86
90
# Return some items, after SO was invoiced
87
91
return_wizard = self .return_picking_wiz (self .picking )
88
- return_pick = self .picking .browse (return_wizard .create_returns ()["res_id" ])
89
- return_pick .move_line_ids .write ({"qty_done" : 1.0 })
92
+ return_pick = self .picking .browse (
93
+ return_wizard .action_create_returns ()["res_id" ]
94
+ )
95
+ return_pick .move_line_ids .write ({"quantity" : 1.0 })
90
96
return_pick .button_validate ()
91
97
self .assertEqual (self .order .invoice_status , "invoiced" )
92
98
@@ -113,15 +119,17 @@ def test_return_po_wo_to_refund(self):
113
119
po_order .button_confirm ()
114
120
picking = po_order .picking_ids [:]
115
121
move_line_vals = picking .move_ids ._prepare_move_line_vals ()
116
- move_line_vals ["qty_done " ] = 1
122
+ move_line_vals ["quantity " ] = 1
117
123
self .env ["stock.move.line" ].create (move_line_vals )
118
124
picking .button_validate ()
119
125
self .assertEqual (po_order .invoice_status , "to invoice" )
120
126
# Return the picking without refund
121
127
return_wizard = self .return_picking_wiz (picking )
122
- return_pick = self .picking .browse (return_wizard .create_returns ()["res_id" ])
128
+ return_pick = self .picking .browse (
129
+ return_wizard .action_create_returns ()["res_id" ]
130
+ )
123
131
move_line_vals = return_pick .move_ids ._prepare_move_line_vals ()
124
- move_line_vals ["qty_done " ] = 1
132
+ move_line_vals ["quantity " ] = 1
125
133
self .env ["stock.move.line" ].create (move_line_vals )
126
134
return_pick .button_validate ()
127
135
# Now set to be refunded
0 commit comments