Skip to content

Commit

Permalink
[ADD] estate_offer_wizard: implemented wizard for adding offers to pr…
Browse files Browse the repository at this point in the history
…operties.

- 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.
  • Loading branch information
koye-odoo committed Sep 30, 2024
1 parent 17a5e88 commit 2a8358d
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 5 deletions.
1 change: 1 addition & 0 deletions estate/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from . import models
from . import demo
from . import data
from . import wizard
5 changes: 3 additions & 2 deletions estate/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
3 changes: 2 additions & 1 deletion estate/security/ir.model.access.csv
Original file line number Diff line number Diff line change
Expand Up @@ -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
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
9 changes: 7 additions & 2 deletions estate/views/estate_property_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@
decoration-success="status=='Offer Received'or status=='Offer Accepted'"
decoration-bf="status=='Offer Accepted'"
decoration-muted="status=='Sold'">
<header>
<button name="%(estate.action_add_offer_properties)d" type="action"
string="Add Offer"
class="btn btn-primary" />
</header>
<field name="status" optional="hide" />
<field name="title" />
<field name="property_type_id" />
Expand Down Expand Up @@ -49,7 +54,7 @@
<field name="status" />
<field name="property_type_id" options="{'no_create': True, 'no_edit': True}" />
<field name="Postcode" />
<field name="company_id"/>
<field name="company_id" />
<field name="date_availability" />
</group>
<group>
Expand Down Expand Up @@ -136,4 +141,4 @@
</kanban>
</field>
</record>
</odoo>
</odoo>
1 change: 1 addition & 0 deletions estate/wizard/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import add_offers_wizard
25 changes: 25 additions & 0 deletions estate/wizard/add_offers_wizard.py
Original file line number Diff line number Diff line change
@@ -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,
}
)
28 changes: 28 additions & 0 deletions estate/wizard/wizard_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<odoo>
<record id="action_add_offer_properties" model="ir.actions.act_window">
<field name="name">add offers to properties</field>
<field name="res_model">add.offers.wizard</field>
<field name="view_mode">form</field>
</record>
<record id="add_offer_form_view_wizard" model="ir.ui.view">
<field name="name">add.offer.form.view.wizard</field>
<field name="model">add.offers.wizard</field>
<field name="arch" type="xml">
<form>
<sheet>
<group>
<field name="price"></field>
<field name="status"></field>
<field name="buyer_id"></field>
</group>
<group>
<button name="add_offer_properties" type="object" string="Make an offer"
class="btn-primary" />
<button string="Cancel" class="btn-secondary" special="cancel"
data-hotkey="x" />
</group>
</sheet>
</form>
</field>
</record>
</odoo>

0 comments on commit 2a8358d

Please sign in to comment.