diff --git a/estate/controllers/estate_website.py b/estate/controllers/estate_website.py index 12a491ff10..f6701eecb9 100644 --- a/estate/controllers/estate_website.py +++ b/estate/controllers/estate_website.py @@ -6,7 +6,7 @@ class EstateWebsite(http.Controller): @http.route( ["/properties", "/properties/page/"], type="http", - auth="user", + auth="public", website=True, ) def list_properties(self, page=1, **kwargs): @@ -28,12 +28,16 @@ def list_properties(self, page=1, **kwargs): ) ) - total_properties = request.env["estate.property"].sudo().search_count( - [ - "&", - ("status", "in", ["new", "offer_received", "offer_accepted"]), - ("active", "=", True), - ] + total_properties = ( + request.env["estate.property"] + .sudo() + .search_count( + [ + "&", + ("status", "in", ["new", "offer_received", "offer_accepted"]), + ("active", "=", True), + ] + ) ) pager = request.website.pager( @@ -49,7 +53,7 @@ def list_properties(self, page=1, **kwargs): @http.route( "/property/", type="http", - auth="user", + auth="public", website=True, ) def property_detail(self, property, **kwargs): diff --git a/estate/models/estate_property.py b/estate/models/estate_property.py index 78776f2fa6..b0212386c7 100644 --- a/estate/models/estate_property.py +++ b/estate/models/estate_property.py @@ -1,8 +1,9 @@ -from odoo import models, fields, api -from odoo.exceptions import UserError from datetime import datetime from dateutil.relativedelta import relativedelta +from odoo import api, fields, models +from odoo.exceptions import UserError + class EstateProperty(models.Model): _name = "estate.property" @@ -18,7 +19,6 @@ class EstateProperty(models.Model): expected_price = fields.Float(required=True) selling_price = fields.Float(readonly=True, copy=False) bedrooms = fields.Integer() - living_area = fields.Integer() facades = fields.Integer() garage = fields.Boolean() @@ -60,6 +60,7 @@ class EstateProperty(models.Model): "res.company", default=lambda self: self.env.company, required=True ) image = fields.Image("Image") + _sql_constraints = [ ( "check_expected_price", @@ -138,7 +139,4 @@ def action_make_offer(self): "target": "new", "view_mode": "form", "res_model": "estate.property.make.offer", - "context": { - "default_property_ids": self.ids, - }, } diff --git a/estate/models/estate_property_offer.py b/estate/models/estate_property_offer.py index 5951f77a29..f56085b2b7 100644 --- a/estate/models/estate_property_offer.py +++ b/estate/models/estate_property_offer.py @@ -1,8 +1,9 @@ -from odoo import models, fields, api from datetime import datetime from dateutil.relativedelta import relativedelta -from odoo.tools.float_utils import float_compare + +from odoo import api, fields, models from odoo.exceptions import ValidationError +from odoo.tools.float_utils import float_compare class EstatePropertyOffer(models.Model): diff --git a/estate/models/estate_property_tags.py b/estate/models/estate_property_tags.py index 13b7896a4b..4a4613a255 100644 --- a/estate/models/estate_property_tags.py +++ b/estate/models/estate_property_tags.py @@ -1,6 +1,7 @@ -from odoo import models, fields import random +from odoo import fields, models + class EstatePropertyTags(models.Model): _name = "estate.property.tags" diff --git a/estate/models/estate_property_type.py b/estate/models/estate_property_type.py index 2b052175c3..591babfc61 100644 --- a/estate/models/estate_property_type.py +++ b/estate/models/estate_property_type.py @@ -1,4 +1,4 @@ -from odoo import models, fields +from odoo import fields, models class EstatePropertyType(models.Model): @@ -8,14 +8,15 @@ class EstatePropertyType(models.Model): name = fields.Char(required=True) property_ids = fields.One2many("estate.property", "property_type_id") - _sql_constraints = [ - ("name_uniq", "unique(name)", "Type must be unique"), - ] offer_ids = fields.One2many( comodel_name="estate.property.offer", inverse_name="property_type_id" ) offer_count = fields.Integer(compute="_compute_offer_count") + _sql_constraints = [ + ("name_uniq", "unique(name)", "Type must be unique"), + ] + def _compute_offer_count(self): for record in self: record.offer_count = len(record.offer_ids) diff --git a/estate/models/inherited_users.py b/estate/models/inherited_users.py index 78d0013752..422156b5cd 100644 --- a/estate/models/inherited_users.py +++ b/estate/models/inherited_users.py @@ -1,6 +1,11 @@ -from odoo import models, fields +from odoo import fields, models + class inheritedUser(models.Model): - _inherit = 'res.users' - - property_ids=fields.One2many('estate.property', 'salesman_id',domain=[('status','not in',["sold","canceled"])]) + _inherit = "res.users" + + property_ids = fields.One2many( + "estate.property", + "salesman_id", + domain=[("status", "not in", ["sold", "canceled"])], + ) diff --git a/estate/security/estate_security.xml b/estate/security/estate_security.xml index ff92dd1d87..9c5e845ba6 100644 --- a/estate/security/estate_security.xml +++ b/estate/security/estate_security.xml @@ -28,7 +28,7 @@ Estate Manager rules for all properties - [] + [(1,'=',1)] diff --git a/estate/views/estate_property_offer_views.xml b/estate/views/estate_property_offer_views.xml index d10823fd98..5c955b5d68 100644 --- a/estate/views/estate_property_offer_views.xml +++ b/estate/views/estate_property_offer_views.xml @@ -1,6 +1,5 @@ - Estate Property Offer estate.property.offer @@ -25,7 +24,7 @@ - + estate_property_offer.view.form estate.property.offer diff --git a/estate/views/estate_property_tags_views.xml b/estate/views/estate_property_tags_views.xml index c6d3b59912..23dc6dd4f1 100644 --- a/estate/views/estate_property_tags_views.xml +++ b/estate/views/estate_property_tags_views.xml @@ -1,6 +1,5 @@ - property tag @@ -27,5 +26,4 @@ - diff --git a/estate/views/estate_property_type_views.xml b/estate/views/estate_property_type_views.xml index 027f5ca5f6..c696a297e7 100644 --- a/estate/views/estate_property_type_views.xml +++ b/estate/views/estate_property_type_views.xml @@ -1,6 +1,5 @@ - property type @@ -16,7 +15,6 @@ - estate_property_type.view.form diff --git a/estate/views/estate_property_views.xml b/estate/views/estate_property_views.xml index a09017a45e..ed5d0c2e01 100644 --- a/estate/views/estate_property_views.xml +++ b/estate/views/estate_property_views.xml @@ -49,14 +49,17 @@ - -

- -

- - - + + +

+ +

+ +
+ + +
diff --git a/estate/views/estate_website_template.xml b/estate/views/estate_website_template.xml index c5156a99af..503bab8615 100644 --- a/estate/views/estate_website_template.xml +++ b/estate/views/estate_website_template.xml @@ -6,32 +6,29 @@
@@ -87,8 +84,8 @@ Expected Price: - - $ + $ +
@@ -110,8 +107,8 @@ Living Area: - - m² + m² +
  • @@ -137,8 +134,8 @@ Garden Area: - - m² + m² +
  • @@ -151,8 +148,8 @@ Total Area: - - m² + m² +
  • @@ -160,6 +157,4 @@ - - diff --git a/estate/wizard/estate_property_make_offer.py b/estate/wizard/estate_property_make_offer.py index a16734acb8..cd6b9f7793 100644 --- a/estate/wizard/estate_property_make_offer.py +++ b/estate/wizard/estate_property_make_offer.py @@ -1,4 +1,4 @@ -from odoo import models, fields +from odoo import fields, models class EstatePropertyMakeOffer(models.TransientModel): @@ -12,18 +12,18 @@ class EstatePropertyMakeOffer(models.TransientModel): def make_offer(self): failed_properties = [] - for property in self.property_ids: + for property in self.env.context.get("active_ids"): try: self.env["estate.property.offer"].create( { "price": self.offer_price, - "property_id": property.id, + "property_id": property, "partner_id": self.partner_id.id, "validity": self.offer_validity, } ) except Exception: - failed_properties.append(property.name) + failed_properties.append(str(property)) if failed_properties: return { "type": "ir.actions.client", diff --git a/estate/wizard/estate_property_wizard_view.xml b/estate/wizard/estate_property_wizard_view.xml index 163a7ef697..00974a38a8 100644 --- a/estate/wizard/estate_property_wizard_view.xml +++ b/estate/wizard/estate_property_wizard_view.xml @@ -1,6 +1,5 @@ - estate_property_make_offer.view.form estate.property.make.offer @@ -18,5 +17,4 @@
    - diff --git a/estate_account/__manifest__.py b/estate_account/__manifest__.py index 2de528ea0c..f2e13bf82b 100644 --- a/estate_account/__manifest__.py +++ b/estate_account/__manifest__.py @@ -10,9 +10,8 @@ "website": "https://www.odoo.com", "category": "Tutorials/Estate_Account", "version": "0.1", - "application": True, "installable": True, - "depends": ["base_setup","estate","account"], + "depends": ["base_setup", "estate", "account"], "data": [], "license": "AGPL-3", } diff --git a/estate_account/models/estate_property.py b/estate_account/models/estate_property.py index dc9a3376bf..8d75d40fb2 100644 --- a/estate_account/models/estate_property.py +++ b/estate_account/models/estate_property.py @@ -1,4 +1,4 @@ -from odoo import models, fields, Command +from odoo import Command, fields, models class InheritedModel(models.Model):