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 property management module #110

Closed
wants to merge 14 commits into from
Closed
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
33 changes: 33 additions & 0 deletions dental/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"name": "Dental",
"version": "1.0",
"summary": "Manage dental history and appointments",
"description": "Module to manage medical history and appointments",
"author": "Akya",
"sequence": "15",
"depends": ["base", "mail", "account", "website"],
"data": [
"security/ir.model.access.csv",
"views/dental_patient_view.xml",
"views/dental_medication_view.xml",
"views/dental_chronic_diseases_view.xml",
"views/dental_allergies_view.xml",
"views/dental_habits_view.xml",
"views/dental_medical_aid_view.xml",
"views/dental_history_view.xml",
"views/dental_menus.xml",
"views/dental_controller_view.xml",
"report/dental_patient_report.xml",
"report/dental_patient_report_template.xml",
],
"images": [
"static/description/icon.png",
"static/description/bag.svg",
"static/description/folder.svg",
"static/description/task.svg",
"static/description/Bill.svg",
],
"installable": True,
"application": True,
"license": "AGPL-3",
}
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
105 changes: 105 additions & 0 deletions dental/controller/dental_controller.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
from odoo import http
from odoo.http import request


class DentalController(http.Controller):

@http.route(
["/home/dental", "/home/dental/page/<int:page>"], auth="public", website=True
)
def display_patients(self, page=1):
patients_per_page = 4
current_user = request.env.user

total_patients = (
request.env["dental.patient"]
.sudo()
.search_count([("guarantor_id", "=", current_user.partner_id.id)])
)

pager = request.website.pager(
url="/home/dental",
total=total_patients,
page=page,
step=patients_per_page,
)

patients = (
request.env["dental.patient"]
.sudo()
.search(
[("guarantor_id", "=", current_user.partner_id.id)],
offset=pager["offset"],
limit=patients_per_page,
)
)

return request.render(
"dental.dental_patient_page", {"patients": patients, "pager": pager}
)

@http.route("/home/dental/<int:record_id>", auth="public", website=True)
def display_patient_details(self, record_id):
patient = request.env["dental.patient"].sudo().browse(record_id)

if not patient:
return request.not_found()

return request.render(
"dental.dental_patient_details_page", {"patient": patient}
)

@http.route(
"/home/dental/<int:record_id>/personal",
type="http",
auth="public",
website=True,
)
def render_dental_patient_form(self, record_id):
patient = request.env["dental.patient"].sudo().browse(record_id)
return request.render(
"dental.dental_patient_personal_details",
{
"patient": patient,
},
)

@http.route("/home/dental/<int:record_id>/medical_aid", auth="user", website=True)
def medical_aid_details(self, record_id):
patient = http.request.env["dental.patient"].sudo().browse(record_id)
return http.request.render(
"dental.dental_patient_medical_aid_details",
{
"patient": patient,
},
)

@http.route(
"/home/dental/<int:record_id>/medical_history",
type="http",
auth="public",
website=True,
)
def medical_history_view(self, record_id):
patient = request.env["dental.patient"].sudo().browse(record_id)
return request.render(
"dental.dental_history_list_view",
{
"patients": patient.history_ids,
},
)

@http.route(
"/home/dental/<int:record_id>/appointment",
type="http",
auth="public",
website=True,
)
def dental_history_list_view(self, record_id):
patient = request.env["dental.patient"].sudo().browse(record_id)
return request.render(
"dental.patient_details_controller_appointment",
{
"patients": patient.history_ids,
},
)
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 dental_medication
from . import dental_chronic_diseases
from . import dental_allergies
from . import dental_habits
from . import dental_medical_aid
from . import dental_history
10 changes: 10 additions & 0 deletions dental/models/dental_allergies.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from odoo import models, fields


class DentalAllergies(models.Model):
_name = "dental.allergies"
_description = "Dental Allergies list "
_order = "name"

name = fields.Char(string="Allergies", required=True)
sequence = fields.Integer(string="Sequence", default=10)
10 changes: 10 additions & 0 deletions dental/models/dental_chronic_diseases.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from odoo import models, fields


class DentalChronicDiseases(models.Model):
_name = "dental.chronic.diseases"
_description = "Dental chronic diseases list"
_order = "name"

name = fields.Char(string="Chronic Condition", required=True)
sequence = fields.Integer(string="Sequence", default=10)
10 changes: 10 additions & 0 deletions dental/models/dental_habits.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from odoo import models, fields


class DentalHabits(models.Model):
_name = "dental.habits"
_description = "Dental habits and substance abuse list"
_order = "name"

name = fields.Char(string="Habits/Substance Abuse", required=True)
sequence = fields.Integer(string="Sequence", default=10)
83 changes: 83 additions & 0 deletions dental/models/dental_history.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
from odoo import models, fields
from datetime import date


class DentalHistory(models.Model):
_name = "dental.history"
_description = "Dental history of patient"

history_id = fields.Many2one("dental.patient")
date = fields.Date(string="Date", default=date.today())
name = fields.Char(string="Name", required=True)
description = fields.Char(string="Description")
tags = fields.Char(string="Tags")
patient = fields.Char()
attend = fields.Boolean(string="Did not attend", required=True)
responsible = fields.Char()
company = fields.Many2one("res.company", string="Company")
history = fields.Text(string="History")
xray_file1 = fields.Binary(string="X-ray file 1")
xray_file2 = fields.Binary(string="X-ray file 2")
clear_aligner_file1 = fields.Binary(string="Clear Aligner File 1")
clear_aligner_file2 = fields.Binary(string="Clear Aligner File 2")
habits = fields.Text(string="Habits")
extra_observation = fields.Text(string="Extra Oral Observation")
treatment_notes = fields.Text(string="Treatment Notes")
consulatation = fields.Selection(
copy=False,
selection=[
(
"full_consultation_and_scan",
"Full Consultation with bite-wings and scan",
),
("basic_consultation", "Basic Consultation"),
("no_consultation", "No Consultation"),
],
string="Consultation Type",
)
call_out = fields.Boolean(string="Call out")
scale_and_polish = fields.Boolean(string="Scale and Push")
flouride = fields.Boolean(string="Flouride")
filling_description = fields.Text(string="Filling Description")
aligner_attachment = fields.Boolean(
string="Alligner delivery and attachment placed"
)
whitening = fields.Boolean(string="Whitening")
fissure_sealant_quantity = fields.Float(string="Fissure Sealant-Quantity")
remove_attachment = fields.Boolean(string="Attachment Removed")
alligner_follow_up_scan = fields.Boolean(string="Alligner Follow-up Scan")
other = fields.Text(string="Other")
upper_18_staining = fields.Boolean(string="18 Staining")
upper_17_staining = fields.Boolean(string="17 Staining")
upper_16_staining = fields.Boolean(string="16 Staining")
upper_15_staining = fields.Boolean(string="15 Staining")
upper_14_staining = fields.Boolean(string="14 Staining")
upper_13_staining = fields.Boolean(string="13 Staining")
upper_12_staining = fields.Boolean(string="12 Staining")
upper_11_staining = fields.Boolean(string="11 Staining")
upper_28_staining = fields.Boolean(string="28 Staining")
upper_27_staining = fields.Boolean(string="27 Staining")
upper_26_staining = fields.Boolean(string="26 Staining")
upper_25_staining = fields.Boolean(string="25 Staining")
upper_24_staining = fields.Boolean(string="24 Staining")
upper_23_staining = fields.Boolean(string="23 Staining")
upper_22_staining = fields.Boolean(string="22 Staining")
upper_21_staining = fields.Boolean(string="21 Staining")
lower_31_staining = fields.Boolean(string="31 Staining")
lower_32_staining = fields.Boolean(string="32 Staining")
lower_33_staining = fields.Boolean(string="33 Staining")
lower_34_staining = fields.Boolean(string="34 Staining")
lower_35_staining = fields.Boolean(string="35 Staining")
lower_36_staining = fields.Boolean(string="36 Staining")
lower_37_staining = fields.Boolean(string="37 Staining")
lower_38_staining = fields.Boolean(string="38 Staining")
lower_41_staining = fields.Boolean(string="41 Staining")
lower_42_staining = fields.Boolean(string="42 Staining")
lower_43_staining = fields.Boolean(string="43 Staining")
lower_44_staining = fields.Boolean(string="44 Staining")
lower_45_staining = fields.Boolean(string="45 Staining")
lower_46_staining = fields.Boolean(string="46 Staining")
lower_47_staining = fields.Boolean(string="47 Staining")
lower_48_staining = fields.Boolean(string="48 Staining")

notes = fields.Text()
14 changes: 14 additions & 0 deletions dental/models/dental_medical_aid.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from odoo import models, fields


class DentalMedication(models.Model):
_name = "dental.medical.aid"
_description = "Medications"
_order = "name"

name = fields.Char(string="Medical Aid Name", required=True)
contact_name = fields.Char(string="Contact")
phone = fields.Char(string="Phone")
email = fields.Char(string="Email")
company = fields.Many2one("res.company", string="Company")
notes = fields.Text()
9 changes: 9 additions & 0 deletions dental/models/dental_medication.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from odoo import models, fields


class DentalMedication(models.Model):
_name = "dental.medication"
_description = "Medications"
_order = "name"

name = fields.Char(string="Medication", required=True)
97 changes: 97 additions & 0 deletions dental/models/dental_patient.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
from odoo import models, fields, Command, api
from datetime import date


class DentalPatient(models.Model):
_name = "dental.patient"
_description = "Dental Patient Info"
_inherit = ["mail.thread", "mail.activity.mixin"]

name = fields.Char(string="Name", required=True)
state = fields.Selection(
[
("new", "New"),
("to_do_today", "To do today"),
("done", "Done"),
("to_invoice", "To invoice"),
],
default="new",
tracking=True,
)
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")
image = fields.Binary(string="Image")
medication_ids = fields.Many2many("dental.medication")
chronic_conditions_ids = fields.Many2many("dental.chronic.diseases")
allergy_ids = fields.Many2many("dental.allergies")
habit_ids = fields.Many2many("dental.habits", string="Habits/Substance Abuse")
hospitalised = fields.Boolean(string="Hospitalised this year?")
female = fields.Boolean(string="FEMALE")
pregnant = fields.Boolean(string="Are you pregnant?")
nursing = fields.Boolean(string="Are you nursing?")
treatment = fields.Selection(
[
("hormone_replacement_treatment", "Hormone Replacement Treatment"),
("birth_control", "Birth Control"),
("neither", "Neither"),
]
)
notes = fields.Char()
special_care = fields.Char(string="Under Special Care")
psychiatric_history = fields.Char(string="Psychiatric History")
medical_aid_id = fields.Many2one("dental.medical.aid", string="Medical Aid")
medical_aid_plan = fields.Char(string="Medical Aid Plan")
medical_aid_number = fields.Char(string="Medical Aid Number")
member_code = fields.Char(string="Main Member Code")
dependant_code = fields.Char(string="Dependant Code")
emergency_contact_id = fields.Many2one("res.partner", string="Emergency Contact")
emergency_contact_phone = fields.Char(
string="Mobile", related="emergency_contact_id.phone"
)
history_ids = fields.One2many("dental.history", "history_id", string="History")
occupation = fields.Char(string="Occupation or Grade")
identity_number = fields.Char(string="Identity Number")
date_of_birth = fields.Date(string="Date of Birth")
gender = fields.Selection(
[("male", "Male"), ("female", "Female"), ("neither", "Neither")]
)
marital_status = fields.Selection(
[
("single", "Single"),
("married", "Married"),
("divorced", "Divorced"),
("widowed", "Widowed"),
]
)
tags = fields.Char(string="Tags")
company_id = fields.Many2one("res.company", string="Company")

@api.onchange("state")
def action_sold(self):
if self.state == "to_invoice":
for record in self:
res = {
"move_type": "out_invoice",
"partner_id": record.guarantor_id.id,
"invoice_line_ids": [
Command.create(
{
"name": record.name,
"quantity": 1,
"invoice_date": date.today(),
"price_unit": 100,
}
),
],
}

self.env["account.move"].sudo().create(res)
Loading