mirror of
https://github.com/bringout/odoomates.git
synced 2026-04-26 04:52:01 +02:00
Initial commit: Odoomates Odoo packages (12 packages)
This commit is contained in:
commit
3b38c49bf0
526 changed files with 34983 additions and 0 deletions
|
|
@ -0,0 +1,4 @@
|
|||
from . import patient
|
||||
from . import doctor
|
||||
from . import appointment
|
||||
from . import sale
|
||||
|
|
@ -0,0 +1,83 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from odoo import api, fields, models, _
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
|
||||
class HospitalAppointment(models.Model):
|
||||
_name = "hospital.appointment"
|
||||
_inherit = ['mail.thread', 'mail.activity.mixin']
|
||||
_description = "Hospital Appointment"
|
||||
_order = "doctor_id,name,age"
|
||||
|
||||
name = fields.Char(string='Order Reference', required=True, copy=False, readonly=True,
|
||||
default=lambda self: _('New'))
|
||||
patient_id = fields.Many2one('hospital.patient', string="Patient", required=True)
|
||||
age = fields.Integer(string='Age', related='patient_id.age', tracking=True, store=True)
|
||||
doctor_id = fields.Many2one('hospital.doctor', string="Doctor", required=True)
|
||||
gender = fields.Selection([
|
||||
('male', 'Male'),
|
||||
('female', 'Female'),
|
||||
('other', 'Other'),
|
||||
], string="Gender")
|
||||
state = fields.Selection([('draft', 'Draft'), ('confirm', 'Confirmed'),
|
||||
('done', 'Done'), ('cancel', 'Cancelled')], default='draft',
|
||||
string="Status", tracking=True)
|
||||
note = fields.Text(string='Description')
|
||||
date_appointment = fields.Date(string="Date")
|
||||
date_checkup = fields.Datetime(string="Check Up Time")
|
||||
prescription = fields.Text(string="Prescription")
|
||||
prescription_line_ids = fields.One2many('appointment.prescription.lines', 'appointment_id',
|
||||
string="Prescription Lines")
|
||||
|
||||
def action_confirm(self):
|
||||
self.state = 'confirm'
|
||||
|
||||
def action_done(self):
|
||||
self.state = 'done'
|
||||
|
||||
def action_draft(self):
|
||||
self.state = 'draft'
|
||||
|
||||
def action_cancel(self):
|
||||
self.state = 'cancel'
|
||||
|
||||
@api.model
|
||||
def create(self, vals):
|
||||
if vals.get('name', _('New')) == _('New'):
|
||||
vals['name'] = self.env['ir.sequence'].next_by_code('hospital.appointment') or _('New')
|
||||
res = super(HospitalAppointment, self).create(vals)
|
||||
return res
|
||||
|
||||
@api.onchange('patient_id')
|
||||
def onchange_patient_id(self):
|
||||
if self.patient_id:
|
||||
if self.patient_id.gender:
|
||||
self.gender = self.patient_id.gender
|
||||
if self.patient_id.note:
|
||||
self.note = self.patient_id.note
|
||||
else:
|
||||
self.gender = ''
|
||||
self.note = ''
|
||||
|
||||
def unlink(self):
|
||||
if self.state == 'done':
|
||||
raise ValidationError(_("You Cannot Delete %s as it is in Done State" % self.name))
|
||||
return super(HospitalAppointment, self).unlink()
|
||||
|
||||
def action_url(self):
|
||||
return {
|
||||
'type': 'ir.actions.act_url',
|
||||
'target': 'new',
|
||||
'url': 'https://apps.odoo.com/apps/modules/14.0/%s/' % self.prescription,
|
||||
}
|
||||
|
||||
|
||||
class AppointmentPrescriptionLines(models.Model):
|
||||
_name = "appointment.prescription.lines"
|
||||
_description = "Appointment Prescription Lines"
|
||||
|
||||
name = fields.Char(string="Medicine", required=True)
|
||||
qty = fields.Integer(string="Quantity")
|
||||
appointment_id = fields.Many2one('hospital.appointment', string="Appointment")
|
||||
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from odoo import api, fields, models, _
|
||||
|
||||
|
||||
class HospitalDoctor(models.Model):
|
||||
_name = "hospital.doctor"
|
||||
_inherit = ['mail.thread', 'mail.activity.mixin']
|
||||
_description = "Hospital Doctor"
|
||||
_rec_name = 'doctor_name'
|
||||
|
||||
doctor_name = fields.Char(string='Name', required=True, tracking=True)
|
||||
age = fields.Integer(string='Age', tracking=True, copy=False)
|
||||
gender = fields.Selection([
|
||||
('male', 'Male'),
|
||||
('female', 'Female'),
|
||||
('other', 'Other'),
|
||||
], required=True, default='male', tracking=True)
|
||||
note = fields.Text(string='Description')
|
||||
image = fields.Binary(string="Patient Image")
|
||||
appointment_count = fields.Integer(string='Appointment Count', compute='_compute_appointment_count')
|
||||
active = fields.Boolean(string="Active", default=True)
|
||||
|
||||
def copy(self, default=None):
|
||||
if default is None:
|
||||
default = {}
|
||||
if not default.get('doctor_name'):
|
||||
default['doctor_name'] = _("%s (Copy)", self.doctor_name)
|
||||
default['note'] = "Copied Record"
|
||||
return super(HospitalDoctor, self).copy(default)
|
||||
|
||||
def _compute_appointment_count(self):
|
||||
for rec in self:
|
||||
appointment_count = self.env['hospital.appointment'].search_count([('doctor_id', '=', rec.id)])
|
||||
rec.appointment_count = appointment_count
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,96 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from odoo import api, fields, models, _
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
|
||||
class HospitalPatient(models.Model):
|
||||
_name = "hospital.patient"
|
||||
_inherit = ['mail.thread', 'mail.activity.mixin']
|
||||
_description = "Hospital Patient"
|
||||
_order = "id desc"
|
||||
|
||||
@api.model
|
||||
def default_get(self, fields):
|
||||
res = super(HospitalPatient, self).default_get(fields)
|
||||
res['note'] = 'NEW Patient Created'
|
||||
return res
|
||||
|
||||
name = fields.Char(string='Name', required=True, tracking=True)
|
||||
reference = fields.Char(string='Order Reference', required=True, copy=False, readonly=True,
|
||||
default=lambda self: _('New'))
|
||||
age = fields.Integer(string='Age', tracking=True)
|
||||
gender = fields.Selection([
|
||||
('male', 'Male'),
|
||||
('female', 'Female'),
|
||||
('other', 'Other'),
|
||||
], required=True, default='male', tracking=True)
|
||||
note = fields.Text(string='Description')
|
||||
state = fields.Selection([('draft', 'Draft'), ('confirm', 'Confirmed'),
|
||||
('done', 'Done'), ('cancel', 'Cancelled')], default='draft',
|
||||
string="Status", tracking=True)
|
||||
responsible_id = fields.Many2one('res.partner', string="Responsible")
|
||||
appointment_count = fields.Integer(string='Appointment Count', compute='_compute_appointment_count')
|
||||
image = fields.Binary(string="Patient Image")
|
||||
appointment_ids = fields.One2many('hospital.appointment', 'patient_id', string="Appointments")
|
||||
|
||||
def _compute_appointment_count(self):
|
||||
for rec in self:
|
||||
appointment_count = self.env['hospital.appointment'].search_count([('patient_id', '=', rec.id)])
|
||||
rec.appointment_count = appointment_count
|
||||
|
||||
def action_confirm(self):
|
||||
for rec in self:
|
||||
rec.state = 'confirm'
|
||||
|
||||
def action_done(self):
|
||||
for rec in self:
|
||||
rec.state = 'done'
|
||||
|
||||
def action_draft(self):
|
||||
for rec in self:
|
||||
rec.state = 'draft'
|
||||
|
||||
def action_cancel(self):
|
||||
for rec in self:
|
||||
rec.state = 'cancel'
|
||||
|
||||
@api.model
|
||||
def create(self, vals):
|
||||
if not vals.get('note'):
|
||||
vals['note'] = 'New Patient'
|
||||
if vals.get('reference', _('New')) == _('New'):
|
||||
vals['reference'] = self.env['ir.sequence'].next_by_code('hospital.patient') or _('New')
|
||||
res = super(HospitalPatient, self).create(vals)
|
||||
return res
|
||||
|
||||
@api.constrains('name')
|
||||
def check_name(self):
|
||||
for rec in self:
|
||||
patients = self.env['hospital.patient'].search([('name', '=', rec.name), ('id', '!=', rec.id)])
|
||||
if patients:
|
||||
raise ValidationError(_("Name %s Already Exists" % rec.name))
|
||||
|
||||
@api.constrains('age')
|
||||
def check_age(self):
|
||||
for rec in self:
|
||||
if rec.age == 0:
|
||||
raise ValidationError(_("Age Cannot Be Zero .. !"))
|
||||
|
||||
def name_get(self):
|
||||
result = []
|
||||
for rec in self:
|
||||
name = '[' + rec.reference + '] ' + rec.name
|
||||
result.append((rec.id, name))
|
||||
return result
|
||||
|
||||
def action_open_appointments(self):
|
||||
return {
|
||||
'type': 'ir.actions.act_window',
|
||||
'name': 'Appointments',
|
||||
'res_model': 'hospital.appointment',
|
||||
'domain': [('patient_id', '=', self.id)],
|
||||
'context': {'default_patient_id': self.id},
|
||||
'view_mode': 'tree,form',
|
||||
'target': 'current',
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from odoo import api, fields, models
|
||||
|
||||
|
||||
class SaleOrder(models.Model):
|
||||
_inherit = "sale.order"
|
||||
|
||||
sale_description = fields.Char(string='Sale Description')
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue