From b219aad27a11be89ab2c4377a3a367585a57c63c Mon Sep 17 00:00:00 2001 From: abdrahmanrashed Date: Wed, 4 Jun 2025 13:04:39 +0200 Subject: [PATCH 01/10] [IMP] -added some estate property types that are available with estate module installation. --- estate/__manifest__.py | 7 +++++-- estate/demo/estate.property.type.csv | 5 +++++ 2 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 estate/demo/estate.property.type.csv diff --git a/estate/__manifest__.py b/estate/__manifest__.py index ab40a80f40..4bf6e2446b 100644 --- a/estate/__manifest__.py +++ b/estate/__manifest__.py @@ -8,11 +8,14 @@ 'data': [ 'security/ir.model.access.csv', 'views/estate_property_views.xml', - 'views/estate_property_type_views.xml', 'views/estate_property_tag_views.xml', 'views/estate_property_offer_views.xml', + 'views/estate_property_type_views.xml', 'views/estate_menus.xml', - 'views/res_users_views.xml' + 'views/res_users_views.xml', + ], + 'demo': [ + 'demo/estate.property.type.csv' ], 'installable': True, 'application': True, diff --git a/estate/demo/estate.property.type.csv b/estate/demo/estate.property.type.csv new file mode 100644 index 0000000000..cf6c135c54 --- /dev/null +++ b/estate/demo/estate.property.type.csv @@ -0,0 +1,5 @@ +"id","name" +"data_property_type_residential","Residential" +"data_property_type_commerial","Commerial" +"data_property_type_industrial","Industrial" +"data_property_type_land","Land" \ No newline at end of file From e00585c7148a6c924858b3acaf3d66821c3aa3d0 Mon Sep 17 00:00:00 2001 From: abdrahmanrashed Date: Wed, 4 Jun 2025 13:06:35 +0200 Subject: [PATCH 02/10] [IMP] -added some demo estate model data for estate module. --- estate/__manifest__.py | 3 ++- estate/demo/estate_property.xml | 45 +++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 estate/demo/estate_property.xml diff --git a/estate/__manifest__.py b/estate/__manifest__.py index 4bf6e2446b..cb5c9063ac 100644 --- a/estate/__manifest__.py +++ b/estate/__manifest__.py @@ -15,7 +15,8 @@ 'views/res_users_views.xml', ], 'demo': [ - 'demo/estate.property.type.csv' + 'demo/estate.property.type.csv', + 'demo/estate_property.xml' ], 'installable': True, 'application': True, diff --git a/estate/demo/estate_property.xml b/estate/demo/estate_property.xml new file mode 100644 index 0000000000..ced7161e06 --- /dev/null +++ b/estate/demo/estate_property.xml @@ -0,0 +1,45 @@ + + + Big Villa + new + A nice and big villa + 12345 + 2020-02-02 + 1600000 + 6 + 100 + 4 + True + True + 100000 + south + + + + Trailer home + cancelled + Home in a trailer park + 54321 + 1970-01-01 + 100000 + 120000 + 1 + 10 + 4 + False + + + + Tutorial House + offer_received + Home in a trailer park + 54321 + 1970-01-01 + 100000 + 120000 + 1 + 10 + 4 + False + + \ No newline at end of file From cc0c3ea4fe82b0dbd3b32f3538df2d6b0aa8086b Mon Sep 17 00:00:00 2001 From: abdrahmanrashed Date: Wed, 4 Jun 2025 13:08:03 +0200 Subject: [PATCH 03/10] [IMP] -Added some demo estate offer model data for estate module. --- estate/__manifest__.py | 3 ++- estate/demo/estate_property_offer.xml | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 estate/demo/estate_property_offer.xml diff --git a/estate/__manifest__.py b/estate/__manifest__.py index cb5c9063ac..bddb9a613a 100644 --- a/estate/__manifest__.py +++ b/estate/__manifest__.py @@ -16,7 +16,8 @@ ], 'demo': [ 'demo/estate.property.type.csv', - 'demo/estate_property.xml' + 'demo/estate_property.xml', + 'demo/estate_property_offer.xml' ], 'installable': True, 'application': True, diff --git a/estate/demo/estate_property_offer.xml b/estate/demo/estate_property_offer.xml new file mode 100644 index 0000000000..1ba2a59b98 --- /dev/null +++ b/estate/demo/estate_property_offer.xml @@ -0,0 +1,22 @@ + + + + + 10000 + 14 + + + + + + 1500000 + 14 + + + + + + 1500001 + 14 + + \ No newline at end of file From b3f827738df5d54c595b8934321cd89284ef4fbc Mon Sep 17 00:00:00 2001 From: abdrahmanrashed Date: Wed, 4 Jun 2025 13:22:34 +0200 Subject: [PATCH 04/10] [IMP] -Set demo estate offers dates to be relative to module creation time. --- estate/demo/estate_property_offer.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/estate/demo/estate_property_offer.xml b/estate/demo/estate_property_offer.xml index 1ba2a59b98..b21c1dd9f9 100644 --- a/estate/demo/estate_property_offer.xml +++ b/estate/demo/estate_property_offer.xml @@ -4,6 +4,7 @@ 10000 14 + @@ -11,6 +12,7 @@ 1500000 14 + @@ -18,5 +20,6 @@ 1500001 14 + \ No newline at end of file From 05d3a45a3af6c2f6315de4f1f0fcc6cdcd2cf46d Mon Sep 17 00:00:00 2001 From: abdrahmanrashed Date: Wed, 4 Jun 2025 13:23:54 +0200 Subject: [PATCH 05/10] [IMP] -Set demo estate properties to be residential type. --- estate/demo/estate_property.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/estate/demo/estate_property.xml b/estate/demo/estate_property.xml index ced7161e06..8de56ac09a 100644 --- a/estate/demo/estate_property.xml +++ b/estate/demo/estate_property.xml @@ -13,6 +13,7 @@ True 100000 south + @@ -27,6 +28,7 @@ 10 4 False + @@ -41,5 +43,6 @@ 10 4 False + \ No newline at end of file From a96dd13e6e5fff094d520bfba1826cc42dfddc92 Mon Sep 17 00:00:00 2001 From: abdrahmanrashed Date: Wed, 4 Jun 2025 13:54:09 +0200 Subject: [PATCH 06/10] [IMP] -Set an offer to be accepted by default, and the rest to be refused. --- estate/demo/estate_property_offer.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/estate/demo/estate_property_offer.xml b/estate/demo/estate_property_offer.xml index b21c1dd9f9..f4409f25a1 100644 --- a/estate/demo/estate_property_offer.xml +++ b/estate/demo/estate_property_offer.xml @@ -22,4 +22,8 @@ 14 + + + + \ No newline at end of file From 7958f6983ef0ba0c8d482cb0faa38d55f6395851 Mon Sep 17 00:00:00 2001 From: abdrahmanrashed Date: Wed, 4 Jun 2025 14:36:05 +0200 Subject: [PATCH 07/10] [IMP] -Created demo estate property with offers inside. --- estate/demo/estate_property.xml | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/estate/demo/estate_property.xml b/estate/demo/estate_property.xml index 8de56ac09a..20374c7151 100644 --- a/estate/demo/estate_property.xml +++ b/estate/demo/estate_property.xml @@ -34,15 +34,28 @@ Tutorial House offer_received - Home in a trailer park - 54321 - 1970-01-01 - 100000 - 120000 - 1 - 10 + X2many tutorial + 13579 + 2011-11-11 + 123456 + 135791 + 2 + 30 4 False + \ No newline at end of file From 94d04787612e550141b12c1b877ac3a686b24be5 Mon Sep 17 00:00:00 2001 From: abdrahmanrashed Date: Tue, 10 Jun 2025 15:31:01 +0200 Subject: [PATCH 08/10] [ADD] -Added check to raise an error if an offer is created for a sold/cancelled property. -Added check to raise an error if a property is sold without any offer accepted. -Created tests cases to verify total area calculation, verify action_property_sold, and verify offer creation for sold property. -Added missing new lines in some files. --- estate/demo/estate.property.type.csv | 2 +- estate/demo/estate_property.xml | 3 +- estate/demo/estate_property_offer.xml | 2 +- estate/models/estate_property.py | 4 +- estate/models/estate_property_offer.py | 3 + estate/tests/__init__.py | 1 + estate/tests/test_estate_property.py | 84 ++++++++++++++++++++++++++ 7 files changed, 95 insertions(+), 4 deletions(-) create mode 100644 estate/tests/__init__.py create mode 100644 estate/tests/test_estate_property.py diff --git a/estate/demo/estate.property.type.csv b/estate/demo/estate.property.type.csv index cf6c135c54..17f4695bb6 100644 --- a/estate/demo/estate.property.type.csv +++ b/estate/demo/estate.property.type.csv @@ -2,4 +2,4 @@ "data_property_type_residential","Residential" "data_property_type_commerial","Commerial" "data_property_type_industrial","Industrial" -"data_property_type_land","Land" \ No newline at end of file +"data_property_type_land","Land" diff --git a/estate/demo/estate_property.xml b/estate/demo/estate_property.xml index 20374c7151..8359e8af29 100644 --- a/estate/demo/estate_property.xml +++ b/estate/demo/estate_property.xml @@ -58,4 +58,5 @@ }), ]"/> - \ No newline at end of file + + \ No newline at end of file diff --git a/estate/demo/estate_property_offer.xml b/estate/demo/estate_property_offer.xml index f4409f25a1..87c01d263e 100644 --- a/estate/demo/estate_property_offer.xml +++ b/estate/demo/estate_property_offer.xml @@ -26,4 +26,4 @@ - \ No newline at end of file + diff --git a/estate/models/estate_property.py b/estate/models/estate_property.py index a816fd33d3..855223a92d 100644 --- a/estate/models/estate_property.py +++ b/estate/models/estate_property.py @@ -70,6 +70,8 @@ def action_property_sold(self): for record in self: if record.state == 'cancelled': raise UserError("Cancelled properties cannot be sold.") + elif record.state != 'offer_accepted': + raise UserError("You cannot sell a property without an accepted offer.") else: record.state = 'sold' return True @@ -92,6 +94,6 @@ def _check_selling_price(self): def unlink_if_new_or_cancelled(self): for record in self: if record.state not in ('new', 'cancelled'): - raise UserError("Only new and cancelled properties can be sold.") + raise UserError("Only new and cancelled properties can be deleted.") if record.offer_ids: record.offer_ids.unlink() diff --git a/estate/models/estate_property_offer.py b/estate/models/estate_property_offer.py index 8df062241a..3334e5a0ce 100644 --- a/estate/models/estate_property_offer.py +++ b/estate/models/estate_property_offer.py @@ -55,6 +55,9 @@ def action_offer_refuse(self): @api.model_create_multi def create(self, vals_list): for vals in vals_list: + property = self.env['estate.property'].browse(vals.get('property_id')) + if property.state in ('sold', 'cancelled'): + raise UserError(f"Cannot create an offer in a {property.state} property.") price = vals.get('price') estate_property = self.env['estate.property'].browse(vals.get('property_id')) if estate_property.best_price and price <= estate_property.best_price: diff --git a/estate/tests/__init__.py b/estate/tests/__init__.py new file mode 100644 index 0000000000..576617cccf --- /dev/null +++ b/estate/tests/__init__.py @@ -0,0 +1 @@ +from . import test_estate_property diff --git a/estate/tests/test_estate_property.py b/estate/tests/test_estate_property.py new file mode 100644 index 0000000000..30ed9d6471 --- /dev/null +++ b/estate/tests/test_estate_property.py @@ -0,0 +1,84 @@ +from odoo.tests.common import TransactionCase +from odoo.exceptions import UserError +from odoo.tests import tagged +from odoo import Command + +@tagged('post_install', '-at_install') +class EstateTestCase(TransactionCase): + + @classmethod + def setUpClass(cls): + # add env on cls and many other things + super().setUpClass() + + cls.properties = cls.env['estate.property'].create([{'name': 'test_house'}]) + cls.partner = cls.env['res.partner'].create([{ + 'id': 'test_partner', + 'name': 'test_person', + 'company_name': 'test_company', + 'street': 'test_street', + 'city': 'test_city', + 'zip': '12345', + 'country_id': cls.env.ref('base.us').id, + 'state_id': cls.env.ref('base.state_us_39').id, + 'phone': '+1 555-555-5555', + 'email': 'test@testing.example.com', + 'tz': 'Europe/Brussels', + }]) + + def test_creation_area(self): + """Test that the total_area is computed like it should.""" + self.properties.living_area = 20 + self.properties.garden = True + self.properties.garden_area = 15 + self.properties.garden_orientation = 'north' + + self.assertRecordValues(self.properties, [ + {'total_area': 35}, + ]) + + def test_action_sell_without_accepted_offer(self): + """Test that everything behaves like it should when selling an invalid property.""" + + self.assertRecordValues(self.properties, [ + {'state': 'new'}, + ]) + + with self.assertRaises(UserError): + self.properties.action_property_sold() + + def test_action_sell_with_accepted_offer(self): + """Test that everything behaves like it should when selling a valid property.""" + + self.properties.offer_ids.create({ + 'property_id': self.properties.id, + 'partner_id': self.partner.id, + 'price': 124, + 'validity': 14, + }) + self.properties.offer_ids.action_offer_accept() + self.properties.action_property_sold() + + self.assertRecordValues(self.properties, [ + {'state': 'sold'}, + ]) + + def test_creation_offer_for_sold_property(self): + """Test that everything behaves like it should when property is sold.""" + + self.properties.offer_ids.create({ + 'property_id': self.properties.id, + 'partner_id': self.partner.id, + 'price': 124, + 'validity': 14, + }) + self.properties.offer_ids.action_offer_accept() + self.properties.action_property_sold() + + with self.assertRaises(UserError): + self.properties.offer_ids.create({ + 'property_id': self.properties.id, + 'partner_id': self.partner.id, + 'price': 130, + 'validity': 14, + }) From 996ee6dfb08d00e31009e61dd4bede70a2173569 Mon Sep 17 00:00:00 2001 From: abdrahmanrashed Date: Tue, 10 Jun 2025 16:19:59 +0200 Subject: [PATCH 09/10] [IMP] -Added tests to check garden values are set/reset correctly onchange. --- estate.zip | Bin 0 -> 20425 bytes estate/models/estate_property.py | 6 +++--- estate/tests/test_estate_property.py | 25 +++++++++++++++++++++++-- 3 files changed, 26 insertions(+), 5 deletions(-) create mode 100644 estate.zip diff --git a/estate.zip b/estate.zip new file mode 100644 index 0000000000000000000000000000000000000000..544623713813f3c439860a40f972b0cb5894c321 GIT binary patch literal 20425 zcmbt+1z45K+BPjncZ#$$NOw0#qjYz72uOpZbc1xaG|~;yh;+AfBlWX%vtjdj_SyUV zb2)2RuIqZ9nS1V;cb=G6S{xJ%1qe_UeLIwY{_)4h6CgYwJsVpsTRj>Dd03z)BEbBH zqPG>$+Brf40fQmD00R2?A^lSbBoHJJopk$Ogdp7u(a0mz9`{LLymrPdvn5s^5;?3Pq@9>h1 zaY!4@wJ2?HNAfdx_&3DsqgK8jvhA#X{s9b_fK&C+AJ2e+fB-Q6ngGCTAZWDyWr~p> zPJpG8j+Tz0o`%LR&J1>N8D_@t83Niz=-yq<%ybM)O!7E} zI1M@wA4W`z(v{Whj8&8iBf1%FQf-KULftc%;geoPZbEKm1#WI)?&o~VBxo@iXd5w+ z(aY$1B&#Ujv(aLRqBAx-I}KL#qT4#Zqsm_|mH=bDiH|UT(+11{sw?>N{k}(BSlB+U zmk1(u=r4w^_AMX9+>RJ9>U)5R9<3p`dpyi6boESaeqq~oyKbCQ_zVH;K5o(D?tIGjdEIAlAQ?`)eD~u(Yk1*+L4>m81OR z^G3P!GsP}S>cZ9JCfGOg!cNGBxp=}|H+pw!zMWu{ByCM8kDXn+oc7nxIqa~m{h;~! zH44UM$IU@|6ZA#vWyHkMf=#1T=X_}k9z>~@el%>!Csp@^3NT7aqotNHC9bA{r@$U# zR0{!0Doq`9IP^_;->D$>%k*kP$bPsObzeh}qk~zr>&PA{!vvxzz-aM>wTjStE1`C4 z_4Q(&R54(l>J(_VvJ&{95^V%vrNXL@;AUj!%kPJTn2ppp@sCT0o>6#wq(8=0(2ziPz_Lf2Dzg#`MqGO7kps(pDQ%W0`NJuV+FeBKKM z>~TIRUGjOKMB~z1RF+r6Q!yzu@s-VHw~p)tow(#UN9(KEqH@n7mJD)9O>4O)r(PKQ z5Ow(l+NViVZ56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&L;3&e#RYdd0J0ulo(FsfL`m<;6))-S(Ec35zq#jq4-!DZ z!+Yw0Gt6Bn_i*~XfBj7B*!{0i z{!KUjm#Z+3yYetYo$fDP2}b_AuKcgp93Ja`m_ZB3gTE`~9Vf~V=VrsOx8Ov07`$C?s3 z?@GDH1o>Zw@krS}j;P)N2ha!zMLrCz0UV`wrQ8FI^1o>OXMxFw3IP$jhanU|#O|(? zdq`6Ky~2MSzk8?>5Sw`zjQ}`S?n=4GH=5t7{O6IHhpGVKjfZZ2KzQS>lzZIJ{#MmL z4R+iq0tozF)Zk9h6)z&)pNj6>+y5Yja8G(b6yc#`{jaRh_>J`cA*OIQ8~_ag{`!Zm zLXqwnpZ zVt~Wxp;H9laJnny9^GvJP4T~RKRwh7aJf9Rqya9MyHf7K&GBFK{!0hUoo0ZB-&yK+ zny+|0x&GArkL~tfECtB;o#lQnyZ`^l{%3alz5L%<^7ry_xgYl(ApalP_4f-6VA(&k mWC51_T`Bjl`cEqUp`9-+4u0!40fY_-fiU2KfD(8B-~J!|>pjx| literal 0 HcmV?d00001 diff --git a/estate/models/estate_property.py b/estate/models/estate_property.py index 855223a92d..6971e731d1 100644 --- a/estate/models/estate_property.py +++ b/estate/models/estate_property.py @@ -57,14 +57,14 @@ def _compute_best_price(self): record.state = 'offer_received' @api.onchange("garden") - def _onchange_partner_id(self): + def _onchange_garden(self): for record in self: if record.garden: record.garden_area = 10 record.garden_orientation = 'north' else: - record.garden_area = None - record.garden_orientation = None + record.garden_area = 0 + record.garden_orientation = False def action_property_sold(self): for record in self: diff --git a/estate/tests/test_estate_property.py b/estate/tests/test_estate_property.py index 30ed9d6471..2ac0c5e682 100644 --- a/estate/tests/test_estate_property.py +++ b/estate/tests/test_estate_property.py @@ -1,7 +1,7 @@ from odoo.tests.common import TransactionCase from odoo.exceptions import UserError -from odoo.tests import tagged -from odoo import Command +from odoo.tests import Form, tagged + @tagged('post_install', '-at_install') class EstateTestCase(TransactionCase): @@ -82,3 +82,24 @@ def test_creation_offer_for_sold_property(self): 'price': 130, 'validity': 14, }) + + def test_enable_garden(self): + """Test that default values are assigned to garden area and orientation when garden is enabled""" + + form = Form(self.env['estate.property']) + form.garden = True + + self.assertEqual(form.garden_area, 10) + self.assertEqual(form.garden_orientation, 'north') + + def test_disable_garden(self): + """Test that values are removed from garden area and orientation when garden is disabled""" + + form = Form(self.env['estate.property']) + form.garden = True + form.garden_area = 15 + form.garden_orientation = 'south' + form.garden = False + + self.assertEqual(form.garden_area, 0) + self.assertEqual(form.garden_orientation, False) From c04331e9e45d269994b7e78ed8b4359228f57f05 Mon Sep 17 00:00:00 2001 From: abdrahmanrashed Date: Wed, 11 Jun 2025 10:15:09 +0200 Subject: [PATCH 10/10] [IMP] -refactoring based of PR feedback. --- estate/demo/estate_property.xml | 15 +++----- estate/tests/test_estate_property.py | 53 ++++++++++------------------ 2 files changed, 24 insertions(+), 44 deletions(-) diff --git a/estate/demo/estate_property.xml b/estate/demo/estate_property.xml index 8359e8af29..71d03835de 100644 --- a/estate/demo/estate_property.xml +++ b/estate/demo/estate_property.xml @@ -1,10 +1,9 @@ Big Villa - new A nice and big villa 12345 - 2020-02-02 + 1600000 6 100 @@ -21,13 +20,11 @@ cancelled Home in a trailer park 54321 - 1970-01-01 + 100000 - 120000 1 10 4 - False @@ -36,24 +33,22 @@ offer_received X2many tutorial 13579 - 2011-11-11 + 123456 - 135791 2 30 4 - False diff --git a/estate/tests/test_estate_property.py b/estate/tests/test_estate_property.py index 2ac0c5e682..75692d1295 100644 --- a/estate/tests/test_estate_property.py +++ b/estate/tests/test_estate_property.py @@ -1,6 +1,7 @@ from odoo.tests.common import TransactionCase from odoo.exceptions import UserError from odoo.tests import Form, tagged +from odoo import Command @tagged('post_install', '-at_install') @@ -11,73 +12,57 @@ def setUpClass(cls): # add env on cls and many other things super().setUpClass() - cls.properties = cls.env['estate.property'].create([{'name': 'test_house'}]) + cls.property = cls.env['estate.property'].create([{'name': 'test_house'}]) cls.partner = cls.env['res.partner'].create([{ - 'id': 'test_partner', 'name': 'test_person', - 'company_name': 'test_company', - 'street': 'test_street', - 'city': 'test_city', - 'zip': '12345', - 'country_id': cls.env.ref('base.us').id, - 'state_id': cls.env.ref('base.state_us_39').id, - 'phone': '+1 555-555-5555', - 'email': 'test@testing.example.com', - 'tz': 'Europe/Brussels', }]) def test_creation_area(self): """Test that the total_area is computed like it should.""" - self.properties.living_area = 20 - self.properties.garden = True - self.properties.garden_area = 15 - self.properties.garden_orientation = 'north' + self.property.living_area = 20 + self.property.garden = True + self.property.garden_area = 15 - self.assertRecordValues(self.properties, [ - {'total_area': 35}, - ]) + self.assertEqual(self.property.total_area, 35) def test_action_sell_without_accepted_offer(self): """Test that everything behaves like it should when selling an invalid property.""" - self.assertRecordValues(self.properties, [ - {'state': 'new'}, - ]) + self.assertEqual(self.property.state, 'new') with self.assertRaises(UserError): - self.properties.action_property_sold() + self.property.action_property_sold() def test_action_sell_with_accepted_offer(self): """Test that everything behaves like it should when selling a valid property.""" - self.properties.offer_ids.create({ - 'property_id': self.properties.id, + self.property.offer_ids.create({ + 'property_id': self.property.id, 'partner_id': self.partner.id, 'price': 124, 'validity': 14, }) - self.properties.offer_ids.action_offer_accept() - self.properties.action_property_sold() + self.property.offer_ids.action_offer_accept() + self.property.action_property_sold() - self.assertRecordValues(self.properties, [ + self.assertRecordValues(self.property, [ {'state': 'sold'}, ]) def test_creation_offer_for_sold_property(self): """Test that everything behaves like it should when property is sold.""" - self.properties.offer_ids.create({ - 'property_id': self.properties.id, + self.property.write({'offer_ids': [Command.create({ 'partner_id': self.partner.id, 'price': 124, 'validity': 14, - }) - self.properties.offer_ids.action_offer_accept() - self.properties.action_property_sold() + })]}) + self.property.offer_ids.action_offer_accept() + self.property.action_property_sold() with self.assertRaises(UserError): - self.properties.offer_ids.create({ - 'property_id': self.properties.id, + self.property.offer_ids.create({ + 'property_id': self.property.id, 'partner_id': self.partner.id, 'price': 130, 'validity': 14,