From d5316f92e787c4e3a88b802f7fc62103e88da8af Mon Sep 17 00:00:00 2001 From: smee-odoo Date: Fri, 6 Sep 2024 18:46:08 +0530 Subject: [PATCH] [IMP] dental: added web controller After this commit: -added added data -added basic appointment booking --- dental/__manifest__.py | 9 +- dental/controller/portal.py | 69 +++++--- dental/data/dental_data.xml | 35 ++++ dental/data/dental_tags.xml | 108 ++++++++++++ dental/models/__init__.py | 1 + dental/models/account_move.py | 7 + dental/models/dental_patients.py | 46 ++--- dental/models/medical_aids.py | 7 - dental/models/medical_symptoms.py | 10 +- dental/security/ir.model.access.csv | 2 - dental/views/dental_views.xml | 12 +- dental/views/portal_template.xml | 249 ++++++++++++++++++++++++---- 12 files changed, 451 insertions(+), 104 deletions(-) create mode 100644 dental/data/dental_data.xml create mode 100644 dental/data/dental_tags.xml create mode 100644 dental/models/account_move.py diff --git a/dental/__manifest__.py b/dental/__manifest__.py index b9af61c99..aaa07bfdb 100644 --- a/dental/__manifest__.py +++ b/dental/__manifest__.py @@ -3,12 +3,15 @@ 'version': '1.2', 'description': "", 'depends': [ - 'base_setup', 'website', - 'mail' + 'base', 'website', + 'mail', 'account' ], 'data': [ 'security/ir.model.access.csv', - + + 'data/dental_data.xml', + 'data/dental_tags.xml', + 'views/portal_template.xml', 'views/tag_views.xml', 'views/medical_history_views.xml', diff --git a/dental/controller/portal.py b/dental/controller/portal.py index 96d634fd7..867b21417 100644 --- a/dental/controller/portal.py +++ b/dental/controller/portal.py @@ -2,31 +2,46 @@ from odoo.http import request from odoo.addons.portal.controllers.portal import CustomerPortal -class DentalPortal(CustomerPortal): - - @http.route(['/my/dental'], type='http', auth='public', website=True) - def portal_my_dental(self, **kwargs): - - patients = request.env['dental.patient'].sudo().search([]) - - values = { - 'patients': patients, - 'page_name': 'dental' - } - for patient in patients: - print("Patient:", patient.guarantor_id.id) - return request.render("dental.portal_my_dental", values) - - @http.route(['/my/dental/'], type='http', auth='public', website=True) - def portal_my_dental_patient(self, patient_id, **kwargs): - patient = request.env['dental.patient'].sudo().search(['guaranter_id', '=' , patient_id]) - - values = { - 'patient': patient, - 'page_name': 'dental' - } - - print("Values:", values) - - return request.render("dental.portal_my_dental_patient", values) \ No newline at end of file +class DentalPortal(CustomerPortal): + @http.route('/my/dental', type='http', auth='user', website=True) + def portal_my_dental(self, **kw): + current = request.env.user.id + users = request.env['dental.patient'].search([('guarantor_id', '=', current)]) + return request.render('dental.portal_my_dental', { + 'users': users + }) + + @http.route('/my/dental/', 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//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//medical_history', type='http', auth='user', website=True) + def portal_my_dental_medical_history(self, patient_id, **kw): + medical_historys = request.env['medical.history'].search([('patient_id', '=', patient_id)]) + return request.render('dental.portal_my_dental_medical_history', { + 'medical_historys': medical_historys + }) + + @http.route('/my/dental//medical_aid', type='http', auth='user', website=True) + def portal_my_dental_medical_aid(self, patient_id, **kw): + medical_aid = request.env['dental.patient'].search([]).insurance_id + return request.render('dental.portal_my_dental_medical_aid', { + 'medical_aid': medical_aid + }) + + @http.route('/my/dental//dental_history', type='http', auth='user', website=True) + def portal_my_dental_dental_history(self, patient_id, **kw): + + return request.render('dental.portal_my_dental_dental_history', { + }) diff --git a/dental/data/dental_data.xml b/dental/data/dental_data.xml new file mode 100644 index 000000000..5b7196665 --- /dev/null +++ b/dental/data/dental_data.xml @@ -0,0 +1,35 @@ + + + + + + Diabetes- Type 2 + + + Heart Conditions + + + Latex + + + Mercury + + + Alcohol + + + + + + Acetaminophen + + + Corticosteroids + + + Ibuprofen + + + Pilocarpine + + \ No newline at end of file diff --git a/dental/data/dental_tags.xml b/dental/data/dental_tags.xml new file mode 100644 index 000000000..ca47d323a --- /dev/null +++ b/dental/data/dental_tags.xml @@ -0,0 +1,108 @@ + + + + + + Upper Left Central Incisor + + + Upper Left Lateral Incisor + + + Upper Right Central Incisor + + + Upper Right Lateral Incisor + + + Lower Left Central Incisor + + + Lower Left Lateral Incisor + + + Lower Right Central Incisor + + + Lower Right Lateral Incisor + + + + + Upper Left Canine + + + Upper Right Canine + + + Lower Left Canine + + + Lower Right Canine + + + + + Upper Left First Premolar + + + Upper Left Second Premolar + + + Upper Right First Premolar + + + Upper Right Second Premolar + + + Lower Left First Premolar + + + Lower Left Second Premolar + + + Lower Right First Premolar + + + Lower Right Second Premolar + + + + + Upper Left First Molar + + + Upper Left Second Molar + + + Upper Left Third Molar (Wisdom Tooth) + + + Upper Right First Molar + + + Upper Right Second Molar + + + Upper Right Third Molar (Wisdom Tooth) + + + Lower Left First Molar + + + Lower Left Second Molar + + + Lower Left Third Molar (Wisdom Tooth) + + + Lower Right First Molar + + + Lower Right Second Molar + + + Lower Right Third Molar (Wisdom Tooth) + + + \ No newline at end of file diff --git a/dental/models/__init__.py b/dental/models/__init__.py index 0ad263d36..ca290182b 100644 --- a/dental/models/__init__.py +++ b/dental/models/__init__.py @@ -4,3 +4,4 @@ from . import medication from . import medical_history from . import dental_tags +# from . import account_move diff --git a/dental/models/account_move.py b/dental/models/account_move.py new file mode 100644 index 000000000..1bd8f68f6 --- /dev/null +++ b/dental/models/account_move.py @@ -0,0 +1,7 @@ +# from odoo import models, fields + + +# class AccountMove(models.Model): +# _inherit = "account.move" + +# patient_id = fields.Many2one('dental.patient', string="Patient name") diff --git a/dental/models/dental_patients.py b/dental/models/dental_patients.py index 570e8890b..e8b9f3a97 100644 --- a/dental/models/dental_patients.py +++ b/dental/models/dental_patients.py @@ -1,6 +1,4 @@ from odoo import models, fields, Command -from datetime import date -from dateutil.relativedelta import relativedelta class DentalPatients(models.Model): @@ -25,10 +23,17 @@ class DentalPatients(models.Model): string="Company", copy=False ) - patient_guarantor_id = fields.Many2one( - 'dental.guarantor', - string="Guranator" + guarantor_id = fields.Many2one( + 'res.users', + string="Guarantor", + copy=False ) + guarantor_phone = fields.Char(string="Guarantor Mobile Phone", related="guarantor_id.phone") + phone = fields.Char(string="Phone") + guarantor_email = fields.Char(string="Email", related="guarantor_id.email") + guarantor_company = fields.Many2one('res.company') + tag_ids = fields.Many2many('dental.tags', string="Tags") + image = fields.Image() doc_phone_number = fields.Char(string="GP's Phone", related="doctor_id.phone") chronic_conditions_ids = fields.Many2many('chronic.conditions', string="Chronic Condtions") @@ -74,10 +79,11 @@ class DentalPatients(models.Model): depedent_code = fields.Char(string="Dependent Code") medical_history_ids = fields.One2many('medical.history', 'patient_id', string="Medical History") - def book_appointment_button(self): + def book_invoice_button(self): self.stage = 'to invoice' + self.guarantor_id = self.env.user.id move_vals = { - 'partner_id': self.patient_guarantor_id.guarantor_id.id, + 'partner_id': self.guarantor_id.id, 'move_type': 'out_invoice', 'invoice_line_ids': [ Command.create({ @@ -91,17 +97,15 @@ def book_appointment_button(self): self.env['account.move'].check_access_rule('create') self.env['account.move'].sudo().create(move_vals) -class Guarantor(models.Model): - _name = "dental.guarantor" - _description = "Gurantor of the patient" - - guarantor_id = fields.Many2one( - 'res.users', - string="Guarantor", - copy=False - ) - patient_ids = fields.One2many('dental.patient', 'patient_guarantor_id') - guarantor_phone = fields.Char(string="Guarantor Mobile Phone", related="guarantor_id.phone") - phone = fields.Char(string="Phone") - guarantor_email = fields.Char(string="Email", related="guarantor_id.email") - notes = fields.Text() + def book_appointment_button(self): + move_vals = { + 'appointment_duration': 1, + 'appointment_tz': self.env.user.tz, + 'assign_method': 'resource_time', + 'max_schedule_days': 1, + 'min_cancellation_hours': 24, + 'min_schedule_hours': 48, + 'name': 'Appointment', + 'schedule_based_on': 'users', + } + self.env['appointment.type'].sudo().create(move_vals) diff --git a/dental/models/medical_aids.py b/dental/models/medical_aids.py index e70857106..0a982345d 100644 --- a/dental/models/medical_aids.py +++ b/dental/models/medical_aids.py @@ -21,10 +21,3 @@ class MedicalAids(models.Model): ) note = fields.Text(string="") image = fields.Image(string="") - -class MedicalAidsDetails(models.Model): - _name = "medicalaids.details" - _inherits = {'medical.aids':'medical_aids_id'} - - medical_aids_id = fields.Many2one('medical.aids') - diff --git a/dental/models/medical_symptoms.py b/dental/models/medical_symptoms.py index 61447538a..ca528e760 100644 --- a/dental/models/medical_symptoms.py +++ b/dental/models/medical_symptoms.py @@ -9,22 +9,26 @@ class MedicalSymptoms(models.Model): sequence = fields.Integer('Sequence', default=1, help="Used to order types. Lower is better.") parent_id = fields.Many2one('medical.symptoms') + class ChronicConditions(models.Model): _name = "chronic.conditions" _description = "Chronic medical symptoms" - _inherits = {'medical.symptoms':'medical_symptoms_id'} + _inherits = {'medical.symptoms': 'medical_symptoms_id'} medical_symptoms_id = fields.Many2one('medical.symptoms') + + class Allergies(models.Model): _name = "dental.allergies" _description = "Allergies" - _inherits = {'medical.symptoms':'medical_symptoms_id'} + _inherits = {'medical.symptoms': 'medical_symptoms_id'} medical_symptoms_id = fields.Many2one('medical.symptoms') + class HabitsSubstance(models.Model): _name = "habits.substance" _description = "Habits and substance abuse info" - _inherits = {'medical.symptoms':'medical_symptoms_id'} + _inherits = {'medical.symptoms': 'medical_symptoms_id'} medical_symptoms_id = fields.Many2one('medical.symptoms') diff --git a/dental/security/ir.model.access.csv b/dental/security/ir.model.access.csv index 0df029fb1..beb8803e9 100644 --- a/dental/security/ir.model.access.csv +++ b/dental/security/ir.model.access.csv @@ -6,7 +6,5 @@ dental.access_chronic_conditions,access_chronic_conditions,dental.model_chronic_ dental.access_dental_allergies,access_dental_allergies,dental.model_dental_allergies,base.group_user,1,1,1,1 dental.access_habits_substance,access_habits_substance,dental.model_habits_substance,base.group_user,1,1,1,1 dental.access_dental_medication,access_dental_medication,dental.model_dental_medication,base.group_user,1,1,1,1 -dental.access_dental_guarantor,access_dental_guarantor,dental.model_dental_guarantor,base.group_user,1,1,1,1 -dental.access_medicalaids_details,access_medicalaids_details,dental.model_medicalaids_details,base.group_user,1,1,1,1 dental.access_medical_history,access_medical_history,dental.model_medical_history,base.group_user,1,1,1,1 dental.access_dental_tags,access_dental_tags,dental.model_dental_tags,base.group_user,1,1,1,1 \ No newline at end of file diff --git a/dental/views/dental_views.xml b/dental/views/dental_views.xml index 6b5f39df0..4452cd954 100644 --- a/dental/views/dental_views.xml +++ b/dental/views/dental_views.xml @@ -59,6 +59,7 @@
+
@@ -144,13 +145,14 @@ - - - + + + + - - + +
diff --git a/dental/views/portal_template.xml b/dental/views/portal_template.xml index 5e056f490..1620a31c7 100644 --- a/dental/views/portal_template.xml +++ b/dental/views/portal_template.xml @@ -1,32 +1,133 @@ - + -