Skip to content

Commit

Permalink
[IMP] dental: updated the web controller
Browse files Browse the repository at this point in the history
After this commit:
-updated the views
  • Loading branch information
smee-odoo committed Sep 10, 2024
1 parent 0a19e28 commit e459d24
Show file tree
Hide file tree
Showing 5 changed files with 530 additions and 183 deletions.
44 changes: 37 additions & 7 deletions dental/controller/portal.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,35 @@
from odoo import http
from odoo.http import request
from odoo.addons.portal.controllers.portal import CustomerPortal
from odoo.addons.portal.controllers.portal import pager as portal_pager


class DentalPortal(CustomerPortal):
@http.route('/my/dental', type='http', auth='user', website=True)
def portal_my_dental(self, **kw):
@http.route(['/my/dental', '/my/dental/page/<int:page>'], type='http', auth='user', website=True)
def portal_my_dental(self, page=1, **kw):
current = request.env.user.id
users = request.env['dental.patient'].search([('guarantor_id', '=', current)])
dental_patient = request.env['dental.patient']
domain = [('guarantor_id', '=', current)]

items_per_page = 2
total_users = dental_patient.search_count(domain)

pager = portal_pager(
url='/my/dental',
total=total_users,
page=int(page),
step=items_per_page,
)

users = dental_patient.search(
domain,
limit=items_per_page,
offset=pager['offset'],
)

return request.render('dental.portal_my_dental', {
'users': users
'users': users,
'pager': pager
})

@http.route('/my/dental/<int:patient_id>', type='http', auth='user', website=True)
Expand All @@ -35,13 +55,23 @@ def portal_my_dental_medical_history(self, patient_id, **kw):

@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):
medical_aid = request.env['dental.patient'].search([]).insurance_id
medical_aids = request.env['dental.patient'].browse(patient_id).insurance_id
return request.render('dental.portal_my_dental_medical_aid', {
'medical_aid': medical_aid
'medical_aids': medical_aids
})

@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):

medical_historys = request.env['medical.history'].search([('patient_id', '=', patient_id)])
return request.render('dental.portal_my_dental_dental_history', {
'medical_historys': medical_historys
})

@http.route('/my/dental/<int:patient_id>/dental_history/<int:history_id>', type='http', auth='user', website=True)
def portal_my_dental_medical_history_form(self, patient_id, history_id, **kw):
medical_historys = request.env['medical.history'].search(
[('patient_id', '=', patient_id)])
medical_history = medical_historys.browse(history_id)
return request.render('dental.portal_teeth_staining', {
'medical_history': medical_history,
})
36 changes: 23 additions & 13 deletions dental/models/dental_patients.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from odoo import models, fields, Command
from odoo import models, fields, Command, api


class DentalPatients(models.Model):
Expand Down Expand Up @@ -79,6 +79,23 @@ 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")
def _onchange_stage(self):
if self.stage == 'to invoice':
self.guarantor_id = self.env.user.id
move_vals = {
'partner_id': self.guarantor_id.id,
'move_type': 'out_invoice',
'invoice_line_ids': [
Command.create({
"name": "consultation fees",
"quantity": 1,
"price_unit": 500
})
]
}
self.env['account.move'].create(move_vals)

def book_invoice_button(self):
self.stage = 'to invoice'
self.guarantor_id = self.env.user.id
Expand All @@ -93,19 +110,12 @@ def book_invoice_button(self):
})
]
}
self.env['account.move'].check_access_rights('create')
self.env['account.move'].check_access_rule('create')
self.env['account.move'].sudo().create(move_vals)
self.env['account.move'].create(move_vals)

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',
'duration': 1,
'appointment_type_id': self.env.ref('appointment.appointment_type_dental_care').id,
'name': f"{self.name}-Dentist Appointment"
}
self.env['appointment.type'].sudo().create(move_vals)
self.env['calendar.event'].create(move_vals)
7 changes: 2 additions & 5 deletions dental/models/medical_history.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class MedicalHistory(models.Model):
_description = "Medical History"
_inherit = ["mail.thread", "mail.activity.mixin"]

name = fields.Char(string="Name", compute="_computed_name")
name = fields.Char(string="Name", compute="_computed_name", store=True)
patient_id = fields.Many2one('dental.patient', string="Patient", required=True)
date = fields.Date(string="Date", default=fields.Date.today())
did_not_attend = fields.Boolean(string="Did not attend", required=True)
Expand Down Expand Up @@ -50,10 +50,7 @@ class MedicalHistory(models.Model):
attachments_removed = fields.Boolean(string="Attachments Removed")
aligner_followup_scan = fields.Boolean(string="Aligner Follow-up Scan")

other_notes = fields.Text(string="Other Notes")

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

upper_18 = fields.Boolean(string="18 Staining")
upper_17 = fields.Boolean(string="17 Staining")
Expand Down
111 changes: 77 additions & 34 deletions dental/views/medical_history_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,42 +55,86 @@
<field name="aligner_file2" />
</group>
</group>
<group string="Tooth chart">
<group string="Tooth Chart">
<group string="Upper">
<field name="upper_18" string="18"/>
<field name="upper_17" string="17"/>
<field name="upper_16" string="16"/>
<field name="upper_15" string="15"/>
<field name="upper_14" string="14"/>
<field name="upper_13" string="13"/>
<field name="upper_12" string="12"/>
<field name="upper_11" string="11"/>
<field name="upper_28" string="28"/>
<field name="upper_27" string="27"/>
<field name="upper_26" string="26"/>
<field name="upper_25" string="25"/>
<field name="upper_24" string="24"/>
<field name="upper_23" string="23"/>
<field name="upper_22" string="22"/>
<field name="upper_21" string="21"/>
<strong>
<div>
<div class="pt-3">18</div>
<div class="pt-3">17</div>
<div class="pt-3">16</div>
<div class="pt-3">15</div>
<div class="pt-3">14</div>
<div class="pt-3">13</div>
<div class="pt-3">12</div>
<div class="pt-3">11</div>
<div class="pt-3">28</div>
<div class="pt-3">27</div>
<div class="pt-3">26</div>
<div class="pt-3">25</div>
<div class="pt-3">24</div>
<div class="pt-3">23</div>
<div class="pt-3">22</div>
<div class="pt-3">21</div>
</div>
</strong>
</group>
<group string="Upper">
<field name="upper_18" />
<field name="upper_17" />
<field name="upper_16" />
<field name="upper_15" />
<field name="upper_14" />
<field name="upper_13" />
<field name="upper_12" />
<field name="upper_11" />
<field name="upper_28" />
<field name="upper_27" />
<field name="upper_26" />
<field name="upper_25" />
<field name="upper_24" />
<field name="upper_23" />
<field name="upper_22" />
<field name="upper_21" />
</group>
<group string="Lower">
<field name="lower_38" string="38"/>
<field name="lower_37" string="37"/>
<field name="lower_36" string="36"/>
<field name="lower_35" string="35"/>
<field name="lower_34" string="34"/>
<field name="lower_33" string="33"/>
<field name="lower_32" string="32"/>
<field name="lower_31" string="31"/>
<field name="lower_48" string="48"/>
<field name="lower_47" string="47"/>
<field name="lower_46" string="46"/>
<field name="lower_45" string="45"/>
<field name="lower_44" string="44"/>
<field name="lower_43" string="43"/>
<field name="lower_42" string="42"/>
<field name="lower_41" string="41"/>
<strong>
<div>
<div class="pt-3">48</div>
<div class="pt-3">47</div>
<div class="pt-3">46</div>
<div class="pt-3">45</div>
<div class="pt-3">44</div>
<div class="pt-3">43</div>
<div class="pt-3">42</div>
<div class="pt-3">41</div>
<div class="pt-3">38</div>
<div class="pt-3">37</div>
<div class="pt-3">36</div>
<div class="pt-3">35</div>
<div class="pt-3">34</div>
<div class="pt-3">33</div>
<div class="pt-3">32</div>
<div class="pt-3">31</div>
</div>
</strong>
</group>
<group name="lower" string="Lower">
<field name="lower_48" />
<field name="lower_47" />
<field name="lower_46" />
<field name="lower_45" />
<field name="lower_44" />
<field name="lower_43" />
<field name="lower_42" />
<field name="lower_41" />
<field name="lower_38" />
<field name="lower_37" />
<field name="lower_36" />
<field name="lower_35" />
<field name="lower_34" />
<field name="lower_33" />
<field name="lower_32" />
<field name="lower_31" />
</group>
</group>
<group string="Treatment notes">
Expand All @@ -107,7 +151,6 @@
<field name="fissure_sealant_qty" widget="float" />
<field name="attachments_removed" widget="boolean" />
<field name="aligner_followup_scan" widget="boolean" />
<field name="other_notes" widget="text" />
</group>

<div>
Expand Down
Loading

0 comments on commit e459d24

Please sign in to comment.