| 1 |
from odoo.addons.point_of_sale.tests.common import CommonPosTest |
| 2 |
from odoo.addons.account_edi.tests.common import AccountTestInvoicingCommon |
| 3 |
from odoo.tests import tagged |
| 4 |
from odoo import fields |
| 5 |
|
| 6 |
|
| 7 |
@tagged('post_install_l10n', 'post_install', '-at_install') |
| 8 |
class TestHash(CommonPosTest): |
| 9 |
|
| 10 |
@classmethod |
| 11 |
@AccountTestInvoicingCommon.setup_country('fr') |
| 12 |
def setUpClass(cls): |
| 13 |
super().setUpClass() |
| 14 |
|
| 15 |
def test_hashes_should_be_equal_if_no_alteration(self): |
| 16 |
product1 = self.env['product.product'].create({ |
| 17 |
'name': 'product1', |
| 18 |
}) |
| 19 |
|
| 20 |
self.pos_config_usd.open_ui() |
| 21 |
pos_session = self.pos_config_usd.current_session_id |
| 22 |
draft_order = { |
| 23 |
'access_token': False, |
| 24 |
'amount_paid': 0, |
| 25 |
'amount_return': 0, |
| 26 |
'amount_tax': 0, |
| 27 |
'amount_total': 0, |
| 28 |
'date_order': fields.Datetime.to_string(fields.Datetime.now()), |
| 29 |
'lines': [], |
| 30 |
'name': '/', |
| 31 |
'partner_id': False, |
| 32 |
'session_id': pos_session.id, |
| 33 |
'sequence_number': 2, |
| 34 |
'payment_ids': [], |
| 35 |
'uuid': '12345-123-1234', |
| 36 |
'last_order_preparation_change': '{}', |
| 37 |
'user_id': self.env.uid, |
| 38 |
'state': 'draft', |
| 39 |
} |
| 40 |
|
| 41 |
self.env['pos.order'].sync_from_ui([draft_order]) |
| 42 |
self.env.invalidate_all() |
| 43 |
|
| 44 |
paid_order = { |
| 45 |
'access_token': False, |
| 46 |
'amount_paid': 20, |
| 47 |
'amount_return': -5.0, |
| 48 |
'amount_tax': 0, |
| 49 |
'amount_total': 15.0, |
| 50 |
'date_order': fields.Datetime.to_string(fields.Datetime.now()), |
| 51 |
'lines': [[0, |
| 52 |
0, |
| 53 |
{'discount': 0, |
| 54 |
'pack_lot_ids': [], |
| 55 |
'price_unit': 15.0, |
| 56 |
'product_id': product1.id, |
| 57 |
'price_subtotal': 15.0, |
| 58 |
'price_subtotal_incl': 15.0, |
| 59 |
'qty': 1, |
| 60 |
'tax_ids': []}]], |
| 61 |
'name': 'Order 12345-123-1234', |
| 62 |
'partner_id': False, |
| 63 |
'session_id': pos_session.id, |
| 64 |
'sequence_number': 2, |
| 65 |
'payment_ids': [[0, |
| 66 |
0, |
| 67 |
{'amount': 20.0, |
| 68 |
'name': fields.Datetime.now(), |
| 69 |
'payment_method_id': self.cash_payment_method.id}]], |
| 70 |
'uuid': '12345-123-1234', |
| 71 |
'last_order_preparation_change': '{}', |
| 72 |
'user_id': self.env.uid, |
| 73 |
'state': 'paid', |
| 74 |
} |
| 75 |
|
| 76 |
self.env['pos.order'].sync_from_ui([paid_order]) |
| 77 |
self.env.invalidate_all() |
| 78 |
|
| 79 |
posted_order = self.env['pos.order'].search([('uuid', '=', '12345-123-1234')]) |
| 80 |
self.assertEqual(posted_order.state, 'paid') |
| 81 |
|
| 82 |
self.pos_config_usd.current_session_id.action_pos_session_closing_control() |
| 83 |
|
| 84 |
self.assertEqual(posted_order.l10n_fr_hash, posted_order._compute_hash('')) |