From c41eaf36e8f6e8bbd07499f63fcee7fbe3a23da1 Mon Sep 17 00:00:00 2001 From: amrendra yadav Date: Thu, 29 Aug 2024 11:31:02 +0530 Subject: [PATCH] [IMP] estate: implemented the Wizard and Access Right to agent and Manager - Implemented the Wizard to add Offer on multiple properties - Created Agent and Manger - Implemented the Access Right to Agent and Manager --- estate/__init__.py | 1 + estate/__manifest__.py | 3 ++ estate/demo/estate_property_demo.xml | 2 +- estate/models/estate_property.py | 7 ++++ estate/security/ir.model.access.csv | 18 +++++++--- estate/security/security.xml | 38 ++++++++++++++++++++++ estate/views/estate_menus.xml | 2 +- estate/views/estate_property_views.xml | 8 ++++- estate/wizard/__init__.py | 1 + estate/wizard/estate_property_add_offer.py | 24 ++++++++++++++ estate/wizard/estate_property_wizard.xml | 25 ++++++++++++++ estate_account/models/estate_property.py | 5 ++- 12 files changed, 126 insertions(+), 8 deletions(-) create mode 100644 estate/security/security.xml create mode 100644 estate/wizard/__init__.py create mode 100644 estate/wizard/estate_property_add_offer.py create mode 100644 estate/wizard/estate_property_wizard.xml diff --git a/estate/__init__.py b/estate/__init__.py index 5607426d8a..317272f8ba 100644 --- a/estate/__init__.py +++ b/estate/__init__.py @@ -1,2 +1,3 @@ from . import models from . import controller +from . import wizard diff --git a/estate/__manifest__.py b/estate/__manifest__.py index fa4b72f521..88c7a4f320 100644 --- a/estate/__manifest__.py +++ b/estate/__manifest__.py @@ -5,13 +5,16 @@ "description": "Technical practice", "installable": True, "application": True, + "category": "Real Estate/Brokerage", "data": [ + "security/security.xml", "security/ir.model.access.csv", "data/estate.property.type.csv", "report/estate_property_templates.xml", "report/estate_propert_web_template.xml", "report/estate_property_report.xml", "views/res_user_views.xml", + "wizard/estate_property_wizard.xml", "views/estate_property_views.xml", "views/estate_property_offer_view.xml", "views/estate_property_type.xml", diff --git a/estate/demo/estate_property_demo.xml b/estate/demo/estate_property_demo.xml index ec75594f71..fbacac1eff 100644 --- a/estate/demo/estate_property_demo.xml +++ b/estate/demo/estate_property_demo.xml @@ -1,5 +1,5 @@ - + Big Villa new diff --git a/estate/models/estate_property.py b/estate/models/estate_property.py index 003a74c11a..eb90c75646 100644 --- a/estate/models/estate_property.py +++ b/estate/models/estate_property.py @@ -9,6 +9,13 @@ class EstateProperty(models.Model): _description = "Real Estate Property Data" _inherit = ["mail.thread", "mail.activity.mixin"] name = fields.Char(required=True) + company_id = fields.Many2one( + "res.company", + string="Company", + required=True, + readonly=False, + default=lambda self: self.env.company, + ) description = fields.Char() postcode = fields.Char() date_availability = fields.Date( diff --git a/estate/security/ir.model.access.csv b/estate/security/ir.model.access.csv index c9494289c0..e7c0fdd6ec 100644 --- a/estate/security/ir.model.access.csv +++ b/estate/security/ir.model.access.csv @@ -1,6 +1,16 @@ "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 +access_estate_property,access_estate_property,model_estate_property,base.group_user,1,0,0,0 +estate.access_estate_property_type,access_estate_property_type,estate.model_estate_property_type,base.group_user,1,0,0,0 +estate.access_estate_property_tag,access_estate_property_tag,estate.model_estate_property_tag,base.group_user,1,0,0,0 +estate.access_estate_property_offer,access_estate_property_offer,estate.model_estate_property_offer,base.group_user,1,0,0,0 +estate.access_add_offer,access_add_offer,estate.model_add_offer,base.group_user,1,0,0,0 +access_estate_property_group_user,access_estate_property_group_user,model_estate_property,estate.estate_group_user,1,1,1,0 +estate.access_estate_property_type_group_user,access_estate_property_type_group_user,estate.model_estate_property_type,estate.estate_group_user,1,0,0,0 +estate.access_estate_property_tag_group_user,access_estate_property_tag_group_user,estate.model_estate_property_tag,estate.estate_group_user,1,0,0,0 + +access_estate_property_manager,access_estate_property_manager,model_estate_property,estate.estate_group_manager,1,1,1,0 +estate.access_estate_property_type_manager,access_estate_property_type_manager,estate.model_estate_property_type,estate.estate_group_manager,1,1,1,1 +estate.access_estate_property_tag_manager,access_estate_property_tag_manager,estate.model_estate_property_tag,estate.estate_group_manager,1,1,1,1 +estate.access_estate_property_offer_manager,access_estate_property_offer_manager,estate.model_estate_property_offer,estate.estate_group_manager,1,1,1,1 +estate.access_add_offer_manager,access_add_offer_manager,estate.model_add_offer,estate.estate_group_manager,1,1,1,1 diff --git a/estate/security/security.xml b/estate/security/security.xml new file mode 100644 index 0000000000..37670fb473 --- /dev/null +++ b/estate/security/security.xml @@ -0,0 +1,38 @@ + + + Agent + + + + Manager + + + + + + + Agent permissions + + + ['|', ('salesman_id', '=', user.id), ('salesman_id', '=', False)] + + + + + Manager permissions + + + + + + Multi Compaines + + + [ + '|', ('company_id', '=', False), + ('company_id', 'in', company_ids)] + + + + + diff --git a/estate/views/estate_menus.xml b/estate/views/estate_menus.xml index ab84e5e5e5..583eeb78a4 100644 --- a/estate/views/estate_menus.xml +++ b/estate/views/estate_menus.xml @@ -3,7 +3,7 @@ - + diff --git a/estate/views/estate_property_views.xml b/estate/views/estate_property_views.xml index 6c7fcff24e..6763456a83 100644 --- a/estate/views/estate_property_views.xml +++ b/estate/views/estate_property_views.xml @@ -14,9 +14,12 @@ estate_property_tree estate.property - + +
+
@@ -51,10 +54,13 @@ + + + diff --git a/estate/wizard/__init__.py b/estate/wizard/__init__.py new file mode 100644 index 0000000000..8dd2815351 --- /dev/null +++ b/estate/wizard/__init__.py @@ -0,0 +1 @@ +from . import estate_property_add_offer diff --git a/estate/wizard/estate_property_add_offer.py b/estate/wizard/estate_property_add_offer.py new file mode 100644 index 0000000000..8ecaf0d02f --- /dev/null +++ b/estate/wizard/estate_property_add_offer.py @@ -0,0 +1,24 @@ +from odoo import fields, models + + +class AddOffer(models.TransientModel): + _name = "add.offer" + _description = "Add Offer in mutiple property" + price = fields.Float() + validity = fields.Integer(default=7) + buyer_id = fields.Many2one( + "res.partner", + string="Buyer", + copy=False, + ) + + def add_offer(self): + context= self.env.context + active_ids = context.get('active_ids',[]) + for property in active_ids: + offer = self.env['estate.property.offer'].create({ + 'property_id': property, + 'price': self.price, + 'validity': self.validity, + 'partner_id': self.buyer_id.id, + }) diff --git a/estate/wizard/estate_property_wizard.xml b/estate/wizard/estate_property_wizard.xml new file mode 100644 index 0000000000..6faf751579 --- /dev/null +++ b/estate/wizard/estate_property_wizard.xml @@ -0,0 +1,25 @@ + + + Add Offer + add.offer + form + + + + estate_property_offer_form + add.offer + +
+ + + + + + +
+
+
+
diff --git a/estate_account/models/estate_property.py b/estate_account/models/estate_property.py index 87869a3de2..aac21ec8d8 100644 --- a/estate_account/models/estate_property.py +++ b/estate_account/models/estate_property.py @@ -8,10 +8,12 @@ class EstateProperty(models.Model): def status_action_sold_button(self): logging.info("Request to create the invoices of property") + self.check_access_rights('write') + self.check_access_rule('write') for record in self: if record.buyer_id: partner_id = record.buyer_id.id - self.env["account.move"].create( + self.env["account.move"].sudo().create( { "partner_id": partner_id, "move_type": "out_invoice", @@ -38,4 +40,5 @@ def status_action_sold_button(self): ], } ) + logging.info("Successfully created") return super().status_action_sold_button()