-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD] estate:[FIX] estate: added different functionalities and actions.
Enhanced estate module by updating estate_property model and views, adding new m odels for estate_property_offer, estate_property_tag, and estate_property_type, and refining access control and menus. Improved estate_property_views functional ity for better user experience.
- Loading branch information
Showing
8 changed files
with
331 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
from . import estate_property | ||
from . import estate_property, estate_property_type, estate_property_tag, estate_property_offer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# estate_property_offer.py | ||
from odoo import models, fields, api | ||
from datetime import timedelta | ||
from odoo.exceptions import UserError | ||
|
||
|
||
class EstatePropertyOffer(models.Model): | ||
_name = 'estate.property.offer' | ||
_description = 'Property Offer' | ||
|
||
price = fields.Float(string="Price") | ||
status = fields.Selection([('accepted', 'Accepted'), ('refused', 'Refused')], string="Status", copy=False) | ||
partner_id = fields.Many2one('res.partner', string="Partner", required=True) | ||
validity = fields.Integer(string="Validity (days)", default=7) | ||
date_deadline = fields.Date(string="Deadline", compute="_compute_date_deadline", inverse="_inverse_date_deadline") | ||
property_id = fields.Many2one('estate.property', 'Property', required=True) | ||
|
||
@api.depends('create_date', 'validity') | ||
def _compute_date_deadline(self): | ||
for record in self: | ||
if record.create_date: | ||
record.date_deadline = record.create_date + timedelta(days=record.validity) | ||
else: | ||
record.date_deadline = fields.Date.today() + timedelta(days=record.validity) | ||
|
||
def _inverse_date_deadline(self): | ||
for record in self: | ||
if record.date_deadline and record.create_date: | ||
# Convert create_date to date before subtracting | ||
create_date_date = record.create_date.date() | ||
record.validity = (record.date_deadline - create_date_date).days | ||
else: | ||
record.validity = 0 | ||
|
||
def action_confirm(self): | ||
for record in self: | ||
if record.status == 'accepted': | ||
raise UserError("This offer has already been accepted.") | ||
record.status = 'accepted' | ||
record.property_id.write({ | ||
'selling_price': record.price, | ||
'buyer_id': record.partner_id.id, | ||
'state': 'offer_accepted', | ||
}) | ||
|
||
_sql_constraints = [ | ||
('check_offer_price', 'CHECK(price > 0)', 'The offer price must be strictly positive.') | ||
] | ||
|
||
def action_cancel(self): | ||
for record in self: | ||
if record.status == 'refused': | ||
raise UserError("This offer has already been refused.") | ||
record.status = 'refused' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from odoo import models, fields | ||
|
||
|
||
class EstatePropertyTag(models.Model): | ||
_name = 'estate.property.tag' | ||
_description = 'Property Tag' | ||
|
||
name = fields.Char(string="Name", required=True) | ||
|
||
_sql_constraints = [ | ||
('unique_name', 'UNIQUE(name)', 'This property tag already exists.'), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from odoo import models, fields | ||
|
||
|
||
class EstateProperty(models.Model): | ||
_name = 'estate.property.type' | ||
_description = 'Estate Property Type' | ||
|
||
name = fields.Char(string="Name", required=True) | ||
|
||
_sql_constraints = [ | ||
('unique_name', 'UNIQUE(name)', 'This property type already exists.'), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,7 @@ | ||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink | ||
access_estate_property,access_estate_property,model_estate_property,base.group_user,1,1,1,1 | ||
estate.access_estate_property_type,access_estate_property_type,estate.model_estate_property_type,base.group_user,1,1,1,1 | ||
estate.access_estate_property_tag,access_estate_property_tag,estate.model_estate_property_tag,base.group_user,1,1,1,1 | ||
estate.access_estate_property_offer,access_estate_property_offer,estate.model_estate_property_offer,base.group_user,1,1,1,1 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,13 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<odoo> | ||
<menuitem id="test_menu_root" name="Test"> | ||
<menuitem id="estate_menu_root" name="Real Estate"> | ||
<menuitem id="Advertisements" name="Advertisements"> | ||
<menuitem id="Properties" action="action_estate_property"/> | ||
</menuitem> | ||
<menuitem id="Settings" name="Settings"> | ||
<menuitem id="Properties_Types" name="Property Types" action="action_estate_property_type"/> | ||
<menuitem id="Properties_Tags" name="Property Tags" action="action_estate_property_tag"/> | ||
|
||
</menuitem> | ||
</menuitem> | ||
</odoo> |
Oops, something went wrong.