diff --git a/dental/__init__.py b/dental/__init__.py index 0650744f6b..5607426d8a 100644 --- a/dental/__init__.py +++ b/dental/__init__.py @@ -1 +1,2 @@ from . import models +from . import controller diff --git a/dental/__manifest__.py b/dental/__manifest__.py index 8524098a00..e85dcd6a80 100644 --- a/dental/__manifest__.py +++ b/dental/__manifest__.py @@ -12,6 +12,7 @@ "views/habits.xml", "views/allergies.xml", "views/medication.xml", + "views/dental_controller.xml", "views/patient_history.xml", "views/menuitem.xml", ], diff --git a/dental/controller/__init__.py b/dental/controller/__init__.py new file mode 100644 index 0000000000..95db74ea1d --- /dev/null +++ b/dental/controller/__init__.py @@ -0,0 +1 @@ +from . import dental_controller diff --git a/dental/controller/dental_controller.py b/dental/controller/dental_controller.py new file mode 100644 index 0000000000..8fa8eff8fb --- /dev/null +++ b/dental/controller/dental_controller.py @@ -0,0 +1,77 @@ +from odoo import http +from odoo.http import request + + +class DentalController(http.Controller): + + @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 + print(user.partner_id.id) + 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, + }, + ) + + @http.route( + ["/patient/"], + 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, + }, + ) + + @http.route( + ["/dental/history/"], + type="http", + auth="public", + website=True, + ) + def show_dental_history(self, patient_id, **kwargs): + data = request.env["dental.patients"].sudo().browse(patient_id) + print(patient_id) + return request.render( + "dental.dental_history_view", + { + "patients": data, + }, + ) diff --git a/dental/models/dental_patient.py b/dental/models/dental_patient.py index d678d5fdc5..2c647f5e44 100644 --- a/dental/models/dental_patient.py +++ b/dental/models/dental_patient.py @@ -7,7 +7,7 @@ class PatientModel(models.Model): _description = "Dental Patients" _inherit = ["mail.thread", "mail.activity.mixin"] - name = fields.Char() + name = fields.Char(required=True) state = fields.Selection( selection=[ ("new", "New"), @@ -78,7 +78,7 @@ class PatientModel(models.Model): guarantor_tags = fields.Many2many(string="Tags", related="guarantor_id.category_id") def action_open_invoice(self): - if self.state == "new": + if self.state == "to invoice": print("invoice") for patient_id in self: self.ensure_one() diff --git a/dental/models/medical_aids.py b/dental/models/medical_aids.py index 68f3dcde71..fffad927b3 100644 --- a/dental/models/medical_aids.py +++ b/dental/models/medical_aids.py @@ -27,3 +27,4 @@ class MedicalAidsModel(models.Model): tracking=True, default="new", ) + pateint_id = fields.One2many("dental.patients", "medical_aid_id") diff --git a/dental/static/icons/Bill.svg b/dental/static/icons/Bill.svg new file mode 100644 index 0000000000..51d1968db6 --- /dev/null +++ b/dental/static/icons/Bill.svg @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/dental/static/icons/bag.svg b/dental/static/icons/bag.svg new file mode 100644 index 0000000000..148d08a226 --- /dev/null +++ b/dental/static/icons/bag.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/dental/static/icons/folder.svg b/dental/static/icons/folder.svg new file mode 100644 index 0000000000..e25122ed53 --- /dev/null +++ b/dental/static/icons/folder.svg @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/dental/static/icons/icon.svg b/dental/static/icons/icon.svg new file mode 100644 index 0000000000..12e8ec084c --- /dev/null +++ b/dental/static/icons/icon.svg @@ -0,0 +1 @@ + diff --git a/dental/static/icons/tasks.svg b/dental/static/icons/tasks.svg new file mode 100644 index 0000000000..d43aeaacdf --- /dev/null +++ b/dental/static/icons/tasks.svg @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/dental/views/dental_controller.xml b/dental/views/dental_controller.xml new file mode 100644 index 0000000000..af44946d06 --- /dev/null +++ b/dental/views/dental_controller.xml @@ -0,0 +1,156 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/dental/views/pateint_views.xml b/dental/views/pateint_views.xml index a9f9b46ac1..834407c7cc 100644 --- a/dental/views/pateint_views.xml +++ b/dental/views/pateint_views.xml @@ -40,11 +40,12 @@

- +

+