Skip to content

Commit fd65042

Browse files
committed
[MIG] pos_session_pay_invoice: Migration to 18.0
1 parent 8b9c65f commit fd65042

File tree

4 files changed

+23
-14
lines changed

4 files changed

+23
-14
lines changed

pos_session_pay_invoice/__manifest__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
{
55
"name": "POS Session Pay invoice",
6-
"version": "16.0.1.0.3",
6+
"version": "18.0.1.0.0",
77
"category": "Point Of Sale",
88
"author": "Creu Blanca, Odoo Community Association (OCA)",
99
"website": "https://github.com/OCA/pos",

pos_session_pay_invoice/tests/test_pay_invoice.py

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
@odoo.tests.tagged("post_install", "-at_install")
1515
class 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:

pos_session_pay_invoice/views/pos_session.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
name="button_show_wizard_pay_out_refund"
2727
type="object"
2828
icon="fa-level-up"
29-
attrs="{'invisible':['|',('cash_control', '=', False), ('state', 'not in', ['opened', 'closing_control'])]}"
29+
invisible="not cash_control or state not in ['opened', 'closing_control']"
3030
>
3131
<div class="o_form_field o_stat_info">
3232
<span class="o_stat_text">Pay</span>
@@ -38,7 +38,7 @@
3838
name="button_show_wizard_pay_in_invoice"
3939
type="object"
4040
icon="fa-level-up"
41-
attrs="{'invisible':['|',('cash_control', '=', False), ('state', 'not in', ['opened', 'closing_control'])]}"
41+
invisible="not cash_control or state not in ['opened', 'closing_control']"
4242
>
4343
<div class="o_form_field o_stat_info">
4444
<span class="o_stat_text">Pay Supplier</span>
@@ -50,7 +50,7 @@
5050
name="button_show_wizard_pay_out_invoice"
5151
type="object"
5252
icon="fa-level-down"
53-
attrs="{'invisible':['|',('cash_control', '=', False), ('state', 'not in', ['opened', 'closing_control'])]}"
53+
invisible="not cash_control or state not in ['opened', 'closing_control']"
5454
>
5555
<div class="o_form_field o_stat_info">
5656
<span class="o_stat_text">Get Payment</span>

pos_session_pay_invoice/wizard/cash_pay_invoice.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,14 @@ def action_pay_invoice(self):
8989
pos_order.write({"name": pos_order._compute_order_name()})
9090
pos_order.add_payment(self._prepare_pos_payment_vals(pos_order))
9191
pos_order._apply_invoice_payments()
92+
pos_order.write({"state": "invoiced"})
9293

9394
def _prepare_pos_order_vals(self):
9495
return {
9596
"amount_total": self.amount,
9697
"partner_id": self.invoice_id.partner_id.id,
9798
"account_move": self.invoice_id.id,
98-
"state": "invoiced",
99+
"state": "draft",
99100
"to_invoice": False,
100101
"session_id": self.pos_session_id.id,
101102
"amount_tax": 0,

0 commit comments

Comments
 (0)