Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ADD] estate: add real estate module #221

Draft
wants to merge 22 commits into
base: 18.0
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
b1dd482
[ADD] estate_module: estate module added with basic model and views
nipl-odoo Jan 2, 2025
fa90e2e
[IMP] estate: added Business logic in estate module buttons
nipl-odoo Jan 2, 2025
97fb4f9
[IMP] estate: Added Proper validation in all actions and UI
nipl-odoo Jan 3, 2025
2574d72
[IMP] estate: added ui bug fixes and inheritance
nipl-odoo Jan 6, 2025
e984273
[IMP] estate: finished chapter 12
nipl-odoo Jan 7, 2025
92c5207
[IMP] estate: removed unnecessory access from csv
nipl-odoo Jan 7, 2025
62402fd
[IMP] estate: finished server framework 101 tutorials
nipl-odoo Jan 7, 2025
9542868
[IMP] estate: added demo data
nipl-odoo Jan 8, 2025
743b5a0
[ADD] estate: added pdf reports
nipl-odoo Jan 9, 2025
6da58e7
[IMP] estate: fixed offer action button bugs
nipl-odoo Jan 10, 2025
1d89221
[IMP] estate,estate_account: added ACL
nipl-odoo Jan 10, 2025
cabbc56
[IMP] estate: added company based property access and wizard
nipl-odoo Jan 13, 2025
90904ed
[IMP] estate: fixed bulk offer bug and added controller
nipl-odoo Jan 13, 2025
c37c5cb
[IMP] estate: added pager and property details page
nipl-odoo Jan 15, 2025
4907827
[IMP] estate: minor optimization
nipl-odoo Jan 15, 2025
13455c5
[IMP] estate,estate_acoount: minor changes for github error
nipl-odoo Jan 16, 2025
28a21db
[IMP] estate: added images in demo data
nipl-odoo Jan 16, 2025
1261bf9
[IMP] estate: add nav item on estate installation
nipl-odoo Jan 16, 2025
17d0010
[IMP] estate: minor PR changes
nipl-odoo Jan 17, 2025
fb4bc2d
[ADD] supplier_portal: add supplier portal module
nipl-odoo Jan 21, 2025
8041e04
[ADD] event_ticket_limit: add event ticket limiting module
nipl-odoo Jan 21, 2025
33db4df
[ADD] budget_management: add budget management module
nipl-odoo Jan 27, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"python.analysis.typeCheckingMode": "standard",
"python.languageServer": "None"
}
2 changes: 2 additions & 0 deletions budget_management/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import models
from . import wizard
19 changes: 19 additions & 0 deletions budget_management/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "Budget Management",
"summary": "Module for managing budgets",
"description": "Module for managing budgets",
"category": "Account/ Budget Management",
"version": "1.0",
"application": True,
"installable": True,
"depends": ["base", "analytic"],
"data": [
"security/ir.model.access.csv",
"views/analytic_line_views.xml",
"views/budget_budget_line_views.xml",
"views/budget_budget_views.xml",
"views/budget_budget_menu_views.xml",
"wizard/budget_wizard_views.xml",
],
"license": "AGPL-3",
}
3 changes: 3 additions & 0 deletions budget_management/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from . import budget_line
from . import budget_budget
from . import analytic_line
9 changes: 9 additions & 0 deletions budget_management/models/analytic_line.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from odoo import fields, models


class AnalyticLine(models.Model):
_inherit = "account.analytic.line"

budget_line_id = fields.Many2one(
"budget.budget.line", "Budget Line", ondelete="cascade"
)
140 changes: 140 additions & 0 deletions budget_management/models/budget_budget.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
from markupsafe import Markup

from odoo import api, fields, models
from odoo.exceptions import ValidationError


class BudgetBudget(models.Model):
_name = "budget.budget"
_description = "Budget"
_inherit = ["mail.thread", "mail.activity.mixin"]

name = fields.Char(compute="_compute_name")
date_from = fields.Date(required=True)
date_to = fields.Date(required=True)
color = fields.Integer(string="Color Index")
active = fields.Boolean(default=True)
show_warning = fields.Boolean(default=False, compute="_compute_show_warning")
state = fields.Selection(
[
("draft", "Draft"),
("confirmed", "Confirmed"),
("revised", "Revised"),
("done", "Done"),
],
default="draft",
)
action_over_budget = fields.Selection(
[("warning", "Warning"), ("restrict", "Restrict")],
default="warning",
)
user_id = fields.Many2one("res.users", string="Responsible")
company_id = fields.Many2one("res.company", string="Company")
parent_id = fields.Many2one(
string="Revision Of",
comodel_name="budget.budget",
ondelete="cascade",
)
budget_line_ids = fields.One2many(
"budget.budget.line", "budget_id", string="Budget lines"
)
children_ids = fields.One2many(
string="Revisions",
comodel_name="budget.budget",
inverse_name="parent_id",
)

@api.constrains("date_from", "date_to")
def _check_dates(self):
for budget in self:
if (
budget.date_from
and budget.date_to
and budget.date_from > budget.date_to
):
raise ValidationError("The start date must be before the end date.")

# period must be unique for all active budget
@api.constrains("date_from", "date_to")
def _check_date(self):
for budget in self:
if budget.date_from and budget.date_to:
existing_budgets = self.search(
[
("date_from", "=", budget.date_to),
("date_to", "=", budget.date_from),
("active", "=", True),
("id", "!=", budget.id),
]
)
if existing_budgets:
raise ValidationError(
"Budget period must be unique for all active budgets."
)

@api.depends("budget_line_ids.achieved_amount")
def _compute_show_warning(self):
for record in self:
if record.action_over_budget == "warning" and any(
ob.achieved_amount > ob.amount for ob in record.budget_line_ids
):
record.show_warning = True
else:
record.show_warning = False

@api.depends("name", "date_from", "date_to")
def _compute_name(self):
for budget in self:
if budget.date_from and budget.date_to:
budget.name = "Budget: %s - %s " % (
budget.date_from.__format__("%d/%m/%Y"),
budget.date_to.__format__("%d/%m/%Y"),
)
else:
budget.name = "Budget: (from) - (to)"

def action_budget_confirm(self):
self.parent_id.filtered(lambda b: b.state == "confirmed").state = "revised"
for budget in self:
budget.state = "revised" if budget.children_ids else "confirmed"

def action_budget_draft(self):
self.state = "draft"

def action_budget_done(self):
self.state = "done"

def create_revised_budget(self):
revised = self.browse()
for budget in self:
budget.state = "revised"
budget.active = False
revised_budget = budget.copy(
default={
"name": budget.name,
"parent_id": budget.id,
"active": True,
}
)

revised += revised_budget
budget.message_post(
body=Markup(
"%s: <a href='#' data-oe-model='budget.budget' data-oe-id='%s'>%s</a>"
)
% (
"New revision",
revised_budget.id,
revised_budget.name,
)
)
return revised._get_records_action()

def action_open_budget_lines(self):
return {
"name": "Budget Lines",
"view_mode": "list,graph,pivot,gantt",
"res_model": "budget.budget.line",
"type": "ir.actions.act_window",
"domain": [("budget_id", "=", self.id)],
}
68 changes: 68 additions & 0 deletions budget_management/models/budget_line.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
from odoo import api, fields, models
from odoo.exceptions import ValidationError


class BudgetLine(models.Model):
_name = "budget.budget.line"
_description = "Budget Budget Line"

name = fields.Char("Description", default="Budget Line")
amount = fields.Float("Budget Amount", required=True)
achieved_amount = fields.Float(
"Achieved Amount", compute="_compute_achieved_amount", store=True
)
achieved_percent = fields.Float("Achieved %", compute="_compute_achieved_percent")
date_from = fields.Date(related="budget_id.date_from")
date_to = fields.Date(related="budget_id.date_to")
sequence = fields.Integer("Sequence", default=1)
budget_id = fields.Many2one("budget.budget", required=True)
account_id = fields.Many2one("account.analytic.account", "Account")
user_id = fields.Many2one(related="budget_id.user_id")
analytic_line_ids = fields.One2many(
"account.analytic.line", "budget_line_id", string="Analytic Lines"
)

@api.constrains("achieved_amount", "amount")
def _check_restriction_on_creation(self):
for record in self:
if record.budget_id.action_over_budget == "restrict":
if record.achieved_amount > record.amount:
raise ValidationError(
"Achieved amount cannot exceed amount when 'Restriction' is selected."
)

@api.depends("amount", "achieved_amount")
def _compute_achieved_percent(self):
for line in self:
if line.account_id and line.amount:
line.achieved_percent = (line.achieved_amount) / line.amount * 100
else:
line.achieved_percent = 0

@api.depends(
"analytic_line_ids.amount",
)
def _compute_achieved_amount(self):
for record in self:
total_achieved = abs(
sum(
record.analytic_line_ids.filtered(lambda l: l.amount < 0).mapped(
"amount"
)
)
)
record.achieved_amount = total_achieved

def action_open_analytic_lines(self):
return {
"type": "ir.actions.act_window",
"name": "Analytic Lines",
"res_model": "account.analytic.line",
"view_mode": "list",
"target": "new",
"context": {
"default_account_id": self.account_id.id,
"default_date": self.budget_id.date_from,
"default_budget_line_id": self.id,
},
}
4 changes: 4 additions & 0 deletions budget_management/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
id,name,model_id/id,group_id/id,perm_read,perm_write,perm_create,perm_unlink
budget_management.access_budget_budget_line,access_budget_budget_line,budget_management.model_budget_budget_line,base.group_user,1,1,1,1
budget_management.access_budget_budget,access_budget_budget,budget_management.model_budget_budget,base.group_user,1,1,1,1
budget_management.access_budget_wizard,access_budget_wizard,budget_management.model_budget_wizard,base.group_user,1,1,1,1
7 changes: 7 additions & 0 deletions budget_management/static/.comments/logo.png.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<comment version="3.0">
<caption/>
<note>Piggy bank and dollar coin icon thin line for web and mobile, modern minimalistic flat design. Vector icon with dark grey outline and offset colour on light grey background.</note>
<place/>
<categories/>
</comment>
Binary file added budget_management/static/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions budget_management/views/analytic_line_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>

<record id="view_account_analytic_line_tree_inherit_module_name" model="ir.ui.view">
<field name="name">account.analytic.line.view.list.inherit</field>
<field name="model">account.analytic.line</field>
<field name="inherit_id" ref="analytic.view_account_analytic_line_tree"/>
<field name="arch" type="xml">
<xpath expr="//list" position="inside">
<field name="budget_line_id" optional="hide"></field>
</xpath>

<xpath expr="//list" position="attributes">
<attribute name="editable">bottom</attribute>
</xpath>
</field>
</record>

</odoo>
66 changes: 66 additions & 0 deletions budget_management/views/budget_budget_line_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>

<record id="budget_budget_line_action" model="ir.actions.act_window">
<field name="name">Budget Lines</field>
<field name="res_model">budget.budget.line</field>
<field name="view_mode">list,graph,gantt,pivot</field>
<field name="context">[('budget_id','=',active_id)]</field>
<field name="help" type="html">
<p class="o_view_nocontent_smiling_face">
Define new budget line
</p>
<p>
Use options specified in form to list budget line
</p>
</field>
</record>

<record id="budget_budget_line_view_list" model="ir.ui.view">
<field name="name">budget.budget.line.view.list</field>
<field name="model">budget.budget.line</field>
<field name="arch" type="xml">
<list string="Budget Line">
<field name="sequence" widget="handle"/>
<field name="name"/>
<field name="account_id" optional="show"/>
<field name="amount" />
<field name="achieved_amount" decoration-danger="(achieved_amount > amount)" />
</list>
</field>
</record>

<record id="budget_budget_line_view_graph" model="ir.ui.view">
<field name="name">budget.line.graph</field>
<field name="model">budget.budget.line</field>
<field name="arch" type="xml">
<graph string="Budget Line" type="bar" stacked="true">
<field name="name" type="row"/>
<field name="achieved_amount" />
<field name="amount" type="measure"/>
</graph>
</field>
</record>

<record id="budget_budget_line_view_gantt" model="ir.ui.view">
<field name="name">budget.line.gantt.view</field>
<field name="model">budget.budget.line</field>
<field name="arch" type="xml">
<gantt default_group_by="name" progress="achieved_percent" date_start="date_from" date_stop="date_to" string="Budget Lines" color="id">
<field name="name"/>
</gantt>
</field>
</record>


<record id="budget_budget_line_view_pivot" model="ir.ui.view">
<field name="name">budget.line.pivot</field>
<field name="model">budget.budget.line</field>
<field name="arch" type="xml">
<pivot string="Budget Lines">
<field name="name" type="row"/>
</pivot>
</field>
</record>

</odoo>
7 changes: 7 additions & 0 deletions budget_management/views/budget_budget_menu_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>

<menuitem id="budget_management_menu" name="Budget Management" sequence="10" web_icon="budget_management,static/logo.png"/>
<menuitem id="budget_budget_menu" name="Budgets" parent="budget_management_menu" action="budget_management.budget_budget_action" sequence="10"/>

</odoo>
Loading