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: initial setup of models, views, and constraints #114

Open
wants to merge 22 commits into
base: 17.0
Choose a base branch
from
Open
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
87a63a8
[ADD] estate: created estate_property
yasp-odoo Aug 2, 2024
39a54d9
[IMP] estate: added actions, menus, and custom views for estate_property
yasp-odoo Aug 2, 2024
3e3189f
[IMP] estate: add buttons to manage property state
yasp-odoo Aug 7, 2024
3fa5a36
[IMP] estate: add SQL and Python constraints to ensure data consistency
yasp-odoo Aug 9, 2024
fa0a041
[IMP] estate: enhance UI with conditional displays and inline views
yasp-odoo Aug 12, 2024
51ec85a
[IMP] estate: enhance UI with inline views, status bar, and condition…
yasp-odoo Aug 20, 2024
a88922e
[IMP] estate: stat button on property type for related offers
yasp-odoo Aug 21, 2024
7de8e7d
[IMP] estate: add salesperson's property list to user view
yasp-odoo Aug 21, 2024
576fb56
[ADD] estate_account: override action_sold to create invoices
yasp-odoo Aug 21, 2024
2fe6926
[IMP] estate: enhance invoice creation and update Kanban view
yasp-odoo Aug 22, 2024
644cd99
[IMP] estate: add icon to Estate menu
yasp-odoo Aug 22, 2024
ca2a277
[IMP] estate: implement demo data with valid property offers and part…
yasp-odoo Aug 30, 2024
759254d
[IMP] estate: enhance demo data with eval, function, and X2many commands
yasp-odoo Aug 30, 2024
458794c
[IMP] estate: implement PDF reports for property offers and sales det…
yasp-odoo Sep 3, 2024
3abb2df
[IMP] estate: implement security groups, access rights, and property …
yasp-odoo Sep 3, 2024
1cd5df5
[IMP] estate: properties menu with grid view and property details page
yasp-odoo Sep 3, 2024
8f22a5f
[ADD] dental: added dental application
yasp-odoo Sep 4, 2024
4e50a3f
[IMP] dental: implemented various views, controller and portal
yasp-odoo Sep 5, 2024
89b321a
[IMP] dental: enhance Portal Views with Dental Patient Details
yasp-odoo Sep 6, 2024
b7e46d2
[ADD] installment: added installment app
yasp-odoo Sep 16, 2024
6e3c45f
[IMP] installment: implemented new features
yasp-odoo Sep 23, 2024
a7c8e66
[ADD] warranty: implemented Warranty Functionality to Sales and Inven…
yasp-odoo Sep 25, 2024
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
23 changes: 23 additions & 0 deletions dental/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
'name': 'dental',
'version': '1.0',
'summary': 'dental management system',
'description': 'A module for managing dental problems and related entities.',
'category': 'website',
'author': 'YASP',
'sequence': 1,
'depends': ['base', 'website', 'mail', 'account'],
'license': 'LGPL-3',
'data': [
'security/ir.model.access.csv',
'views/dental_portal_templates.xml',
'views/dental_views.xml',
'views/medical_aids_views.xml',
'views/medical_symptoms_views.xml',
'views/medication_views.xml',
'views/dental_patient_history_views.xml',
'views/dental_menu.xml',
],
'installable': True,
'application': True,
}
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_portal
55 changes: 55 additions & 0 deletions dental/controller/dental_portal.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
from odoo import http
from odoo.http import request
from odoo.addons.portal.controllers.portal import CustomerPortal


class DentalPortal(CustomerPortal):
@http.route('/my/dental', type='http', auth='user', website=True)
def portal_my_dental(self, **kw):
patients = request.env['dental.patient'].search([('guarantor_id', '=', request.env.user.id), ('gender', '=', 'male'), ('patient_history_ids', '!=', False), ('emergency_contact_id', '!=', False)])
return request.render('dental.portal_my_dental', {
'patients': patients
})

@http.route('/my/dental/<int:patient_id>', type='http', auth='user', website=True)
def portal_my_dental_user(self, patient_id, **kw):
patient = request.env['dental.patient'].browse(patient_id)
return request.render('dental.portal_my_dental_user', {
'patient': patient
})

@http.route('/my/dental/<int:patient_id>/personal', type='http', auth='user', website=True)
def portal_my_dental_personal(self, patient_id, **kw):
patient = request.env['dental.patient'].browse(patient_id)
return request.render('dental.portal_my_dental_personal', {
'patient': patient
})

@http.route('/my/dental/<int:patient_id>/medical_history', type='http', auth='user', website=True)
def portal_my_dental_medical_history(self, patient_id, **kw):
history = request.env['dental.patient.history'].search([('patient_id', '=', patient_id)])
return request.render('dental.portal_my_dental_medical_history', {
'history': history
})

@http.route('/my/dental/<int:patient_id>/medical_aid', type='http', auth='user', website=True)
def portal_my_dental_medical_aid(self, patient_id, **kw):
patient = request.env['dental.patient'].browse([patient_id])
return request.render('dental.portal_my_dental_medical_aid', {
'patient': patient
})

@http.route('/my/dental/<int:patient_id>/dental_history', type='http', auth='user', website=True)
def portal_my_dental_dental_history(self, patient_id, **kw):
history = request.env['dental.patient.history'].search([('patient_id', '=', patient_id)])
return request.render('dental.portal_my_dental_dental_history', {
'history': history,
'patient_id': patient_id
})

@http.route('/my/dental/<int:patient_id>/dental_history/<int:history_id>', type='http', auth='user', website=True)
def portal_my_dental_dental_history_details(self, patient_id, history_id, **kw):
history_record = request.env['dental.patient.history'].browse(history_id)
return request.render('dental.portal_my_dental_dental_history_details', {
'history_record': history_record
})
5 changes: 5 additions & 0 deletions dental/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from . import dental_patients
from . import medical_aids
from . import medical_symptoms
from . import medication
from . import dental_patient_history
104 changes: 104 additions & 0 deletions dental/models/dental_patient_history.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
from odoo import models, fields, api
from datetime import date


class DentalPatientHistory(models.Model):
_name = 'dental.patient.history'
_description = 'Dental Patient History'

# Basic information
name = fields.Char(string="Title", required=True)
description = fields.Text(string="Description")
patient_id = fields.Many2one('dental.patient', string="Patient", required=True)
date = fields.Datetime(string="Date", default=fields.Datetime.now, required=True)
main_complaint = fields.Text(string="Main Complaint")
history = fields.Text(string="History")
company_id = fields.Many2one('res.company', string='Company')
did_not_attend = fields.Boolean(string="Did Not Attend")
tags = fields.Char(string="Tags")

# X-ray file uploads
xray_file_1 = fields.Binary(string="X-ray File 1")
xray_file_2 = fields.Binary(string="X-ray File 2")
clear_aligner_file_1 = fields.Binary(string="Clear Aligner File 1")
clear_aligner_file_2 = fields.Binary(string="Clear Aligner File 2")

# Other details
habits = fields.Text(string="Habits")
extra_oral_observation = fields.Text(string="Extra-Oral Observation")

# Tooth chart (for example purposes)
teeth_chart = fields.Char(string="Teeth Chart")

# Treatment notes
treatment_notes = fields.Text(string="Treatment Notes")

# Billing information
consultation_type = fields.Selection([
('full_consultation', 'Full Consultation with Bitewings 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 Polish")
fluoride = fields.Boolean(string="Fluoride")

filling_description = fields.Text(string="Filling Description")

aligner_delivery = fields.Boolean(
string="Aligner Delivery and Attachment Placed")
whitening = fields.Boolean(string="Whitening")

fissure_sealant_qty = fields.Float(
string="Fissure Sealant Quantity", digits=(6, 2))

attachments_removed = fields.Boolean(string="Attachments Removed")
aligner_followup_scan = fields.Boolean(string="Aligner Follow-up Scan")

other_notes = fields.Text(string="Other Notes")
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')

# General notes field at the end
notes = fields.Text(string="Additional Notes")

@api.depends("patient_id")
def _compute_name(self):
for record in self:
record.name = f"{record.patient_id.name}-{date.today()}"

def action_save_close(self):
# Method to save and close the form view
self.ensure_one()
self.env['ir.actions.act_window'].browse(self._context.get('active_id')).write({'state': 'done'})
96 changes: 96 additions & 0 deletions dental/models/dental_patients.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
from odoo import models, fields, Command


class DentalPatients(models.Model):
_name = "dental.patient"
_description = "Patients"
_inherit = ['mail.thread', 'mail.activity.mixin', 'portal.mixin']

name = fields.Char(string='Name', required=True)
state = fields.Selection([
('new', 'New'),
('todotoday', 'To Do Today'),
('done', 'Done'),
('toinvoice', 'To Invoice')
], default='new', tracking=True)

gp_id = fields.Many2one('res.partner', string="GP's Name")
gp_phone = fields.Char(related='gp_id.phone', string="GP's Phone", readonly=True)
chronic_conditions = fields.Many2many('chronic.conditions', string="Chronic Conditions")
medication = fields.Many2many('dental.medication', string="Medication")
hospitalized_this_year = fields.Boolean(string="Hospitalised this Year")
allergies = fields.Many2many('dental.allergies', string="Allergies")
habits_substance_abuse = fields.Many2many('habits.substance', string="Habits and Substance Abuse")
under_specialist_care = fields.Char(string="Under Specialist Care")
psychiatric_history = fields.Char(string="Psychiatric History")
image_1920 = fields.Image(string="Image")
gender = fields.Selection([
('female', 'Female'),
('male', 'Male'),
('neither', 'Neither')
], string="Gender")
is_pregnant = fields.Boolean(string="Are you pregnant?", default=False, help="Visible if gender is Female")
is_nursing = fields.Boolean(string="Are you nursing?", default=False, help="Visible if gender is Female")
hormone_treatment = fields.Selection([
('hormone', 'Hormone Replacement Treatment'),
('birth_control', 'Birth control'),
('neither', 'Neither')
], string="Are you on...", default='neither', help="Visible if gender is Female")

medical_aid_id = fields.Many2one('medical.aids', string="Medical Aid")
medical_aid_plan = fields.Char(string="Medical Aid Plan")
medical_aid_number = fields.Char(string="Medical Aid Number")
main_number_code = fields.Char(string="Main Number Code")
dependant_code = fields.Char(string="Dependant Code")

# Fields for Patient Details
emergency_contact_id = fields.Many2one('res.partner', string="Emergency Contact")
mobile = fields.Char(related='emergency_contact_id.phone', string="Mobile", readonly=True)
company_id = fields.Many2one('res.company', string="Company/School")
occupation = fields.Char(string="Occupation/Grade")
identity_number = fields.Char(string="Identity Number")
date_of_birth = fields.Date(string="Date of Birth")
marital_status = fields.Selection([
('single', 'Single'),
('married', 'Married'),
('divorced', 'Divorced'),
('widowed', 'Widowed')
], string="Marital Status")

# Fields for Consent Form
consent_signature = fields.Binary(string="Consent Signature")
consent_date = fields.Date(string="Consent Date")

guarantor_id = fields.Many2one('res.users', string="Guarantor")
guarantor_mobile = fields.Char(related='guarantor_id.mobile', string="Guarantor Mobile Phone", readonly=False)
guarantor_phone = fields.Char(related='guarantor_id.phone', string="Phone", readonly=True)
guarantor_email = fields.Char(related='guarantor_id.email', string="Email", readonly=True)

# Add this field to link history records
patient_history_ids = fields.One2many('dental.patient.history', 'patient_id', string="Patient History")

def action_invoice(self):
self.state = 'toinvoice'
move_vals = {
'partner_id': self.guarantor_id.id,
'move_type': 'out_invoice',
'invoice_date': fields.Date.today(),
"invoice_line_ids": [
Command.create({
"name": self.name,
"quantity": 1,
"price_unit": 100
}),
],

}
self.env['account.move'].create(move_vals)

def book_appointment_button(self):
vals = {
'name': f"{self.name}-Dentist Booking",
'appointment_type_id': self.env.ref('appointment.appointment_type_dental_care').id,
'duration': 0.5
}
self.env['calendar.event'].create(vals)
self.state = 'toinvoice'
21 changes: 21 additions & 0 deletions dental/models/medical_aids.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from odoo import models, fields


class MedicalAids(models.Model):
_name = "medical.aids"
_description = "Medical Insurance Info"

name = fields.Char(string='Name', required=True)
state = fields.Selection([
('new', 'New'),
('inprogress', 'In Progress'),
('done', 'Done')],
string='Status',
default='new'
)
contact = fields.Many2one('res.partner', string='Contact', required=True)
phone = fields.Char(related='contact.phone', string='Phone', readonly=True)
email = fields.Char(related='contact.email', string='Email', readonly=True)
company_id = fields.Many2one('res.company', string='Company', required=True)
note = fields.Text(string='Notes')
image = fields.Binary(string='Image')
27 changes: 27 additions & 0 deletions dental/models/medical_symptoms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from odoo import models, fields


class ChronicConditions(models.Model):
_name = "chronic.conditions"
_description = "Chronic medical conditions"
_order = 'sequence, name'

name = fields.Char(string='Name', required=True)
sequence = fields.Integer(string='Sequence')
parent_id = fields.Many2one('chronic.conditions', string='Parent Condition', ondelete='cascade', index=True)


class Allergies(models.Model):
_name = "dental.allergies"
_description = "Allergies"

name = fields.Char(string='Name', required=True)
parent_id = fields.Many2one('chronic.conditions', string='Parent Condition', ondelete='cascade', index=True)


class HabitsSubstance(models.Model):
_name = "habits.substance"
_description = "Habits and substance abuse information"

name = fields.Char(string='Name', required=True)
parent_id = fields.Many2one('chronic.conditions', string='Parent Condition', ondelete='cascade', index=True)
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 models, fields


class Medication(models.Model):
_name = "dental.medication"
_description = "Medicinal Info"
_order = "sequence, name"

name = fields.Char(string='Name', required=True)
sequence = fields.Integer()
8 changes: 8 additions & 0 deletions dental/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_dental_patient,access_dental_patient,dental.model_dental_patient,base.group_user,1,1,1,1
access_medical_aids,access_medical_aids,dental.model_medical_aids,base.group_user,1,1,1,1
access_chronic_conditions,access_chronic_conditions,dental.model_chronic_conditions,base.group_user,1,1,1,1
access_dental_allergies,access_dental_allergies,dental.model_dental_allergies,base.group_user,1,1,1,1
access_habits_substance,access_habits_substance,dental.model_habits_substance,base.group_user,1,1,1,1
access_dental_medication,access_dental_medication,dental.model_dental_medication,base.group_user,1,1,1,1
access_dental_patient_history,access_dental_patient_history,dental.model_dental_patient_history,base.group_user,1,1,1,1
Binary file added dental/static/src/image/dental.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading