mirror of
https://github.com/SARL-PACIFIC-ERP/odoo-sh-test.git
synced 2025-06-25 01:32:20 +00:00
104 lines
3.1 KiB
Python
104 lines
3.1 KiB
Python
from odoo import Command
|
|
from odoo.exceptions import UserError, ValidationError
|
|
from odoo.tests.common import Form, TransactionCase
|
|
from odoo.tests import tagged
|
|
|
|
|
|
@tagged('post_install', '-at_install')
|
|
class EstateTestCase(TransactionCase):
|
|
|
|
@classmethod
|
|
def setUpClass(cls):
|
|
super(EstateTestCase, cls).setUpClass()
|
|
|
|
# Properties
|
|
|
|
cls.property = cls.env['estate.property'].create({
|
|
'name': "Sick house",
|
|
'description' : "Will not actually make you sick",
|
|
'postcode': '12345',
|
|
'expected_price': 1000000.00,
|
|
'living_area': '100',
|
|
'facades': 4,
|
|
'garage': False,
|
|
'garden': False,
|
|
'property_type_id': cls.env.ref('estate.property_type_commercial').id
|
|
})
|
|
|
|
# Partners
|
|
|
|
cls.buyman = cls.env['res.partner'].create({
|
|
'name': 'Buyman',
|
|
})
|
|
cls.poorman = cls.env['res.partner'].create({
|
|
'name': 'Buyman',
|
|
})
|
|
cls.wooman = cls.env['res.partner'].create({
|
|
'name': 'Wooman',
|
|
})
|
|
|
|
# Offers
|
|
|
|
cls.property_offer_1 = cls.env['estate.property.offer'].create({
|
|
'price': 500000.00,
|
|
'partner_id': cls.poorman.id,
|
|
'property_id': cls.property.id,
|
|
})
|
|
|
|
cls.property_offer_2 = cls.env['estate.property.offer'].create({
|
|
'price': 950000.50,
|
|
'partner_id': cls.buyman.id,
|
|
'property_id': cls.property.id,
|
|
})
|
|
|
|
cls.property.offer_ids = [cls.property_offer_1.id, cls.property_offer_2.id]
|
|
|
|
def test_offer_creation_if_sold(self):
|
|
self.property_offer_2.action_accept()
|
|
self.property.action_sold()
|
|
|
|
self.assertEqual('sold', self.property.state)
|
|
|
|
with self.assertRaises(UserError):
|
|
self.env['estate.property.offer'].create({
|
|
'price': 10000.00,
|
|
'partner_id': self.poorman.id,
|
|
'property_id': self.property.id,
|
|
})
|
|
|
|
def test_sell_property_no_offer(self):
|
|
property = self.env['estate.property'].create({
|
|
'name': "Test house",
|
|
'postcode': '12345',
|
|
'expected_price': 1000000.00,
|
|
'living_area': '100',
|
|
'facades': 4,
|
|
'garage': False,
|
|
'garden': False,
|
|
'property_type_id': self.env.ref('estate.property_type_residential').id
|
|
})
|
|
|
|
with self.assertRaises(ValidationError):
|
|
property.action_sold()
|
|
with self.assertRaises(ValidationError):
|
|
self.property.action_sold()
|
|
|
|
def test_reset_garden_area(self):
|
|
with Form(self.property) as property:
|
|
self.assertEqual(0, property.garden_area)
|
|
self.assertIs(False, property.garden_orientation)
|
|
|
|
property.garden = True
|
|
|
|
self.assertEqual(10, property.garden_area)
|
|
self.assertEqual('north', property.garden_orientation)
|
|
|
|
property.garden = False
|
|
self.assertEqual(0, property.garden_area)
|
|
self.assertIs(False, property.garden_orientation)
|
|
|
|
|
|
|
|
|
|
|
|
|