1414@odoo .tests .tagged ("post_install" , "-at_install" )
1515class TestSessionPayInvoice (TestPointOfSaleCommon ):
1616 @classmethod
17- def setUpClass (cls , chart_template_ref = None ):
18- super ().setUpClass (chart_template_ref = chart_template_ref )
17+ def setUpClass (cls ):
18+ super ().setUpClass ()
1919 cls .env = cls .env (context = dict (cls .env .context , ** DISABLED_MAIL_CONTEXT ))
2020 cls .pos_config .cash_control = True
2121 cls .new_journal = cls .env ["account.journal" ].create (
@@ -68,14 +68,22 @@ def setUpClass(cls, chart_template_ref=None):
6868 }
6969 )
7070 cls .invoice_in .action_post ()
71+ cls .invoice_out2 = cls .invoice_out .copy ()
72+ cls .invoice_out2 .action_post ()
73+ payment_register = Form (
74+ cls .env ["account.payment.register" ].with_context (
75+ active_model = "account.move" , active_ids = cls .invoice_out2 .ids
76+ )
77+ )
78+ cls .payment = payment_register .save ()._create_payments ()
7179 refund_wizard = (
7280 cls .env ["account.move.reversal" ]
7381 .with_context (
74- active_ids = cls .invoice_out .ids ,
75- active_id = cls .invoice_out .id ,
76- active_model = cls .invoice_out ._name ,
82+ active_ids = cls .invoice_out2 .ids ,
83+ active_id = cls .invoice_out2 .id ,
84+ active_model = cls .invoice_out2 ._name ,
7785 )
78- .create ({"journal_id" : cls .invoice_out .journal_id .id })
86+ .create ({"journal_id" : cls .invoice_out2 .journal_id .id })
7987 .reverse_moves ()
8088 )
8189 cls .refund = cls .env [refund_wizard ["res_model" ]].browse (refund_wizard ["res_id" ])
@@ -87,7 +95,7 @@ def test_pos_in_invoice(self):
8795 session = self .pos_config .current_session_id
8896 self .assertTrue (session .cash_control )
8997 self .assertTrue (session .cash_journal_id )
90- session .set_cashbox_pos (0 , notes = "Initial cash" )
98+ session .set_opening_control (0 , notes = "Initial cash" )
9199 wizard_context = session .button_show_wizard_pay_in_invoice ()["context" ]
92100 cash_in = self .env ["cash.pay.invoice" ].with_context (** wizard_context )
93101 with Form (cash_in , view = WIZARD_PAY_INVOICE_VIEW ) as form :
@@ -113,7 +121,7 @@ def test_pos_out_invoice(self):
113121 self .assertEqual (self .invoice_out .amount_residual , 100.0 )
114122 self .pos_config ._action_to_open_ui ()
115123 session = self .pos_config .current_session_id
116- session .set_cashbox_pos (0 , notes = "Initial cash" )
124+ session .set_opening_control (0 , notes = "Initial cash" )
117125 wizard_context = session .button_show_wizard_pay_out_invoice ()["context" ]
118126 cash_out = self .env ["cash.pay.invoice" ].with_context (** wizard_context )
119127 with Form (cash_out , view = WIZARD_PAY_INVOICE_VIEW ) as form :
@@ -136,7 +144,7 @@ def test_pos_invoice_refund(self):
136144 self .assertEqual (self .refund .amount_residual , 100.0 )
137145 self .pos_config ._action_to_open_ui ()
138146 session = self .pos_config .current_session_id
139- session .set_cashbox_pos (0 , notes = "Initial cash" )
147+ session .set_opening_control (0 , notes = "Initial cash" )
140148 wizard_context = session .button_show_wizard_pay_out_refund ()["context" ]
141149 cash_out = self .env ["cash.pay.invoice" ].with_context (** wizard_context )
142150 with Form (cash_out , view = WIZARD_PAY_INVOICE_VIEW ) as form :
0 commit comments