From 2a8358d8f7b9c3c78a4c60a6a2b2cc0c0311e8c6 Mon Sep 17 00:00:00 2001 From: koye-odoo Date: Mon, 30 Sep 2024 14:53:59 +0530 Subject: [PATCH] [ADD] estate_offer_wizard: implemented wizard for adding offers to properties. - Added 'Add Offer' button in the estate property tree view header. - Enabled selection of multiple properties for offer creation. - Created wizard with fields for price, offer status, and buyer. - Included 'Make an Offer' button to handle business logic and 'Cancel' button for form cancellation. --- estate/__init__.py | 1 + estate/__manifest__.py | 5 +++-- estate/security/ir.model.access.csv | 3 ++- estate/views/estate_property_views.xml | 9 +++++++-- estate/wizard/__init__.py | 1 + estate/wizard/add_offers_wizard.py | 25 +++++++++++++++++++++++ estate/wizard/wizard_view.xml | 28 ++++++++++++++++++++++++++ 7 files changed, 67 insertions(+), 5 deletions(-) create mode 100644 estate/wizard/__init__.py create mode 100644 estate/wizard/add_offers_wizard.py create mode 100644 estate/wizard/wizard_view.xml diff --git a/estate/__init__.py b/estate/__init__.py index 54f3958776..a92309f9fb 100644 --- a/estate/__init__.py +++ b/estate/__init__.py @@ -1,3 +1,4 @@ from . import models from . import demo from . import data +from . import wizard diff --git a/estate/__manifest__.py b/estate/__manifest__.py index 23dbf35364..bf287ca54f 100644 --- a/estate/__manifest__.py +++ b/estate/__manifest__.py @@ -10,6 +10,9 @@ "application": True, "installable": True, "data": [ + "security/security.xml", + "security/ir.model.access.csv", + "wizard/wizard_view.xml", "views/estate_property_views.xml", "views/estate_property_offer.xml", "views/estate_property_type.xml", @@ -20,8 +23,6 @@ "report/subtemplate_offers_table.xml", "report/estate_property_templates.xml", "report/estate_property_reports.xml", - "security/security.xml", - "security/ir.model.access.csv", ], "demo": [ "demo/estate_demo.xml", diff --git a/estate/security/ir.model.access.csv b/estate/security/ir.model.access.csv index c94876be96..3ebe07ac43 100644 --- a/estate/security/ir.model.access.csv +++ b/estate/security/ir.model.access.csv @@ -10,4 +10,5 @@ estate.access_estate_property_offer_manager,access_estate_property_offer_manager estate.access_estate_property_agent,access_estate_property_agent,estate.model_estate_property,estate_group_user,1,1,1,0 estate.access_estate_property_type_agent,access_estate_property_type_agent,estate.model_estate_property_type,estate_group_user,1,0,0,0 estate.access_estate_property_tag_agent,access_estate_property_tag_agent,estate.model_estate_property_tag,estate_group_user,1,0,0,0 -estate.access_estate_property_offer_agent,access_estate_property_offer_agent,estate.model_estate_property_offer,base.group_user,1,1,1,0 \ No newline at end of file +estate.access_estate_property_offer_agent,access_estate_property_offer_agent,estate.model_estate_property_offer,base.group_user,1,1,1,0 +estate.access_add_offers_wizard,access_add_offers_wizard,estate.model_add_offers_wizard,base.group_user,1,1,1,0 diff --git a/estate/views/estate_property_views.xml b/estate/views/estate_property_views.xml index cbc22ce8c0..0e429d5944 100644 --- a/estate/views/estate_property_views.xml +++ b/estate/views/estate_property_views.xml @@ -13,6 +13,11 @@ decoration-success="status=='Offer Received'or status=='Offer Accepted'" decoration-bf="status=='Offer Accepted'" decoration-muted="status=='Sold'"> +
+
@@ -49,7 +54,7 @@ - + @@ -136,4 +141,4 @@ - + \ No newline at end of file diff --git a/estate/wizard/__init__.py b/estate/wizard/__init__.py new file mode 100644 index 0000000000..d81e4d075b --- /dev/null +++ b/estate/wizard/__init__.py @@ -0,0 +1 @@ +from . import add_offers_wizard diff --git a/estate/wizard/add_offers_wizard.py b/estate/wizard/add_offers_wizard.py new file mode 100644 index 0000000000..76729d1f78 --- /dev/null +++ b/estate/wizard/add_offers_wizard.py @@ -0,0 +1,25 @@ +from odoo import fields, models + + +class addofferproperties(models.TransientModel): + _name = "add.offers.wizard" + _description = "wizard for adding offers to properties" + + price = fields.Float(required=True) + status = fields.Selection( + [("Accepted", "Accepted"), ("Refused", "Refused")], string="Status", copy=False + ) + buyer_id = fields.Many2one("res.partner", string="Buyer", required=True) + + def add_offer_properties(self): + active_ids = self.env.context.get("active_ids", []) + properties = self.env["estate.property"].browse(active_ids) + for ele in properties: + self.env["estate.property.offer"].create( + { + "property_id": ele.id, + "price": self.price, + "status": self.status, + "partner_id": self.buyer_id.id, + } + ) diff --git a/estate/wizard/wizard_view.xml b/estate/wizard/wizard_view.xml new file mode 100644 index 0000000000..d23465c469 --- /dev/null +++ b/estate/wizard/wizard_view.xml @@ -0,0 +1,28 @@ + + + add offers to properties + add.offers.wizard + form + + + add.offer.form.view.wizard + add.offers.wizard + +
+ + + + + + + +