gilles
8 years ago
committed by
Denis Roussel
20 changed files with 290 additions and 136 deletions
-
9pos_sequence_ref_number/README.rst
-
5pos_sequence_ref_number/__init__.py
-
13pos_sequence_ref_number/__manifest__.py
-
2pos_sequence_ref_number/i18n/ca.po
-
2pos_sequence_ref_number/i18n/de.po
-
2pos_sequence_ref_number/i18n/es.po
-
2pos_sequence_ref_number/i18n/fr.po
-
2pos_sequence_ref_number/i18n/gl.po
-
2pos_sequence_ref_number/i18n/it.po
-
2pos_sequence_ref_number/i18n/nl_NL.po
-
2pos_sequence_ref_number/i18n/sl.po
-
2pos_sequence_ref_number/i18n/zh_CN.po
-
5pos_sequence_ref_number/models/__init__.py
-
26pos_sequence_ref_number/models/pos_order.py
-
7pos_sequence_ref_number/static/lib/moment.js
-
56pos_sequence_ref_number/static/src/js/main.js
-
3pos_sequence_ref_number/static/src/xml/pos.xml
-
2pos_sequence_ref_number/tests/__init__.py
-
161pos_sequence_ref_number/tests/test_pos_order.py
-
9pos_sequence_ref_number/views/pos_template.xml
@ -1,7 +1,4 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# © 2016 Acsone SA/NV (http://www.acsone.eu) |
|||
# © 2016 Eficent Business and IT Consulting Services S.L. |
|||
# (http://www.eficent.com) |
|||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
|
|||
from . import models |
@ -1,7 +1,4 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# © 2016 Acsone SA/NV (http://www.acsone.eu) |
|||
# © 2016 Eficent Business and IT Consulting Services S.L. |
|||
# (http://www.eficent.com) |
|||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
|
|||
from . import pos_order |
@ -0,0 +1,2 @@ |
|||
# -*- coding: utf-8 -*- |
|||
from . import test_pos_order |
@ -0,0 +1,161 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Copyright 2017 ACSONE SA/NV |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
|
|||
from odoo import fields |
|||
|
|||
from odoo.tests.common import SavepointCase |
|||
|
|||
|
|||
class TestSequenceNumberSync(SavepointCase): |
|||
|
|||
@classmethod |
|||
def setUpClass(cls): |
|||
""" |
|||
Simulation of sales coming from the interface |
|||
""" |
|||
super(TestSequenceNumberSync, cls).setUpClass() |
|||
|
|||
# ENVIRONEMENTS |
|||
cls.pos_obj = cls.env['pos.order'] |
|||
cls.partner_obj = cls.env['res.partner'] |
|||
|
|||
# INSTANCES |
|||
cls.partner = cls.partner_obj.create({'name': 'test_partner_A'}) |
|||
cls.product = cls.env.ref( |
|||
'product.product_order_01') |
|||
cls.pos_config = cls.env.ref('point_of_sale.pos_config_main') |
|||
|
|||
# USING VARIABLE |
|||
cls.sequence_ref_number = 10 |
|||
cls.sequence_number = 2 |
|||
|
|||
# USER PARTNER |
|||
cls.user_partner = cls.env.user.partner_id |
|||
|
|||
def get_data(self, session, sequence_number): |
|||
return '000' + str(session.id) + '-001-000' + str(sequence_number) |
|||
|
|||
def ui_order_data(self, sequence_ref_number, sequence_number, |
|||
current_session): |
|||
values = { |
|||
'data': { |
|||
'creation_date': fields.Datetime.now(), |
|||
'fiscal_position_id': False, |
|||
'amount_return': 0, |
|||
'sequence_ref_number': sequence_ref_number, |
|||
'lines': [[0, 0, {'product_id': self.product.id, |
|||
'qty': 1}]], |
|||
'name': 'Order ' + self.get_data( |
|||
current_session, sequence_number), |
|||
'partner_id': False, |
|||
'pos_session_id': current_session.id, |
|||
'sequence_number': sequence_number, |
|||
'statement_ids': [[0, 0, { |
|||
'account_id': |
|||
self.user_partner.property_account_receivable_id.id, |
|||
'amount': 0.9, |
|||
'journal_id': self.pos_config.journal_ids[0].id, |
|||
'name': fields.Datetime.now(), |
|||
'statement_id':current_session.statement_ids[0].id}]], |
|||
'user_id': self.env.uid |
|||
}, |
|||
'to_invoice': False |
|||
} |
|||
|
|||
# because travis install (pos_loyalty) |
|||
# may be an edge effect |
|||
if 'loyalty_points' in self.pos_obj._fields: |
|||
values['data']['loyalty_points'] = 0 |
|||
|
|||
return values |
|||
|
|||
def test_check_sequence_number_sync_00(self): |
|||
""" |
|||
case 1 : |
|||
1 - create order from ui |
|||
2 - close session |
|||
3 - create new order from ui, |
|||
4 - close session |
|||
5 - validate closing & post entries |
|||
sequence result : 000session_id-001-000sequence_number |
|||
and 000new_session_id+1-001-000sequence_number |
|||
order name result : Main/00sequence_ref_number |
|||
""" |
|||
|
|||
# click on create a new session button |
|||
self.pos_config.open_session_cb() |
|||
|
|||
# session |
|||
current_session = self.pos_config.current_session_id |
|||
|
|||
# data |
|||
ui_order = self.ui_order_data(self.sequence_ref_number, |
|||
self.sequence_number, current_session) |
|||
|
|||
# I create an order on an open session |
|||
pos_order_id = self.pos_obj.create_from_ui([ui_order]) |
|||
pos_order = self.env['pos.order'].browse(pos_order_id) |
|||
self.assertEqual(pos_order.name, |
|||
'Main/00' + str(self.sequence_ref_number)) |
|||
self.assertEqual(pos_order.pos_reference, |
|||
'Order 000' + str(current_session.id)+'-001-0002') |
|||
|
|||
# close the session |
|||
self.pos_config.current_session_id.action_pos_session_closing_control() |
|||
|
|||
# create an open new session |
|||
self.pos_config.open_session_cb() |
|||
new_current_session = self.pos_config.current_session_id |
|||
ui_order['data']['pos_session_id'] = new_current_session.id |
|||
ui_order['data']['name'] = self.get_data( |
|||
new_current_session, self.sequence_number) |
|||
|
|||
# create an order on an open session |
|||
pos_order_id = self.pos_obj.create_from_ui([ui_order]) |
|||
pos_order = self.env['pos.order'].browse(pos_order_id) |
|||
self.assertEqual(pos_order.name, |
|||
'Main/00' + str(self.sequence_ref_number)) |
|||
self.assertEqual(pos_order.pos_reference, |
|||
'000' + str(new_current_session.id)+'-001-0002') |
|||
|
|||
def test_check_sequence_number_sync_01(self): |
|||
""" |
|||
case 2 : |
|||
1 - create order from ui, |
|||
2 - create new order from ui |
|||
3 - validate closing & post entries |
|||
sequence result : 000session_id-001-000sequence_number |
|||
and 000session_id-001-000new_sequence_number |
|||
order name result : Main/00sequence_ref_number |
|||
""" |
|||
|
|||
# create a new session button |
|||
self.pos_config.open_session_cb() |
|||
|
|||
# session |
|||
current_session = self.pos_config.current_session_id |
|||
|
|||
# data |
|||
ui_order = self.ui_order_data(self.sequence_ref_number, |
|||
self.sequence_number, current_session) |
|||
|
|||
# create an order on an open session |
|||
pos_order_id = self.pos_obj.create_from_ui([ui_order]) |
|||
pos_order = self.env['pos.order'].browse(pos_order_id) |
|||
self.assertEqual(pos_order.name, |
|||
'Main/00' + str(self.sequence_ref_number)) |
|||
self.assertEqual(pos_order.pos_reference, |
|||
'Order 000' + str(current_session.id) + '-001-0002') |
|||
|
|||
self.sequence_number = self.sequence_number+1 |
|||
ui_order = self.ui_order_data(self.sequence_ref_number, |
|||
self.sequence_number, current_session) |
|||
pos_order_id = self.pos_obj.create_from_ui([ui_order]) |
|||
pos_order = self.env['pos.order'].browse(pos_order_id) |
|||
self.assertEqual(pos_order.name, |
|||
'Main/00' + str(self.sequence_ref_number)) |
|||
self.assertEqual(pos_order.pos_reference, |
|||
'Order 000' + str(current_session.id) + '-001-0003') |
|||
# close the session |
|||
self.pos_config.current_session_id.action_pos_session_closing_control() |
Write
Preview
Loading…
Cancel
Save
Reference in new issue