Skip to content

Commit

Permalink
[IMP] dental: Add controller
Browse files Browse the repository at this point in the history
-Create Controller
-Show the the list of patient
-Redirect medical aid and personal and medical history to the  form view of these
  • Loading branch information
krku-odoo committed Sep 6, 2024
1 parent 0937960 commit 44a3499
Show file tree
Hide file tree
Showing 22 changed files with 299 additions and 69 deletions.
1 change: 0 additions & 1 deletion company/__init__.py

This file was deleted.

16 changes: 0 additions & 16 deletions company/__manifest__.py

This file was deleted.

1 change: 0 additions & 1 deletion company/models/__init__.py

This file was deleted.

12 changes: 0 additions & 12 deletions company/models/employee_management.py

This file was deleted.

2 changes: 0 additions & 2 deletions company/security/ir.model.access.csv

This file was deleted.

20 changes: 0 additions & 20 deletions company/views/employee_view.xml

This file was deleted.

8 changes: 0 additions & 8 deletions company/views/menu.xml

This file was deleted.

1 change: 1 addition & 0 deletions dental/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
from . import models
from . import controller
1 change: 1 addition & 0 deletions dental/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"views/habits.xml",
"views/allergies.xml",
"views/medication.xml",
"views/dental_controller.xml",
"views/patient_history.xml",
"views/menuitem.xml",
],
Expand Down
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_controller
75 changes: 75 additions & 0 deletions dental/controller/dental_controller.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
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
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/<int:record_id>"],
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/<int:patient_id>"],
type="http",
auth="public",
website=True,
)
def show_dental_history(self, patient_id, **kwargs):
data = request.env["dental.patients"].sudo().browse(patient_id)
return request.render(
"dental.dental_history_view",
{
"patients": data,
},
)
6 changes: 2 additions & 4 deletions dental/models/dental_patient.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down Expand Up @@ -78,12 +78,10 @@ class PatientModel(models.Model):
guarantor_tags = fields.Many2many(string="Tags", related="guarantor_id.category_id")

def action_open_invoice(self):
if self.state == "new":
print("invoice")
if self.state == "to invoice":
for patient_id in self:
self.ensure_one()
invoice_obj = self.env["account.move"]
print(patient_id.guarantor_id)
invoice_vals = {
"partner_id": patient_id.guarantor_id.id,
"move_type": "out_invoice",
Expand Down
1 change: 1 addition & 0 deletions dental/models/medical_aids.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ class MedicalAidsModel(models.Model):
tracking=True,
default="new",
)
pateint_id = fields.One2many("dental.patients", "medical_aid_id")
13 changes: 13 additions & 0 deletions dental/static/icons/Bill.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions dental/static/icons/bag.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 44a3499

Please sign in to comment.