Skip to content

Commit

Permalink
[IMP] estate: implemented the Wizard and Access Right to agent and Ma…
Browse files Browse the repository at this point in the history
…nager

- Implemented the Wizard to add Offer on multiple properties
- Created Agent and Manger
- Implemented the Access Right to Agent and Manager
  • Loading branch information
amya-odoo committed Aug 29, 2024
1 parent 50bb5db commit c41eaf3
Show file tree
Hide file tree
Showing 12 changed files with 126 additions and 8 deletions.
1 change: 1 addition & 0 deletions estate/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from . import models
from . import controller
from . import wizard
3 changes: 3 additions & 0 deletions estate/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion estate/demo/estate_property_demo.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<odoo>
<data>
<data noupdate="1">
<record id="id1" model="estate.property">
<field name="name">Big Villa</field>
<field name="state">new</field>
Expand Down
7 changes: 7 additions & 0 deletions estate/models/estate_property.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
18 changes: 14 additions & 4 deletions estate/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -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
38 changes: 38 additions & 0 deletions estate/security/security.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<odoo>
<record id="estate_group_user" model="res.groups">
<field name="name">Agent</field>
<field name="category_id" ref="base.module_category_real_estate_brokerage"/>
</record>
<record id="estate_group_manager" model="res.groups">
<field name="name">Manager</field>
<field name="category_id" ref="base.module_category_real_estate_brokerage"/>
<field name="implied_ids" eval="[(4, ref('estate_group_user'))]"/>
</record>

<record id="rule_estate_group_user" model="ir.rule">
<field ref="model_estate_property" name="model_id"/>
<field name="name">Agent permissions</field>
<field name="perm_unlink" eval="False"/>
<field name="groups" eval="[Command.link(ref('estate.estate_group_user'))]"/>
<field name="domain_force">['|', ('salesman_id', '=', user.id), ('salesman_id', '=', False)]</field>
</record>

<record id="rule_estate_group_manager" model="ir.rule">
<field ref="model_estate_property" name="model_id"/>
<field name="name">Manager permissions</field>
<field name="perm_unlink" eval="False"/>
<field name="groups" eval="[Command.link(ref('estate.estate_group_manager'))]"/>
</record>

<record model="ir.rule" id="estate_property_companies_rule">
<field name="name">Multi Compaines</field>
<field name="model_id" ref="model_estate_property"/>
<field name="global" eval="True"/>
<field name="domain_force">[
'|', ('company_id', '=', False),
('company_id', 'in', company_ids)]
</field>
</record>


</odoo>
2 changes: 1 addition & 1 deletion estate/views/estate_menus.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<menuitem id="estate_property_first_level_menu" name="Advertisment">
<menuitem id="estate_property_model_menu_action" action="estate_property_action"/>
</menuitem>
<menuitem id="estate_property_type_level_menu" name="Setting">
<menuitem id="estate_property_type_level_menu" name="Setting" groups="estate.estate_group_manager">
<menuitem id="estate_property_type_menu_action" action="estate_property_type_action"/>
<menuitem id="estate_property_tag_menu_action" action="estate_property_tag_action"/>
</menuitem>
Expand Down
8 changes: 7 additions & 1 deletion estate/views/estate_property_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@
<record id="action_account_estate_property_tree" model="ir.ui.view">
<field name="name">estate_property_tree</field>
<field name="model">estate.property</field>

<field name="arch" type="xml">
<tree decoration-success="state in ('offer_accepted', 'Offer Accepted') or state in ('offer_recived', 'Offer Recieved')" decoration-bf="state in ('offer_accepted', 'Offer Accepted')" decoration-muted="state == 'sold'">
<header>
<button name="%(estate.estate_properties_add_offer)d" type="action" string="Add Offer" class="btn-secondary"/>
</header>
<field name="name" string="Title"/>
<field name="postcode"/>
<field name="bedrooms"/>
Expand Down Expand Up @@ -51,10 +54,13 @@
<field name="property_image" widget="image" class="oe_avatar" />

</h1>

<field name="tag_ids" widget="many2many_tags" options="{'color_field': 'color'}" />

</div>
<group>
<group >
<field name="company_id"/>
<field name='state' string='status'/>
<field name="property_type_id" options="{'no_create': true}"/>
<field name="postcode" class="o_stat_value"/>
Expand Down
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 estate_property_add_offer
24 changes: 24 additions & 0 deletions estate/wizard/estate_property_add_offer.py
Original file line number Diff line number Diff line change
@@ -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,
})
25 changes: 25 additions & 0 deletions estate/wizard/estate_property_wizard.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<odoo>
<record id="estate_properties_add_offer" model="ir.actions.act_window">
<field name="name">Add Offer</field>
<field name="res_model">add.offer</field>
<field name="view_mode">form</field>
</record>

<record id='estate_properties_add_offer_form' model='ir.ui.view'>
<field name="name">estate_property_offer_form</field>
<field name="model">add.offer</field>
<field name="arch" type="xml">
<form >
<group>
<field name='price'/>
<field name='buyer_id'/>
<field name='validity'/>
</group>
<footer>
<button name="add_offer" type="object" id="create_invoice_open" string="Make an offer" class="btn-primary" data-hotkey="q"/>
<button string="Cancel" class="btn-secondary" special="cancel" data-hotkey="x"/>
</footer>
</form>
</field>
</record>
</odoo>
5 changes: 4 additions & 1 deletion estate_account/models/estate_property.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -38,4 +40,5 @@ def status_action_sold_button(self):
],
}
)
logging.info("Successfully created")
return super().status_action_sold_button()

0 comments on commit c41eaf3

Please sign in to comment.