Debian Codegraph @

addons/point_of_sale/tests/test_continental.py

raw
1 # Part of Odoo. See LICENSE file for full copyright and licensing details.
2
3 from odoo.tests import tagged
4 from odoo.addons.point_of_sale.tests.test_anglo_saxon import TestAngloSaxonCommon
5
6
7 class TestContinentalCommon(TestAngloSaxonCommon):
8
9 @classmethod
10 def setUpClass(cls):
11 super().setUpClass()
12 cls.env.company.anglo_saxon_accounting = False
13
14
15 @tagged('post_install', '-at_install')
16 class TestContinentalPerpetualFlow(TestContinentalCommon):
17
18 @classmethod
19 def setUpClass(cls):
20 super().setUpClass()
21 cls.env.company.inventory_valuation = 'real_time'
22 cls.category.property_valuation = 'real_time'
23 cls.product.write({
24 'name': "Real time valo product",
25 'categ_id': cls.category,
26 'standard_price': 20,
27 'list_price': 100
28 })
29
30 def test_inventory_valuation_session_closing_no_invoice(self):
31 """ Tests that closing the session posts the stock valuation
32 move line entries, even if order was not invoiced. """
33 self.pos_config.open_ui()
34 pos_session = self.pos_config.current_session_id
35 pos_session.set_opening_control(0, None)
36
37 # create order
38 pos_order_values = {
39 'company_id': self.company.id,
40 'partner_id': self.partner.id,
41 'session_id': self.pos_config.current_session_id.id,
42 'lines': [(0, 0, {
43 'name': "OL/0001",
44 'product_id': self.product.id,
45 'price_unit': 100,
46 'discount': 0.0,
47 'qty': 1.0,
48 'price_subtotal': 100,
49 'price_subtotal_incl': 100,
50 })],
51 'amount_total': 100,
52 'amount_tax': 0,
53 'amount_paid': 0,
54 'amount_return': 0,
55 'last_order_preparation_change': '{}'
56 }
57
58 pos_order = self.PosOrder.create(pos_order_values)
59
60 # register payment
61 context_make_payment = {"active_ids": [pos_order.id], "active_id": pos_order.id}
62 pos_payment = self.PosMakePayment.with_context(context_make_payment).create({
63 'amount': 100.0,
64 'payment_method_id': self.cash_payment_method.id,
65 })
66 context_payment = {'active_id': pos_order.id}
67 pos_payment.with_context(context_payment).check()
68
69 # validate the session
70 current_session_id = self.pos_config.current_session_id
71 current_session_id.post_closing_cash_details(100.0)
72 current_session_id.close_session_from_ui()
73
74 valuation_account = self.category.property_stock_valuation_account_id
75 valuation_lines = current_session_id.move_id.line_ids.filtered(lambda line: line.account_id == valuation_account)
76
77 self.assertEqual(len(valuation_lines), 1)
78 self.assertEqual(valuation_lines.credit, 20.0)