summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYannick Tivisse <yti@odoo.com>2019-11-04 16:38:49 +0100
committerYannick Tivisse <yti@odoo.com>2019-11-05 16:18:10 +0100
commit0a8866fdebd748de2c8ef9fd8328fffcbb285c04 (patch)
treea54e0727ddb680401c63fdf50824416f982d1b19
parentd360c49a5ad03eb3d12dcaa00301a6e1d76b3b40 (diff)
[IMP] pos_restaurant: Adapt tests to work with/without demo data
-rw-r--r--addons/account/tests/test_account_bank_statement.py1
-rw-r--r--addons/point_of_sale/models/pos_config.py1
-rw-r--r--addons/pos_restaurant/tests/test_frontend.py79
3 files changed, 72 insertions, 9 deletions
diff --git a/addons/account/tests/test_account_bank_statement.py b/addons/account/tests/test_account_bank_statement.py
index 4a51f21e568..b7dd04d48b1 100644
--- a/addons/account/tests/test_account_bank_statement.py
+++ b/addons/account/tests/test_account_bank_statement.py
@@ -71,7 +71,6 @@ class TestBankStatementReconciliation(AccountingTestCase):
def test_create_new_statement(self):
# Create first statement on 1/1/2019
bnk1 = self.create_bank_statement('2019-01-02', 100)
- # import pdb;pdb.set_trace()
self.assertEqual(bnk1.balance_start, 0)
# Balance is automatically computed when creating statement with the lines
self.assertEqual(bnk1.balance_end_real, 100)
diff --git a/addons/point_of_sale/models/pos_config.py b/addons/point_of_sale/models/pos_config.py
index bb4eff28e30..eb4f3f0d64a 100644
--- a/addons/point_of_sale/models/pos_config.py
+++ b/addons/point_of_sale/models/pos_config.py
@@ -320,6 +320,7 @@ class PosConfig(models.Model):
@api.constrains('company_id', 'payment_method_ids')
def _check_company_payment(self):
if self.env['pos.payment.method'].search_count([('id', 'in', self.payment_method_ids.ids), ('company_id', '!=', self.company_id.id)]):
+ import pdb; pdb.set_trace()
raise ValidationError(_("The method payments and the point of sale must belong to the same company."))
@api.constrains('pricelist_id', 'use_pricelist', 'available_pricelist_ids', 'journal_id', 'invoice_journal_id', 'payment_method_ids')
diff --git a/addons/pos_restaurant/tests/test_frontend.py b/addons/pos_restaurant/tests/test_frontend.py
index f65150e647b..b4d5a8b3ed8 100644
--- a/addons/pos_restaurant/tests/test_frontend.py
+++ b/addons/pos_restaurant/tests/test_frontend.py
@@ -9,7 +9,47 @@ class TestFrontend(odoo.tests.HttpCase):
env = self.env(user=self.env.ref('base.user_admin'))
account_obj = env['account.account']
- pos_config = env.ref('pos_restaurant.pos_config_restaurant')
+ printer = self.env['restaurant.printer'].create({
+ 'name': 'Kitchen Printer',
+ 'proxy_ip': 'localhost',
+ })
+ drinks_category = self.env['pos.category'].create({'name': 'Drinks'})
+
+ pos_config = self.env['pos.config'].create({
+ 'name': 'Bar',
+ 'barcode_nomenclature_id': self.env.ref('barcodes.default_barcode_nomenclature').id,
+ 'module_pos_restaurant': True,
+ 'is_table_management': True,
+ 'iface_splitbill': True,
+ 'iface_printbill': True,
+ 'iface_orderline_notes': True,
+ 'printer_ids': [(4, printer.id)],
+ 'iface_start_categ_id': drinks_category.id,
+ 'start_category': True,
+ 'pricelist_id': self.env.ref('product.list0').id,
+ })
+
+ main_floor = self.env['restaurant.floor'].create({
+ 'name': 'Main Floor',
+ 'pos_config_id': pos_config.id,
+ })
+
+ table_05 = self.env['restaurant.table'].create({
+ 'name': 'T5',
+ 'floor_id': main_floor.id,
+ 'seats': 4,
+ })
+ table_04 = self.env['restaurant.table'].create({
+ 'name': 'T4',
+ 'floor_id': main_floor.id,
+ 'seats': 4,
+ })
+ table_02 = self.env['restaurant.table'].create({
+ 'name': 'T2',
+ 'floor_id': main_floor.id,
+ 'seats': 4,
+ })
+
main_company = env.ref('base.main_company')
account_receivable = account_obj.create({'code': 'X1012',
@@ -47,14 +87,37 @@ class TestFrontend(odoo.tests.HttpCase):
})],
})
- coke = self.env.ref('pos_restaurant.coke')
- coke.write({'taxes_id': [(6, 0, [])]})
- water = self.env.ref('pos_restaurant.water')
- water.write({'taxes_id': [(6, 0, [])]})
- minute_maid = self.env.ref('pos_restaurant.minute_maid')
- minute_maid.write({'taxes_id': [(6, 0, [])]})
+ coke = self.env['product.product'].create({
+ 'available_in_pos': True,
+ 'list_price': 2.20,
+ 'name': 'Coca-Cola',
+ 'weight': 0.01,
+ 'pos_categ_id': drinks_category.id,
+ 'categ_id': self.env.ref('point_of_sale.product_category_pos').id,
+ 'taxes_id': [(6, 0, [])],
+ })
+
+ water = self.env['product.product'].create({
+ 'available_in_pos': True,
+ 'list_price': 2.20,
+ 'name': 'Water',
+ 'weight': 0.01,
+ 'pos_categ_id': drinks_category.id,
+ 'categ_id': self.env.ref('point_of_sale.product_category_pos').id,
+ 'taxes_id': [(6, 0, [])],
+ })
+
+ minute_maid = self.env['product.product'].create({
+ 'available_in_pos': True,
+ 'list_price': 2.20,
+ 'name': 'Minute Maid',
+ 'weight': 0.01,
+ 'pos_categ_id': drinks_category.id,
+ 'categ_id': self.env.ref('point_of_sale.product_category_pos').id,
+ 'taxes_id': [(6, 0, [])],
+ })
- pos_config.open_session_cb()
+ pos_config.with_user(self.env.ref('base.user_admin')).open_session_cb(check_coa=False)
self.start_tour("/pos/web?config_id=%d" % pos_config.id, 'pos_restaurant_sync', login="admin")