From f04efc04447d65116a33459dadabdbf897180639 Mon Sep 17 00:00:00 2001 From: smee-odoo Date: Thu, 12 Sep 2024 15:15:42 +0530 Subject: [PATCH] [IMP] dental: updated web controller After this commit: -added patient creation form --- dental/__manifest__.py | 2 + dental/controller/portal.py | 22 ++ dental/data/data.xml | 11 + dental/data/dental_data.xml | 20 ++ dental/models/__init__.py | 2 +- dental/models/dental_patients.py | 15 +- dental/models/dental_stage.py | 10 + dental/security/ir.model.access.csv | 3 +- dental/views/dental_menu.xml | 6 +- dental/views/dental_stage_views.xml | 55 +++++ dental/views/dental_views.xml | 14 +- dental/views/medical_history_views.xml | 288 +++++++++++++------------ dental/views/portal_template.xml | 187 ++++++++++++++-- 13 files changed, 457 insertions(+), 178 deletions(-) create mode 100644 dental/data/data.xml create mode 100644 dental/models/dental_stage.py create mode 100644 dental/views/dental_stage_views.xml diff --git a/dental/__manifest__.py b/dental/__manifest__.py index aaa07bfdb..ce875db7e 100644 --- a/dental/__manifest__.py +++ b/dental/__manifest__.py @@ -9,9 +9,11 @@ 'data': [ 'security/ir.model.access.csv', + 'data/data.xml', 'data/dental_data.xml', 'data/dental_tags.xml', + 'views/dental_stage_views.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 980f83ea3..af30b7967 100644 --- a/dental/controller/portal.py +++ b/dental/controller/portal.py @@ -75,3 +75,25 @@ def portal_my_dental_medical_history_form(self, patient_id, history_id, **kw): return request.render('dental.portal_teeth_staining', { 'medical_history': medical_history, }) + + @http.route('/dentalappointment', type='http', auth='user', website=True) + def portal_dental_appointment(self, **kw): + return request.render('dental.create_patient_form', {}) + + @http.route('/createpatient', type='http', auth='user', website=True) + def portal_create_patient(self, **kw): + vals = { + 'name': kw.get("name"), + 'birthdate': kw.get("birthdate"), + 'stage_id': 1 + } + new_patient = request.env['dental.patient'].sudo().create(vals) + return request.render('dental.create_patient_details_form', { + 'patient_id': new_patient.id + }) + + @http.route('/createpatient/', type='http', auth='user', website=True) + def portal_dental_appointment_details(self, patient_id, **kw): + patient = request.env['dental.patient'].browse(patient_id) + patient.sudo().write(kw) + return request.render('dental.patient_created', {}) diff --git a/dental/data/data.xml b/dental/data/data.xml new file mode 100644 index 000000000..d9551b0f3 --- /dev/null +++ b/dental/data/data.xml @@ -0,0 +1,11 @@ + + + + + Dental Appointment + /dentalappointment + + 100 + + + \ No newline at end of file diff --git a/dental/data/dental_data.xml b/dental/data/dental_data.xml index 2a19de92a..ce7a824f2 100644 --- a/dental/data/dental_data.xml +++ b/dental/data/dental_data.xml @@ -32,4 +32,24 @@ Pilocarpine + + + + + New + 1 + + + To Do Today + 2 + + + Done + 3 + + + To Invoice + 4 + + \ No newline at end of file diff --git a/dental/models/__init__.py b/dental/models/__init__.py index ca290182b..31991b55c 100644 --- a/dental/models/__init__.py +++ b/dental/models/__init__.py @@ -4,4 +4,4 @@ from . import medication from . import medical_history from . import dental_tags -# from . import account_move +from . import dental_stage diff --git a/dental/models/dental_patients.py b/dental/models/dental_patients.py index 8e8ba477b..cbfdf1022 100644 --- a/dental/models/dental_patients.py +++ b/dental/models/dental_patients.py @@ -7,12 +7,9 @@ class DentalPatients(models.Model): _inherit = ["mail.thread", "mail.activity.mixin"] name = fields.Char(string='Name', required=True) - stage = fields.Selection( - string='Stage', - selection=[('new', 'New'), ('to do today', 'To Do Today'), ('done', 'Done'), ('to invoice', 'To Invoice')], - help='stage of the appointment', - required=True, - default='new') + + stage_id = fields.Many2one('dental.stage', string="Stage") + doctor_id = fields.Many2one( 'res.partner', string="GP's Name", @@ -79,9 +76,9 @@ class DentalPatients(models.Model): depedent_code = fields.Char(string="Dependent Code") medical_history_ids = fields.One2many('medical.history', 'patient_id', string="Medical History") - @api.onchange("stage") + @api.onchange("stage_id") def _onchange_stage(self): - if self.stage == 'to invoice': + if self.stage_id.name == 'To Invoice': self.guarantor_id = self.env.user.id move_vals = { 'partner_id': self.guarantor_id.id, @@ -97,7 +94,7 @@ def _onchange_stage(self): self.env['account.move'].create(move_vals) def book_invoice_button(self): - self.stage = 'to invoice' + self.stage_id.name = 'To Invoice' self.guarantor_id = self.env.user.id move_vals = { 'partner_id': self.guarantor_id.id, diff --git a/dental/models/dental_stage.py b/dental/models/dental_stage.py new file mode 100644 index 000000000..65ba7225d --- /dev/null +++ b/dental/models/dental_stage.py @@ -0,0 +1,10 @@ +from odoo import fields, models + + +class DentalStage(models.Model): + + _name = "dental.stage" + _description = "dental stages" + + name = fields.Char(string="Name", required=True) + sequence = fields.Integer(default=1, string="Sequence") \ No newline at end of file diff --git a/dental/security/ir.model.access.csv b/dental/security/ir.model.access.csv index beb8803e9..a4ffd0557 100644 --- a/dental/security/ir.model.access.csv +++ b/dental/security/ir.model.access.csv @@ -7,4 +7,5 @@ dental.access_dental_allergies,access_dental_allergies,dental.model_dental_aller 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_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 +dental.access_dental_tags,access_dental_tags,dental.model_dental_tags,base.group_user,1,1,1,1 +dental.access_dental_stage,access_dental_stage,dental.model_dental_stage,base.group_user,1,1,1,1 \ No newline at end of file diff --git a/dental/views/dental_menu.xml b/dental/views/dental_menu.xml index 1b3ebfc17..7a6a46fd6 100644 --- a/dental/views/dental_menu.xml +++ b/dental/views/dental_menu.xml @@ -15,5 +15,9 @@ - + + + + + \ No newline at end of file diff --git a/dental/views/dental_stage_views.xml b/dental/views/dental_stage_views.xml new file mode 100644 index 000000000..2e2a7e092 --- /dev/null +++ b/dental/views/dental_stage_views.xml @@ -0,0 +1,55 @@ + + + + + Stage - Search + dental.stage + + + + + + + + + + dental.stage.tree + dental.stage + + + + + + + + + + dental.stage.form + dental.stage + + +
+ +
+
+
+
+
+
+ + + Stages + dental.stage + tree,form + +

+ Set a new stage in your opportunity pipeline +

+
+
+ +
diff --git a/dental/views/dental_views.xml b/dental/views/dental_views.xml index 4452cd954..13bf344fb 100644 --- a/dental/views/dental_views.xml +++ b/dental/views/dental_views.xml @@ -25,8 +25,8 @@ dental.patient.kanban dental.patient - - + +
@@ -43,12 +43,6 @@
- - -
- -
-
@@ -59,9 +53,9 @@
-
diff --git a/dental/views/medical_history_views.xml b/dental/views/medical_history_views.xml index 2f2995203..15291d6f7 100644 --- a/dental/views/medical_history_views.xml +++ b/dental/views/medical_history_views.xml @@ -19,151 +19,161 @@ - - - medical.history.form - medical.history - - - - - - - - - - - - - - - - - + + medical.history.tree + medical.history + + + + + + + + + + + medical.history.form + medical.history + + + + + + + + + + + - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - - - -
-
18
-
17
-
16
-
15
-
14
-
13
-
12
-
11
-
28
-
27
-
26
-
25
-
24
-
23
-
22
-
21
-
-
-
- - - - - - - - - - - - - - - - - - - - -
-
48
-
47
-
46
-
45
-
44
-
43
-
42
-
41
-
38
-
37
-
36
-
35
-
34
-
33
-
32
-
31
-
-
-
- - - - - - - - - - - - - - - - - - +
+ + + +
+
18
+
17
+
16
+
15
+
14
+
13
+
12
+
11
+
28
+
27
+
26
+
25
+
24
+
23
+
22
+
21
+
+
+
+ + + + + + + + + + + + + + + + + - - + + +
+
48
+
47
+
46
+
45
+
44
+
43
+
42
+
41
+
38
+
37
+
36
+
35
+
34
+
33
+
32
+
31
+
+
- - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -
- -
-
-
- - - +
+
- -
- - + +
+ + + +
+ +
+ \ No newline at end of file diff --git a/dental/views/portal_template.xml b/dental/views/portal_template.xml index 6e03fee2c..74d6ae6d5 100644 --- a/dental/views/portal_template.xml +++ b/dental/views/portal_template.xml @@ -303,7 +303,7 @@ -