[ADD] product pricelist constraint and test cases

This commit is contained in:
Pablo
2019-09-20 12:58:21 +02:00
parent d8095ef599
commit 05571bc65c
3 changed files with 39 additions and 4 deletions

View File

@@ -23,6 +23,7 @@
# from . import test_reservation
# from . import test_folio
from . import test_inherited_ir_http
from . import test_inherited_product_pricelist
from . import test_hotel_room_type
from . import test_hotel_room
from . import test_massive_changes

View File

@@ -0,0 +1,30 @@
from .common import TestHotel
from odoo import fields
from odoo.exceptions import ValidationError
class TestInheritedProductPricelist(TestHotel):
# be aware using self.env.user.hotel_id because it is the value configure for the user running the tests
def test_daily_pricelist(self):
# A daily pricelist must be related with one and only one hotel #1
with self.assertRaises(ValidationError):
self.list0.hotel_ids += self.demo_hotel_property
# A daily pricelist must be related with one and only one hotel #2
with self.assertRaises(ValidationError):
self.list0.hotel_ids = False
# create a valid record using a daily pricelist
test_result = self.env['product.pricelist'].create({
'name': 'Test Daily Pricelist',
'hotel_ids': [(4, self.demo_hotel_property.id)]
})
self.assertEqual(test_result.pricelist_type, 'daily')
self.assertEqual(test_result.hotel_ids, self.demo_hotel_property)
def test_pricelist_by_hotel(self):
# Relationship mismatch when the pricelist is already used as default in a different hotel
with self.assertRaises(ValidationError):
self.list0.hotel_ids = self.demo_hotel_property