From 0d38c6d80cee11a68d9513bcc6a0f3b356caa897 Mon Sep 17 00:00:00 2001 From: NathanBangwa243 Date: Fri, 19 Jul 2024 15:14:01 +0200 Subject: [PATCH 01/12] [ADD] estate: add estate property type master data --- addons/estate/__manifest__.py | 9 +++++++++ addons/estate/data/estate_property_type_demo.xml | 15 +++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 addons/estate/data/estate_property_type_demo.xml diff --git a/addons/estate/__manifest__.py b/addons/estate/__manifest__.py index fba09e6..0658016 100644 --- a/addons/estate/__manifest__.py +++ b/addons/estate/__manifest__.py @@ -23,11 +23,20 @@ 'data': [ 'security/ir.model.access.csv', + + # estate property 'views/estate_property_actions.xml', 'views/estate_menus.xml', 'views/estate_property_views.xml', + + # estate property offer 'views/estate_property_offer_views.xml', + + # estate property type 'views/estate_property_type_views.xml', + 'data/estate_property_type_demo.xml', + + # estate property tag 'views/estate_property_tag_views.xml', 'views/res_users.xml', ], diff --git a/addons/estate/data/estate_property_type_demo.xml b/addons/estate/data/estate_property_type_demo.xml new file mode 100644 index 0000000..ef4fa4e --- /dev/null +++ b/addons/estate/data/estate_property_type_demo.xml @@ -0,0 +1,15 @@ + + + + Residential + + + Commercial + + + Industrial + + + Land + + \ No newline at end of file From 5221be0613e6c7320d1dd79379382806f4ba53bd Mon Sep 17 00:00:00 2001 From: NathanBangwa243 Date: Fri, 19 Jul 2024 15:15:55 +0200 Subject: [PATCH 02/12] [REF] estate: update estate property type master data file --- addons/estate/__manifest__.py | 2 +- ...ate_property_type_demo.xml => estate_property_type_data.xml} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename addons/estate/data/{estate_property_type_demo.xml => estate_property_type_data.xml} (100%) diff --git a/addons/estate/__manifest__.py b/addons/estate/__manifest__.py index 0658016..cd6e2ff 100644 --- a/addons/estate/__manifest__.py +++ b/addons/estate/__manifest__.py @@ -34,7 +34,7 @@ # estate property type 'views/estate_property_type_views.xml', - 'data/estate_property_type_demo.xml', + 'data/estate_property_type_data.xml', # estate property tag 'views/estate_property_tag_views.xml', diff --git a/addons/estate/data/estate_property_type_demo.xml b/addons/estate/data/estate_property_type_data.xml similarity index 100% rename from addons/estate/data/estate_property_type_demo.xml rename to addons/estate/data/estate_property_type_data.xml From aebd4a55555c0479610a58b9061c78d4ab930925 Mon Sep 17 00:00:00 2001 From: NathanBangwa243 Date: Fri, 19 Jul 2024 16:09:39 +0200 Subject: [PATCH 03/12] [ADD] estate: add estate property demo data --- addons/estate/__manifest__.py | 1 + addons/estate/data/estate_property_demo.xml | 33 +++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 addons/estate/data/estate_property_demo.xml diff --git a/addons/estate/__manifest__.py b/addons/estate/__manifest__.py index cd6e2ff..9158619 100644 --- a/addons/estate/__manifest__.py +++ b/addons/estate/__manifest__.py @@ -28,6 +28,7 @@ 'views/estate_property_actions.xml', 'views/estate_menus.xml', 'views/estate_property_views.xml', + 'data/estate_property_demo.xml', # estate property offer 'views/estate_property_offer_views.xml', diff --git a/addons/estate/data/estate_property_demo.xml b/addons/estate/data/estate_property_demo.xml new file mode 100644 index 0000000..afea167 --- /dev/null +++ b/addons/estate/data/estate_property_demo.xml @@ -0,0 +1,33 @@ + + + + Big Villa + new + A nice and big villa + 12345 + 2020-02-02 + 1600000.0 + 6 + 100 + 4 + True + True + 100000 + South + + + Trailer home + canceled + Home in a trailer park + 54321 + 1970-01-01 + 100000.0 + 120000.0 + 1 + 10 + 4 + False + + + + \ No newline at end of file From 6ee0aba7d4108b875f10c9ac13b1e0b84e11adbb Mon Sep 17 00:00:00 2001 From: NathanBangwa243 Date: Fri, 19 Jul 2024 16:12:05 +0200 Subject: [PATCH 04/12] [ADD] estate: prevent db data erasing when upload the default master data --- .../estate/data/estate_property_type_data.xml | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/addons/estate/data/estate_property_type_data.xml b/addons/estate/data/estate_property_type_data.xml index ef4fa4e..fb0eec3 100644 --- a/addons/estate/data/estate_property_type_data.xml +++ b/addons/estate/data/estate_property_type_data.xml @@ -1,15 +1,18 @@ - - Residential - - - Commercial - - - Industrial - - - Land - + + + Residential + + + Commercial + + + Industrial + + + Land + + + \ No newline at end of file From 84f8976187d45d48cd44adb0792061dee61021ad Mon Sep 17 00:00:00 2001 From: NathanBangwa243 Date: Mon, 22 Jul 2024 16:33:02 +0200 Subject: [PATCH 05/12] [MOV] estate: move demo data file to they proper folder --- addons/estate/__manifest__.py | 2 +- addons/estate/{data => demo}/estate_property_demo.xml | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename addons/estate/{data => demo}/estate_property_demo.xml (100%) diff --git a/addons/estate/__manifest__.py b/addons/estate/__manifest__.py index 9158619..54e898c 100644 --- a/addons/estate/__manifest__.py +++ b/addons/estate/__manifest__.py @@ -28,7 +28,7 @@ 'views/estate_property_actions.xml', 'views/estate_menus.xml', 'views/estate_property_views.xml', - 'data/estate_property_demo.xml', + 'demo/estate_property_demo.xml', # estate property offer 'views/estate_property_offer_views.xml', diff --git a/addons/estate/data/estate_property_demo.xml b/addons/estate/demo/estate_property_demo.xml similarity index 100% rename from addons/estate/data/estate_property_demo.xml rename to addons/estate/demo/estate_property_demo.xml From 0b2bc8c1e47502f79a1b0f00e37862061106bf8c Mon Sep 17 00:00:00 2001 From: NathanBangwa243 Date: Mon, 22 Jul 2024 17:17:21 +0200 Subject: [PATCH 06/12] [ADD] learning-odoo-17: add script for project reinitialization --- docker-reset.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100755 docker-reset.sh diff --git a/docker-reset.sh b/docker-reset.sh new file mode 100755 index 0000000..c28bf5f --- /dev/null +++ b/docker-reset.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +# delete odoo docker instance +echo "**********[DELETE ODOO DOCKER INSTANCES]*********" +docker rm -f odoo17Learning postgres_odoo17Learning + +# delete all volumes +echo "**********[DELETE ODOO DOCKER VOLUMES]*********" +docker volume rm learning-odoo-17_odoo-db-data learning-odoo-17_odoo-web-data learning-odoo-17_odoo-db-pgdata + +# execute the project +echo "**********[START ODOO DOCKER INSTANCES]*********" +docker compose up -d --force-recreate \ No newline at end of file From 404164f167ef04ed0d7b7d252824857d685d783a Mon Sep 17 00:00:00 2001 From: NathanBangwa243 Date: Mon, 22 Jul 2024 17:18:56 +0200 Subject: [PATCH 07/12] [ADD] estate: set Residential as default property type --- addons/estate/__manifest__.py | 12 +++++++++--- addons/estate/demo/estate_property_demo.xml | 2 ++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/addons/estate/__manifest__.py b/addons/estate/__manifest__.py index 54e898c..7312da2 100644 --- a/addons/estate/__manifest__.py +++ b/addons/estate/__manifest__.py @@ -17,7 +17,7 @@ 'website': "http://www.gofamille.org", 'category': 'Sales/Real Estate', - 'version': '0.1', + 'version': '0.3', 'depends': ['base'], @@ -28,18 +28,24 @@ 'views/estate_property_actions.xml', 'views/estate_menus.xml', 'views/estate_property_views.xml', - 'demo/estate_property_demo.xml', # estate property offer 'views/estate_property_offer_views.xml', # estate property type 'views/estate_property_type_views.xml', - 'data/estate_property_type_data.xml', # estate property tag 'views/estate_property_tag_views.xml', 'views/res_users.xml', + + # MASTER DATAS + # estate property type + 'data/estate_property_type_data.xml', + + # DEMO DATAS + # estate property + 'demo/estate_property_demo.xml', ], 'installable': True, diff --git a/addons/estate/demo/estate_property_demo.xml b/addons/estate/demo/estate_property_demo.xml index afea167..6b10c0b 100644 --- a/addons/estate/demo/estate_property_demo.xml +++ b/addons/estate/demo/estate_property_demo.xml @@ -14,6 +14,7 @@ True 100000 South + Trailer home @@ -27,6 +28,7 @@ 10 4 False + From 04e81907e4230fab2e36f4f76ed4d0742b5486ff Mon Sep 17 00:00:00 2001 From: NathanBangwa243 Date: Mon, 22 Jul 2024 17:33:12 +0200 Subject: [PATCH 08/12] [ADD] estate: add some demo data offers for the properties --- addons/estate/__manifest__.py | 3 ++- .../demo/estate_property_offer_demo.xml | 22 +++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 addons/estate/demo/estate_property_offer_demo.xml diff --git a/addons/estate/__manifest__.py b/addons/estate/__manifest__.py index 7312da2..fe33f7f 100644 --- a/addons/estate/__manifest__.py +++ b/addons/estate/__manifest__.py @@ -17,7 +17,7 @@ 'website': "http://www.gofamille.org", 'category': 'Sales/Real Estate', - 'version': '0.3', + 'version': '0.4', 'depends': ['base'], @@ -46,6 +46,7 @@ # DEMO DATAS # estate property 'demo/estate_property_demo.xml', + 'demo/estate_property_offer_demo.xml', ], 'installable': True, diff --git a/addons/estate/demo/estate_property_offer_demo.xml b/addons/estate/demo/estate_property_offer_demo.xml new file mode 100644 index 0000000..b50166f --- /dev/null +++ b/addons/estate/demo/estate_property_offer_demo.xml @@ -0,0 +1,22 @@ + + + + 10000 + 14 + + + + + 1500000 + 14 + + + + + 1500001 + 14 + + + + + \ No newline at end of file From 1f2361c2e5687e1b4a4f6f70744b12b3a0c75823 Mon Sep 17 00:00:00 2001 From: NathanBangwa243 Date: Mon, 22 Jul 2024 22:33:59 +0200 Subject: [PATCH 09/12] [ADD] estate: set today as relative date for the offer --- addons/estate/__manifest__.py | 2 +- addons/estate/demo/estate_property_offer_demo.xml | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/addons/estate/__manifest__.py b/addons/estate/__manifest__.py index fe33f7f..4a0a16b 100644 --- a/addons/estate/__manifest__.py +++ b/addons/estate/__manifest__.py @@ -17,7 +17,7 @@ 'website': "http://www.gofamille.org", 'category': 'Sales/Real Estate', - 'version': '0.4', + 'version': '0.5', 'depends': ['base'], diff --git a/addons/estate/demo/estate_property_offer_demo.xml b/addons/estate/demo/estate_property_offer_demo.xml index b50166f..3bfd79a 100644 --- a/addons/estate/demo/estate_property_offer_demo.xml +++ b/addons/estate/demo/estate_property_offer_demo.xml @@ -5,18 +5,23 @@ 14 + + 1500000 14 + + 1500001 14 + \ No newline at end of file From 6735d8fedaa1fb7ead184c6dcb23018ee9893de9 Mon Sep 17 00:00:00 2001 From: NathanBangwa243 Date: Mon, 22 Jul 2024 23:11:12 +0200 Subject: [PATCH 10/12] [ADD] estate: Validate one of the demo data offers by using the 'Accept Offer' button. --- addons/estate/__manifest__.py | 2 +- addons/estate/demo/estate_property_offer_demo.xml | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/addons/estate/__manifest__.py b/addons/estate/__manifest__.py index 4a0a16b..5553c91 100644 --- a/addons/estate/__manifest__.py +++ b/addons/estate/__manifest__.py @@ -17,7 +17,7 @@ 'website': "http://www.gofamille.org", 'category': 'Sales/Real Estate', - 'version': '0.5', + 'version': '0.6', 'depends': ['base'], diff --git a/addons/estate/demo/estate_property_offer_demo.xml b/addons/estate/demo/estate_property_offer_demo.xml index 3bfd79a..a8cefc4 100644 --- a/addons/estate/demo/estate_property_offer_demo.xml +++ b/addons/estate/demo/estate_property_offer_demo.xml @@ -23,5 +23,10 @@ + + + + + \ No newline at end of file From ab88ee763386a92049934fe4cda606f8a01f356f Mon Sep 17 00:00:00 2001 From: NathanBangwa243 Date: Tue, 23 Jul 2024 17:09:27 +0200 Subject: [PATCH 11/12] [ADD] estate: create new Property with some offers created directly inside the One2many --- addons/estate/__manifest__.py | 2 +- addons/estate/demo/estate_property_demo.xml | 29 +++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/addons/estate/__manifest__.py b/addons/estate/__manifest__.py index 5553c91..46f1442 100644 --- a/addons/estate/__manifest__.py +++ b/addons/estate/__manifest__.py @@ -17,7 +17,7 @@ 'website': "http://www.gofamille.org", 'category': 'Sales/Real Estate', - 'version': '0.6', + 'version': '0.7', 'depends': ['base'], diff --git a/addons/estate/demo/estate_property_demo.xml b/addons/estate/demo/estate_property_demo.xml index 6b10c0b..8c7cedf 100644 --- a/addons/estate/demo/estate_property_demo.xml +++ b/addons/estate/demo/estate_property_demo.xml @@ -30,6 +30,35 @@ False + + Bangwa home + offer_received + Home in a trailer park + 54321 + 1970-01-01 + 100000.0 + 120000.0 + 1 + 10 + 4 + False + + + + \ No newline at end of file From 2a02d8541979cb2536e177025a88398899519899 Mon Sep 17 00:00:00 2001 From: NathanBangwa243 Date: Tue, 23 Jul 2024 18:02:48 +0200 Subject: [PATCH 12/12] [ADD] README.md: add initial resume for section 1 of additionnal tutorial --- README.md | 124 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 123 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 405b3bd..1f17e48 100644 --- a/README.md +++ b/README.md @@ -1919,4 +1919,126 @@ To use an external library like Unidecode: With these steps, you've created your first Odoo module, tested it, and deployed it in production. -Congratulations! πŸŽ‰ \ No newline at end of file +Congratulations! πŸŽ‰ + +## Expand your knowledge on the server framework + +### Chapter 9: Define Module Data πŸ“Š + +After creating your first module with Odoo.sh, it's time to dive deeper into managing the data that powers your module. This chapter will guide you through the types of data you can define and how to structure and declare them effectively within your Odoo module. + +#### Data Types πŸ“‘ + +In Odoo, data is categorized into two main types: **Master Data** and **Demo Data**. + +**Master Data** is essential for the module to function correctly. It includes technical data like views and actions and business data such as countries, currencies, and legal reports. This data is automatically installed with the module. + +**Demo Data** is used for demonstration and testing purposes. It helps sales representatives perform demos, allows developers to test new features, and ensures that data loads correctly without errors. Demo data is loaded automatically unless you specify otherwise. + +#### Data Declaration πŸ“ + +To declare data in your module, you need to include it in the module's manifest file. Data can be declared in CSV or XML format, with each file listed under the appropriate key in the manifest. + +**Manifest Example:** + +```python +{ + "name": "Real Estate", + "depends": ["base"], + "data": [ + "security/ir.model.access.csv", + "views/estate_property_offer_views.xml", + "data/master_data.xml", + ], + "demo": [ + "demo/demo_data.xml", + ], + "application": True, +} +``` + +#### CSV Data πŸ“„ + +CSV files are ideal for simple, long lists of data. They are easy to create and maintain but are limited in functionality compared to XML. + +**CSV Example:** + +```plaintext +id,field_a,field_b,related_id:id +id1,valueA1,valueB1,module.relatedid +id2,valueA2,valueB2,module.relatedid +``` + +#### XML Data πŸ—‚οΈ + +XML is more flexible and powerful, suitable for complex data structures. It allows you to create detailed records and link related data. + +**XML Example:** + +```xml + + + valueA1 + valueB1 + + + + valueA2 + valueB2 + + +``` + +#### Extending Data πŸ› οΈ + +In Odoo, you can extend existing data by adding new fields or enhancing current ones without replacing the original data. Use the `xml_id` of existing records to integrate new information seamlessly. + +**Extending Example:** + +```xml + + + valueC1 + + +``` + +#### Accessing Data πŸ” + +Accessing data in Odoo can be done through Python code, XML references, or CSV declarations. Always code defensively, considering that data can be altered or deleted by users. + +**Accessing Data Example in XML:** + +```xml + + + + + +``` + +**Accessing Data Example in CSV:** + +```plaintext +id,parent_id:id,name +"child1","module.parent","Name1" +"child2","module.parent","Name2" +``` + +#### Advanced Techniques πŸ’‘ + +Understanding XML ids, the `noupdate` flag, and the use of raw SQL for data import are advanced techniques that can enhance your data management skills. However, these should be used cautiously to maintain data integrity and security. + +**No Update Example:** + +The records created with the noupdate flag won’t be updated when upgrading the module that created them, but it will be created if it didn’t exist yet. + +```xml + + + + + +``` + +By mastering these data management techniques, you'll ensure your Odoo modules are robust, flexible, and reliable, paving the way for more advanced development in the Odoo ecosystem. πŸš€ \ No newline at end of file