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: added new real estate module #108

Draft
wants to merge 15 commits into
base: 17.0
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions dental/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import models
from . import controller
22 changes: 22 additions & 0 deletions dental/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "Dental",
"version": "1.0",
"license": "LGPL-3",
"summary": "Manage properties",
"depends": ["base", "mail", "account"],
"data": [
"security/ir.model.access.csv",
"views/pateint_views.xml",
"views/medical_aids_views.xml",
"views/chronic_condition.xml",
"views/habits.xml",
"views/allergies.xml",
"views/medication.xml",
"views/dental_controller.xml",
"views/patient_history.xml",
"views/menuitem.xml",
],
"installable": True,
"application": True,
"auto_install": False,
}
1 change: 1 addition & 0 deletions dental/controller/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import dental_controller
155 changes: 155 additions & 0 deletions dental/controller/dental_controller.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
from odoo import http
from odoo.http import request


class DentalController(http.Controller):
# show dental on my account
@http.route(
[
"/dental",
],
type="http",
auth="public",
website=True,
)
def show_all_the_data(self, page=1, **kwargs):
user = request.env.user
try:
page = int(page)
except ValueError:
page = 1
patient = request.env["dental.patients"].sudo()
patient_per_page = 6
total_patients = patient.search_count(
[
("guarantor_id", "=", user.partner_id.id),
]
)
total_pages = (total_patients + patient_per_page - 1) // patient_per_page
page = max(1, min(page, total_pages))
offset = (page - 1) * patient_per_page
patients = patient.search(
[
("guarantor_id", "=", user.partner_id.id),
],
limit=patient_per_page,
offset=offset,
)
return request.render(
"dental.dental_patient_view_controller",
{
"patients": patients,
"page": page,
"total_pages": total_pages,
},
)

# show all patient
@http.route(
["/patient/<int:record_id>"],
type="http",
auth="public",
website=True,
)
def show_patient_details(self, record_id, **kwargs):
data = request.env["dental.patients"].sudo().browse(record_id)
return request.render(
"dental.patient_details_view_controller",
{
"patients": data,
},
)

# show personal detail
@http.route(
["/personal/detail/<int:record_id>"],
type="http",
auth="public",
website=True,
)
def show_personal_detail(self, record_id, **kwargs):
data = request.env["dental.patients"].sudo().browse(record_id)
return request.render(
"dental.personal_detail_template",
{
"personal": data,
},
)

# show medical Aid detail
@http.route(
["/patients/medical_aid/detail/<int:record_id>"],
type="http",
auth="public",
website=True,
)
def show_medical_aid_detail(self, record_id, **kwargs):
data = request.env["dental.patients"].sudo().browse(record_id)
medical_aid_id = data.medical_aid_id.id
medical_aid = (
request.env["medical.aids"]
.sudo()
.search(
[
("id", "=", medical_aid_id),
],
)
)
return request.render(
"dental.medical_aid_detail_template",
{
"medical_aid": medical_aid,
"patient": data,
},
)

# medical history
@http.route(
["/medical/history/<int:patient_id>"],
type="http",
auth="public",
website=True,
)
def show_medical_history(self, patient_id, **kwargs):
data = request.env["dental.patients"].sudo().browse(patient_id)
history_id = data.history_id
return request.render(
"dental.portal_medical_history_template",
{"history": history_id, "patient": data},
)

# dental history
@http.route(
["/dental/history/<int:patient_id>"],
type="http",
auth="public",
website=True,
)
def show_dental_history(self, patient_id, **kwargs):
data = request.env["dental.patients"].sudo().browse(patient_id)
history_id = data.history_id
return request.render(
"dental.dental_history_view",
{
"history": history_id,
"patient": data,
},
)

# Dental_history_detail
@http.route(
["/history/detail/<int:history_id>/<int:patient_id>"],
type="http",
auth="public",
website=True,
)
def show_dental_history_detail(self, history_id, patient_id, **kwargs):
patient = request.env["dental.patients"].sudo().browse(patient_id)
data = request.env["pateint.history"].sudo().browse(history_id)
return request.render(
"dental.dental_history_detail_view",
{
"history": data,
"patient": patient,
},
)
7 changes: 7 additions & 0 deletions dental/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from . import dental_patient
from . import medical_aids
from . import chronic_condition
from . import allergies
from . import habits
from . import medication
from . import patient_history
10 changes: 10 additions & 0 deletions dental/models/allergies.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from odoo import fields, models


class AllergiesModel(models.Model):
_name = "symptoms.allergies"
_description = "Medical Aids"
_inherit = ["mail.thread", "mail.activity.mixin"]

name = fields.Char()
sequence = fields.Integer("Sequence")
11 changes: 11 additions & 0 deletions dental/models/chronic_condition.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from odoo import fields, models


class ChronicModel(models.Model):
_name = "chronic.condition"
_description = "Medical Aids"
_inherit = ["mail.thread", "mail.activity.mixin"]

name = fields.Char()
sequence = fields.Integer("Sequence")
description = fields.Text()
102 changes: 102 additions & 0 deletions dental/models/dental_patient.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
from datetime import date
from odoo import Command, fields, models


class PatientModel(models.Model):
_name = "dental.patients"
_description = "Dental Patients"
_inherit = ["mail.thread", "mail.activity.mixin"]

name = fields.Char(required=True)
state = fields.Selection(
selection=[
("new", "New"),
("to do today", "To Do Today"),
("done", "Done"),
("to invoice", "To Invoice"),
],
tracking=True,
default="new",
)
image = fields.Image(string="Image")
sequence = fields.Integer("Sequence")
gp_name = fields.Many2one("res.partner", string="Gp's Name")
gp_phone = fields.Char(string="Gp's Phone", related="gp_name.phone", store=True)
chronic_ids = fields.Many2many("chronic.condition", string="Chronic Condition")
aleergies_ids = fields.Many2many("symptoms.allergies", string="Allergies")
habits_ids = fields.Many2many("symptoms.habits", string="Habits/Substance Abuse")
medication = fields.Many2many("medication", string="Medication")
hospitalised_this_year = fields.Text()
under_special_care = fields.Text(string="Under Specialist Care")
psychiatric_history = fields.Text(string="Psychiatric History")
gender = fields.Selection(
selection=[
("male", "Male"),
("female", "Female"),
("neither", "Neither"),
],
)
are_you_pregnant = fields.Boolean(string="Are You Pregnant")
are_you_nursing = fields.Boolean(string="Are You Nursing")
are_you_on = fields.Selection(
selection=[
("hormon replacement treatment", "Hormon Replacement Treatment"),
("birth control", "Birth Control"),
("neither", "Neither"),
],
)
notes = fields.Text()
medical_aid_id = fields.Many2one("medical.aids", string="Medical Aid")
medical_aid_plan = fields.Text(string="Medical Aid Plan")
medical_aid_number = fields.Text(string="Medical Aid Number")
main_member_code = fields.Text(string="Main Member Code")
dependant_code = fields.Text(string="Dependant Code")
occupation_or_grade = fields.Text(string="Occupation Or Grade")
identity_number = fields.Text(string="Identity Number")
date_of_birth = fields.Date(string="Date Of Birth")
marital_status = fields.Selection(
selection=[
("single", "single"),
("married", "married"),
("divorced", "divorced"),
("widowed", "widowed"),
],
string="Marital Status",
)
phone_number = fields.Char(string="Mobile")
history_id = fields.One2many("pateint.history", "patient_id", string="History")
guarantor_id = fields.Many2one("res.partner", string="Guarantor")
guarantor_phone = fields.Char(
string="Guarantor Phone", related="guarantor_id.phone", readonly=True
)
guarantor_email = fields.Char(
string="Guarantor Email", related="guarantor_id.email", readonly=True
)
guarantor_company = fields.Char(
string="Company", related="guarantor_id.parent_id.name"
)
guarantor_tags = fields.Many2many(string="Tags", related="guarantor_id.category_id")

def action_open_invoice(self):
if self.state == "to invoice":
for patient_id in self:
self.ensure_one()
invoice_obj = self.env["account.move"]
invoice_vals = {
"partner_id": patient_id.guarantor_id.id,
"move_type": "out_invoice",
"invoice_date": date.today(),
"state": "draft",
"ref": patient_id.name,
"invoice_line_ids": [
Command.create(
{
"name": patient_id.name,
"quantity": 1,
"price_unit": 1000 * 0.06,
"invoice_date": date.today(),
}
)
],
}
invoice_obj.create(invoice_vals)
10 changes: 10 additions & 0 deletions dental/models/habits.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from odoo import fields, models


class habitModel(models.Model):
_name = "symptoms.habits"
_description = "Habits"
_inherit = ["mail.thread", "mail.activity.mixin"]

name = fields.Char()
sequence = fields.Integer("Sequence")
29 changes: 29 additions & 0 deletions dental/models/medical_aids.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from odoo import fields, models


class MedicalAidsModel(models.Model):
_name = "medical.aids"
_description = "Medical Aids"
_inherit = ["mail.thread", "mail.activity.mixin"]

name = fields.Char(string="Name")
sequence = fields.Integer("Sequence")
contact = fields.Char(string="Contact")
phone_number = fields.Char(string="Phone Number")
email = fields.Char(string="Email")
company_id = fields.Many2one(
"res.company",
string="Company",
required=True,
default=lambda self: self.env.company,
)
notes = fields.Text()
state = fields.Selection(
selection=[
("new", "New"),
("in progress", "In Progress"),
("done", "Done"),
],
tracking=True,
default="new",
)
10 changes: 10 additions & 0 deletions dental/models/medication.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from odoo import fields, models


class MedicationModel(models.Model):
_name = "medication"
_description = "Medication"
_inherit = ["mail.thread", "mail.activity.mixin"]

name = fields.Char(string="Medication")
sequence = fields.Integer("Sequence")
Loading