Ver código fonte

Registro de visita SIS

Sebas 5 anos atrás
commit
3f2d355826

+ 6 - 0
__init__.py

@@ -0,0 +1,6 @@
+# -*- coding: utf-8 -*-
+# License, author and contributors information in:
+# __openerp__.py file at the root folder of this module.
+
+from . import models
+# from . import reports

BIN
__init__.pyc


+ 41 - 0
__openerp__.py

@@ -0,0 +1,41 @@
+# -*- coding: utf-8 -*-
+###############################################################################
+
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+###############################################################################
+
+{
+    'name': 'Historia clínica médica',
+    'summary': 'Registrar historia clínica médica',
+    'category': 'Sale',
+    'version': '0.1',
+    'description': """
+    """,
+    'author': 'Sebastian Penayo - Eiru Software',
+    'website': 'https://www.eiru.com.py',
+    'depends': [
+        'product',
+        'account',
+        'sale',
+    ],
+    'data': [
+        'data/report_paperformat_sis.xml',
+        'data/sequence_sis.xml',
+        'views/clinic_history_sis.xml',
+    ],
+    'test': [
+    ],
+    'installable': True,
+}

+ 20 - 0
data/report_paperformat_sis.xml

@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+    <data>
+        <record id="paperformat_clinic_history" model="report.paperformat">
+            <field name="name">Historial clinica</field>
+            <field name="default" eval="True"/>
+            <field name="format">custom</field>
+            <field name="page_height">150</field>
+            <field name="page_width">80</field>
+            <field name="orientation">Portrait</field>
+            <field name="margin_top">1</field>
+            <field name="margin_bottom">1</field>
+            <field name="margin_left">1</field>
+            <field name="margin_right">1</field>
+            <field name="header_line" eval="False" />
+            <field name="header_spacing">0</field>
+            <field name="dpi">300</field>
+        </record>
+    </data>
+</openerp>

+ 20 - 0
data/sequence_sis.xml

@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+    <data noupdate="1">
+
+        <!-- Sequences for repair.workorder -->
+        <record id="seq_type_medicorder" model="ir.sequence.type">
+            <field name="name">Orden de Visita</field>
+            <field name="code">clinic.history</field>
+        </record>
+
+        <record id="seq_medic_order" model="ir.sequence">
+            <field name="name">Orden de Visita</field>
+            <field name="code">clinic.history</field>
+            <field name="prefix">HV</field>
+            <field name="padding">3</field>
+            <field name="company_id" eval="False"/>
+        </record>
+
+    </data>
+</openerp>

+ 5 - 0
models/__init__.py

@@ -0,0 +1,5 @@
+# -*- coding: utf-8 -*-
+# License, author and contributors information in:
+# __openerp__.py file at the root folder of this module.
+
+from . import medic_clinic

BIN
models/__init__.pyc


+ 293 - 0
models/medic_clinic.py

@@ -0,0 +1,293 @@
+# -*- coding: utf-8 -*-
+# License, author and contributors information in:
+# __openerp__.py file at the root folder of this module.
+
+from openerp import api, models, fields
+from openerp.exceptions import ValidationError, except_orm, Warning, RedirectWarning
+import logging
+
+_log = logging.getLogger(__name__)
+
+
+class MedicClinic(models.Model):
+    _name = 'clinic.history'
+    _description = 'Historial clínica médica'
+    _inherit = ['mail.thread', 'ir.needaction_mixin']
+
+    def _get_user(self):
+        return self.env.uid
+
+    def _get_number(self):
+        return self.env['ir.sequence'].get('clinic.history') or '*'
+
+    name = fields.Char(
+        string=u'Codigo',
+        readonly=True,
+        default=_get_number
+    )
+    user_id = fields.Many2one(
+        comodel_name='res.users',
+        string='Médico',
+        default=_get_user
+    )
+    partner_id = fields.Many2one(
+        comodel_name='res.partner',
+        string='Cliente'
+    )
+    paciente_id = fields.Many2one(
+        comodel_name='res.partner',
+        string='Paciente'
+    )
+    lugar_visita = fields.Selection([('domicilio','A domicilio'),('via','Vía pública'),('comercio','Comercio'),('sanatorio','Sanatorio')],'Lugar atendido')
+    tipo_paciente = fields.Selection([('directivo','Directivo'),('externo','Cliente externo'),('Trabajador','Trabajador'),('otro','Otros')],'Tipo de paciente')
+    line_ids = fields.One2many(
+        comodel_name='clinic.history.line',
+        inverse_name='clinichistory_id',
+        string='Trabajos hechos'
+    )
+    # consumed_ids = fields.One2many(
+    #     comodel_name='clinic.history.consumed',
+    #     inverse_name='clinichistory_id ',
+    #     string='Productos y Servicios consumidos'
+    # )
+    order_date = fields.Datetime(
+        string='Fecha de Carga',
+        default=fields.Datetime.now
+    )
+    planned_start_date = fields.Datetime(
+        string='Fecha y hora de Recepción'
+    )
+    planned_end_date = fields.Datetime(
+        string='Fecha y hora de Atención'
+    )
+    name_movil = fields.Char(
+        string='Móvil'
+    )
+    nro_salida = fields.Char(
+        string='N° de Salida'
+    )
+    seguro = fields.Char(
+        string='Seguro'
+    )
+    nro_socio = fields.Char(
+        string='N° de Socio'
+    )
+    alergico = fields.Selection([('si','Sí'),('no','No')],'Alérgico?')
+    embarazada = fields.Selection([('si','Sí'),('no','No')],'Embarazada?')
+    pa = fields.Char(
+        string='P.A.'
+    )
+    fc = fields.Char(
+        string='F.C.'
+    )
+    fr = fields.Char(
+        string='F.R.'
+    )
+    temp = fields.Char(
+        string='T.'
+    )
+    so = fields.Char(
+        string='SO.'
+    )
+    hgt = fields.Char(
+        string='HGT'
+    )
+    motivo = fields.Text(
+        string='Motivo de la consulta'
+    )
+    diagnostic = fields.Text(
+        string='Hallazgo Positivo'
+    )
+    indicacion = fields.Text(
+        string='Indicación Médica'
+    )
+    actions = fields.Text(
+        string='Acciones'
+    )
+    recommendations = fields.Text(
+        string="Tratamiento Administrado"
+    )
+    epicrisis = fields.Char(
+        string='Epicrisis'
+    )
+    presuntivo = fields.Char(
+        string='Diagnóstico Presuntivo'
+    )
+    clasificacion = fields.Selection([('emergencia','Emergencia'),('urgencia','Urgencia'),('consulta','Consulta'),('suministro','Suministro'),('tar','T.A.R'),('tbr','T.B.R')],'Clasificación de la Atención')
+    state = fields.Selection([
+        ('draft', 'Pendiente'),
+        ('in_progress', 'En progreso'),
+        ('done', 'Hecho'),
+        ('canceled', 'Cancelado')],
+        string='Estado',
+        default='draft'
+    )
+    # invoicehistory_ids = fields.One2many('account.invoice', 'clinichistory_invoice_id')
+    # invoicehistory_count = fields.Integer(
+    #     string='Facturas',
+    #     compute='_get_invoice_count',
+    # )
+
+    # @api.multi
+    # def button_draft(self):
+    #     if self.invoicehistory_count > 0:
+    #         raise Warning('Este trabajo tiene una factura asociada')
+    #     if self.invoicehistory_count == 0:
+    #         for history in self:
+    #             history.write({'state': 'draft'})
+    #         return True
+    #
+    # @api.one
+    # @api.depends('invoicehistory_ids')
+    # def _get_invoice_count(self):
+    #     self.invoice_counthistory = len(self.invoicehistory_ids)
+
+    @api.one
+    def onchange_partner_id(self, partner_id):
+        _log.info('-'*100)
+        _log.info(partner_id)
+
+    @api.one
+    def button_in_progress(self):
+        self.state = 'in_progress'
+
+    @api.one
+    def button_in_progress_back(self):
+        self.state = 'draft'
+
+    @api.one
+    def button_done(self):
+        # product = self.line_ids
+        works = self.consumed_ids
+        if not product or not works:
+            raise Warning('El trabajo debe tener productos y trabajos asociados')
+        else:
+            self.state = 'done'
+
+    @api.one
+    def button_done_back(self):
+        self.state = 'in_progress'
+
+    @api.one
+    def button_cancel(self):
+        self.state = 'canceled'
+
+    # @api.multi
+    # def Facturado(self):
+    #     inv_obj = self.env['account.invoice']
+    #     inv_line_obj = self.env['account.invoice.line']
+    #     customer = self.partner_id
+    #     if not customer.name:
+    #         raise osv.except_osv(_('UserError!'), _('Por favor seleccione el cliente.'))
+    #     company_id = self.env['res.users'].browse(1).company_id
+    #     self.ensure_one()
+    #     ir_values = self.env['ir.values']
+    #     inv_data = {
+    #         'name': customer.name,
+    #         'reference': customer.name,
+    #         'account_id': customer.property_account_receivable.id,
+    #         'partner_id': customer.id,
+    #         'origin': self.name,
+    #         'clinichistory_invoice_id ': self.id
+    #     }
+    #     inv_id = inv_obj.create(inv_data)
+    #     for records in self.consumed_ids:
+    #         if records.product_id.id:
+    #             income_account = records.product_id.categ_id.property_account_income_categ.id
+    #         if not income_account:
+    #             raise osv.except_osv(_('UserError!'), _('No hay cuenta definida '
+    #                                                     'para este producto: "%s".') % (records.product_id.name,))
+    #         inv_line_data = {
+    #             'name': records.product_id.name,
+    #             'account_id': income_account,
+    #             'price_unit': records.price_unit,
+    #             'quantity': records.quantity,
+    #             'product_id': records.product_id.id,
+    #             'invoice_id': inv_id.id,
+    #             'invoice_line_tax_id': [(6, 0, [x.id for x in records.product_id.taxes_id])],
+    #         }
+    #         inv_line_obj.create(inv_line_data)
+    #     self.state = 'invoiced'
+    #     imd = self.env['ir.model.data']
+    #     action = imd.xmlid_to_object('account.action_invoice_tree1')
+    #     list_view_id = imd.xmlid_to_res_id('account.invoice_tree')
+    #     form_view_id = imd.xmlid_to_res_id('account.invoice_form')
+    #     result = {
+    #         'name': action.name,
+    #         'help': action.help,
+    #         'type': 'ir.actions.act_window',
+    #         'views': [[list_view_id, 'tree'], [form_view_id, 'form'], [False, 'graph'], [False, 'kanban'],
+    #                   [False, 'calendar'], [False, 'pivot']],
+    #         'target': action.target,
+    #         'context': action.context,
+    #         'res_model': 'account.invoice',
+    #     }
+    #     if len(inv_id) > 1:
+    #         result['domain'] = "[('id','in',%s)]" % inv_id.ids
+    #     elif len(inv_id) == 1:
+    #         result['views'] = [(form_view_id, 'form')]
+    #         result['res_id'] = inv_id.ids[0]
+    #     else:
+    #         result = {'type': 'ir.actions.act_window_close'}
+    #     invoiced_records = self.env['clinic.history']
+    #     total = 0
+    #     self.stage_id = 3
+    #     for rows in invoiced_records:
+    #         invoiced_date = rows.date
+    #         invoiced_date = invoiced_date[0:10]
+    #         if invoiced_date == str(date.today()):
+    #             total = total + rows.price_subtotal
+    #     inv_id.signal_workflow('invoice_open')
+    #     return result
+
+
+class ClinicHistoryLine(models.Model):
+    _name = 'clinic.history.line'
+    _description = 'Trabajos realizados'
+    _inherit = ['mail.thread', 'ir.needaction_mixin']
+
+    clinichistory_id = fields.Many2one(
+        comodel_name='clinic.history',
+        string='Clinic History')
+
+    description = fields.Char(string='Descripción')
+    quantity = fields.Float(string='Cantidad', default=1.0)
+    brand = fields.Char(string='Marca')
+    number = fields.Char(string="Numero de serie")
+
+
+# class ClinicHistoryConsumed(models.Model):
+#     _name = 'clinic.history.consumed'
+#     _description = 'Servicios consumidos'
+#     _inherit = ['mail.thread', 'ir.needaction_mixin']
+#
+#     clinichistory_id = fields.Many2one(
+#         comodel_name='clinic.history',
+#         string='Orden de visita'
+#     )
+#     product_id = fields.Many2one(
+#         comodel_name='product.product',
+#         string='Product'
+#     )
+#     type = fields.Selection([
+#         ('service', 'Service'),
+#         ('product', 'Product')],
+#         string='Type',
+#         required=True,
+#         default='service'
+#     )
+#     description = fields.Char(
+#         string='Descripción',
+#         required=True
+#     )
+#     quantity = fields.Float(
+#         string='Cantidad',
+#         default=1
+#     )
+#     price_unit = fields.Float(
+#         string='Precio Unit.'
+#     )
+#     subtotal = fields.Float(
+#         string='Subtotal',
+#         compute='compute_subtotal'
+#     )

BIN
models/medic_clinic.pyc


+ 5 - 0
reports/__init__.py

@@ -0,0 +1,5 @@
+# -*- coding: utf-8 -*-
+# License, author and contributors information in:
+# __openerp__.py file at the root folder of this module.
+
+from . import parser

BIN
reports/__init__.pyc


+ 95 - 0
reports/parser.py

@@ -0,0 +1,95 @@
+# -*- coding: utf-8 -*-
+# License, author and contributors information in:
+# __openerp__.py file at the root folder of this module.
+
+from functools import partial
+from openerp.osv import osv
+from openerp import exceptions, _
+from reportlab.graphics.barcode import createBarcodeDrawing
+
+
+class PartnerReport(osv.AbstractModel):
+    _name = 'report.repair_workorder_mejorado.partner_report'
+
+    def get_total(self, cr, uid, workorder, context=None):
+        total = 0
+        for line_consumed in workorder.consumed_ids:
+            total += line_consumed.quantity * line_consumed.price_unit
+        return total
+
+    def render_html(self, cr, uid, ids, data=None, context=None):
+        report_obj = self.pool['report']
+        repair_workorder_obj = self.pool['repair.workorderimproved']
+        report = report_obj._get_report_from_name(
+            cr, uid, 'repair_workorder_mejorado.partner_report')
+        selected_orders = repair_workorder_obj.browse(
+            cr, uid, ids, context=context)
+
+        docargs = {
+            'doc_ids': ids,
+            'doc_model': report.model,
+            'docs': selected_orders,
+            'get_total': partial(
+                self.get_total, cr, uid, context=context),
+            'printBarcode': partial(
+                self.printBarcode, cr, uid, context=context),
+        }
+
+        return report_obj.render(
+            cr, uid, ids, 'repair_workorder_mejorado.partner_report',
+            docargs, context=context)
+
+    def printBarcode(self, cr, uid, value, width, height, context=None):
+        try:
+            width, height = int(width), int(height)
+            barcode = createBarcodeDrawing(
+                'EAN13', value=value, format='png', width=width, height=height)
+            barcode = barcode.asString('png')
+            barcode = barcode.encode('base64', 'strict')
+        except (ValueError, AttributeError):
+            raise exceptions.Warning(_('Cannot convert into barcode.'))
+
+        return barcode
+
+
+class CompanyReport(osv.AbstractModel):
+    _name = 'report.repair_workorder_mejorado.company_report'
+
+    def get_total(self, cr, uid, workorder, context=None):
+        total = 0
+        for line_consumed in workorder.consumed_ids:
+            total += line_consumed.quantity * line_consumed.price_unit
+        return total
+
+    def render_html(self, cr, uid, ids, data=None, context=None):
+        report_obj = self.pool['report']
+        repair_workorder_obj = self.pool['repair.workorderimproved']
+        report = report_obj._get_report_from_name(
+            cr, uid, 'repair_workorder_mejorado.company_report')
+        selected_orders = repair_workorder_obj.browse(
+            cr, uid, ids, context=context)
+
+        docargs = {
+            'doc_ids': ids,
+            'doc_model': report.model,
+            'docs': selected_orders,
+            'get_total': partial(
+                self.get_total, cr, uid, context=context),
+            'printBarcode': partial(
+                self.printBarcode, cr, uid, context=context),
+        }
+        return report_obj.render(
+            cr, uid, ids, 'repair_workorder_mejorado.company_report',
+            docargs, context=context)
+
+    def printBarcode(self, cr, uid, value, width, height, context=None):
+        try:
+            width, height = int(width), int(height)
+            barcode = createBarcodeDrawing(
+                'EAN13', value=value, format='png', width=width, height=height)
+            barcode = barcode.asString('png')
+            barcode = barcode.encode('base64', 'strict')
+        except (ValueError, AttributeError):
+            raise exceptions.Warning(_('Cannot convert into barcode.'))
+
+        return barcode

BIN
reports/parser.pyc


+ 181 - 0
reports/work_order_company.xml

@@ -0,0 +1,181 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+    <data>
+
+        <!-- Declarar el informe -->
+        <report
+            id="action_work_order_company_mejorado_report"
+            string="Work order (company copy)"
+            model="repair.workorderimproved"
+            report_type="qweb-pdf"
+            name="repair_workorder_mejorado.company_report"
+            file="workorder_company"
+         />
+
+        <record id="action_work_order_company_mejorado_report" model="ir.actions.report.xml">
+            <field name="paperformat_id" ref="repair_workorder_mejorado.paperformat_repair_workorder"/>
+        </record>
+
+        <!-- Informe -->
+        <template id="company_report">
+            <t t-call="report.html_container">
+                <t t-foreach="doc_ids" t-as="doc_id">
+                    <t t-raw="translate_doc(doc_id, doc_model, 'partner_id.lang', 'repair_workorder_mejorado.company_report_document')"/>
+                </t>
+            </t>
+        </template>
+
+        <template id="workorder_company">
+            <div class="page">
+                <style>
+                    body {
+                        color: #000;
+                        font-family: Arial, Helvetica, sans-serif;
+                        font-size: 14px;
+                        letter-spacing: 0.0px;
+                        line-height: 20px;
+                        margin:0;
+                        padding:0;
+                        word-spacing:1px;
+                    }
+                    .text-lg {
+                        font-size: 18px;
+                        font-weight: bold;
+                    }
+                    .text-md {
+                        display: inline-block;
+                        font-size: 18px;
+                        font-weight: bold;
+                    }
+                    .bordered {
+                        border: 1px solid #000;
+                        padding: 10px;
+                    }
+                    /* http://www.squareonemd.co.uk/how-to-crop-an-image-with-a-css-class/ */
+                    .image-container {
+                        width: 366px;
+                        text-align: center;
+                    }
+                    .image-cropper {
+                        position: relative;
+                        height: 45px;
+                        overflow: hidden;
+                    }
+                    .centered {
+                        position: absolute;
+                        left: -50%;
+                        top: -50%;
+                        max-width: 100%;
+                    }
+                    .bottom {
+                        position: absolute;
+                        bottom: 0px;
+                        max-width: 100%;
+                    }
+                    .top {
+                        position: absolute;
+                        top: 0px;
+                        max-width: 100%;
+                    }
+                    .separator {
+                        border-top: 1px solid #000;
+                        margin-top: 20px;
+                        margin-bottom: 20px;
+                    }
+                </style>
+                <section class="header">
+                    <div class="row">
+                        <div class="col-xs-12">
+                        <p class="text-center" style="margin-top: 10px; margin-bottom: 10px;"><span class="text-lg">PARTE TRABAJO <span t-if="o.name" t-field="o.name"/></span></p>
+                        <div class="image-container">
+                            <div class="image-cropper">
+                                <img class="top" t-att-src="'data:image/png;base64,%s' % printBarcode(o.id, 732, 472)"/>
+                            </div>
+                        </div>
+                        </div>
+                    </div>
+                </section>
+                <div class="row"><div class="col-xs-12"><div class="separator"/></div></div>
+                <div class="row">
+                    <div class="col-xs-12">
+                        MATERIAL A RECOGER<br/>
+                        <t t-if="o.line_ids">
+                            <table class="order_lines" style="width: 100%;">
+                                <thead>
+                                    <tr>
+                                        <th style="width: 75%;">Concepto</th>
+                                        <th style="width: 25%;" class="text-right">Uds.</th>
+                                    </tr>
+                                </thead>
+                                <tbody>
+                                    <t t-foreach="o.line_ids" t-as="line">
+                                        <tr>
+                                            <td><span t-if="line.description" t-field="line.description"></span></td>
+                                            <td class="text-right"><span t-if="line.quantity" t-field="line.quantity"></span></td>
+                                        </tr>
+                                    </t>
+                                </tbody>
+                            </table>
+                        </t>
+                        <br/>
+                        <span class="text-md">Fecha Recogida: <span t-if="o.planned_end_date" t-field="o.planned_end_date"/></span><br/>
+                        Cliente: <span t-if="o.partner_id.name" t-field="o.partner_id.name"/><br/>
+                        Teléfono: <span t-if="o.partner_id.phone" t-field="o.partner_id.phone"/><t t-if="o.partner_id.mobile"> - <span t-field="o.partner_id.mobile"/></t><br/>
+                        Fecha Entrada: <span t-if="o.order_date" t-field="o.order_date"/>
+                    </div>
+                </div>
+                <t t-if="o.consumed_ids">
+                    <div class="row"><div class="col-xs-12"><div class="separator"/></div></div>
+                    <table class="consumed_lines" style="width: 100%;">
+                        <thead>
+                            <tr>
+                                <th style="width: 45%;">Concepto</th>
+                                <th style="width: 15%;" class="text-right">Uds.</th>
+                                <th style="width: 20%;" class="text-right">Precio</th>
+                                <th style="width: 20%;" class="text-right">Subtotal</th>
+                            </tr>
+                        </thead>
+                        <tbody>
+                            <t t-foreach="o.consumed_ids" t-as="consumed">
+                                <tr>
+                                    <td><span t-if="consumed.description" t-field="consumed.description"/></td>
+                                    <td class="text-right"><span t-if="consumed.quantity" t-field="consumed.quantity"/></td>
+                                    <td class="text-right"><span t-if="consumed.price_unit" t-field="consumed.price_unit"/></td>
+                                    <td class="text-right"><span t-if="consumed.subtotal and consumed.price_unit" t-raw="consumed.quantity * consumed.price_unit"/></td>
+                                </tr>
+                            </t>
+                        </tbody>
+                    </table>
+                    <t t-set="total" t-value="get_total(o)"/>
+                    <p class="text-right" style="margin-top: 10px; margin-bottom: 0px;">Total <span class="text-md" t-esc="total"></span></p>
+                </t>
+                <t t-if="o.causes">
+                    <div class="row"><div class="col-xs-12"><div class="separator"/></div></div>
+                    <div class="row">
+                        <div class="col-xs-12">
+                            <div t-field="o.causes"/>
+                        </div>
+                    </div>
+                </t>
+                <div class="row"><div class="col-xs-12"><div class="separator"/></div></div>
+                <div class="row">
+                    <div class="col-xs-6">
+                        <p class="text-center bordered sign"><br/><br/><br/><br/>Firma cliente</p>
+                    </div>
+                    <div class="col-xs-6">
+                        <p class="agreement">Doy mi consentimiento para la realización de las operaciones y montaje del material aquí descritos.</p>
+                    </div>
+                </div>
+            </div>
+        </template>
+
+        <!-- Contenido del informe -->
+        <template id="company_report_document">
+            <t t-call="report.html_container">
+                <t t-call="repair_workorder_mejorado.workorder_company"/>
+            </t>
+        </template>
+
+
+    </data>
+</openerp>

+ 191 - 0
reports/work_order_partner.xml

@@ -0,0 +1,191 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+    <data>
+
+        <!-- Declarar el informe -->
+        <report
+            id="action_work_order_partner_mejorado_report"
+            string="Work order (partner copy)"
+            model="repair.workorderimproved"
+            report_type="qweb-pdf"
+            name="repair_workorder_mejorado.partner_report"
+            file="workorder_partner"
+         />
+
+        <record id="action_work_order_partner_mejorado_report" model="ir.actions.report.xml">
+            <field name="paperformat_id" ref="repair_workorder_mejorado.paperformat_repair_workorder"/>
+        </record>
+
+        <!-- Informe -->
+        <template id="partner_report">
+            <t t-call="report.html_container">
+                <t t-foreach="doc_ids" t-as="doc_id">
+                    <t t-raw="translate_doc(doc_id, doc_model, 'partner_id.lang', 'repair_workorder_mejorado.partner_report_document')"/>
+                </t>
+            </t>
+        </template>
+
+        <template id="workorder_partner">
+            <div class="page">
+                <style>
+                    body {
+                        color: #000;
+                        font-family: Arial, Helvetica, sans-serif;
+                        font-size: 14px;
+                        letter-spacing: 0.0px;
+                        line-height: 20px;
+                        margin:0;
+                        padding:0;
+                        word-spacing:1px;
+                    }
+                    .text-lg {
+                        font-size: 18px;
+                        font-weight: bold;
+                    }
+                    .text-md {
+                        display: inline-block;
+                        font-size: 18px;
+                        font-weight: bold;
+                    }
+                    .bordered {
+                        border: 1px solid #000;
+                        padding: 10px;
+                    }
+                    /* http://www.squareonemd.co.uk/how-to-crop-an-image-with-a-css-class/ */
+                    .image-container {
+                        width: 366px;
+                        text-align: center;
+                    }
+                    .image-cropper {
+                        position: relative;
+                        height: 45px;
+                        overflow: hidden;
+                    }
+                    .centered {
+                        position: absolute;
+                        left: -50%;
+                        top: -50%;
+                        max-width: 100%;
+                    }
+                    .bottom {
+                        position: absolute;
+                        bottom: 0px;
+                        max-width: 100%;
+                    }
+                    .top {
+                        position: absolute;
+                        top: 0px;
+                        max-width: 100%;
+                    }
+                    .separator {
+                        border-top: 1px solid #000;
+                        margin-top: 20px;
+                        margin-bottom: 20px;
+                    }
+                </style>
+                <section class="header">
+                    <div class="row">
+                        <div class="col-xs-12">
+                            <p class="text-center" style="margin-top: 10px; margin-bottom: 10px;"><span class="text-lg">COMPROBANTE SAT <span t-if="o.name" t-field="o.name"/></span></p>
+                            <div class="image-container">
+                                <div class="image-cropper">
+                                    <img class="top" t-att-src="'data:image/png;base64,%s' % printBarcode(o.id, 732, 472)"/>
+                                </div>
+                            </div>
+                        </div>
+                    </div>
+                </section>
+                <div class="row"><div class="col-xs-12"><div class="separator"/></div></div>
+                <div class="row">
+                    <div class="col-xs-12">
+                        MATERIAL A RECOGER<br/>
+                        <t t-if="o.line_ids">
+                            <table class="order_lines" style="width: 100%;">
+                                <thead>
+                                    <tr>
+                                        <th style="width: 75%;">Concepto</th>
+                                        <th style="width: 25%;" class="text-right">Uds.</th>
+                                    </tr>
+                                </thead>
+                                <tbody>
+                                    <t t-foreach="o.line_ids" t-as="line">
+                                        <tr>
+                                            <td><span t-if="line.description" t-field="line.description"></span></td>
+                                            <td class="text-right"><span t-if="line.quantity" t-field="line.quantity"></span></td>
+                                        </tr>
+                                    </t>
+                                </tbody>
+                            </table>
+                        </t>
+                        <br/>
+                        Cliente: <span t-if="o.partner_id.name" t-field="o.partner_id.name"/><br/>
+                        Teléfono: <span t-if="o.partner_id.phone" t-field="o.partner_id.phone"/><t t-if="o.partner_id.mobile"> - <span t-field="o.partner_id.mobile"/></t><br/>
+                        Fecha Entrada: <span t-if="o.order_date" t-field="o.order_date"/><br/>
+                        Fecha Recogida: <span t-if="o.planned_end_date" t-field="o.planned_end_date"/>
+                    </div>
+                </div>
+                <t t-if="o.consumed_ids">
+                    <div class="row"><div class="col-xs-12"><div class="separator"/></div></div>
+                    <table class="consumed_lines" style="width: 100%;">
+                        <thead>
+                            <tr>
+                                <th style="width: 45%;">Concepto</th>
+                                <th style="width: 15%;" class="text-right">Uds.</th>
+                                <th style="width: 20%;" class="text-right">Precio</th>
+                                <th style="width: 20%;" class="text-right">Subtotal</th>
+                            </tr>
+                        </thead>
+                        <tbody>
+                            <t t-foreach="o.consumed_ids" t-as="consumed">
+                                <tr>
+                                    <td><span t-if="consumed.description" t-field="consumed.description"/></td>
+                                    <td class="text-right"><span t-if="consumed.quantity" t-field="consumed.quantity"/></td>
+                                    <td class="text-right"><span t-if="consumed.price_unit" t-field="consumed.price_unit"/></td>
+                                    <td class="text-right"><span t-if="consumed.subtotal and consumed.price_unit" t-raw="consumed.quantity * consumed.price_unit"/></td>
+                                </tr>
+                            </t>
+                        </tbody>
+                    </table>
+                    <t t-set="total" t-value="get_total(o)"/>
+                    <p class="text-right" style="margin-top: 10px; margin-bottom: 0px;">Total <span class="text-md" t-esc="total"></span> EUR</p>
+
+                </t>
+                <section class="warning">
+                    <div class="row"><div class="col-xs-12"><div class="separator"/></div></div>
+                    <div class="row">
+                        <div class="col-xs-12">
+                            <p style="text-align: justify; margin-bottom: 0px;">
+                                <small class="warning-text">Presupuesto estimado, si durante la reparación el importe se modificara sustancialmente se consultará al cliente para su aprobación.</small>
+                            </p>
+                        </div>
+                    </div>
+                </section>
+                <t t-if="o.partner_id.company_id">
+                    <div class="row"><div class="col-xs-12"><div class="separator"/></div></div>
+                    <div class="row">
+                        <div class="col-xs-12">
+                            <p class="company-info text-center">
+                                <t t-if="o.partner_id.company_id.name"><span t-field="o.partner_id.company_id.name"/></t>
+                                <t t-if="o.partner_id.company_id.street">- <span t-field="o.partner_id.company_id.street"/>,</t>
+                                <t t-if="o.partner_id.company_id.zip"> <span t-field="o.partner_id.company_id.zip"/></t>
+                                <t t-if="o.partner_id.company_id.city">- <span t-field="o.partner_id.company_id.city"/></t>
+                                <t t-if="o.partner_id.company_id.state_id">(<span t-field="o.partner_id.company_id.state_id.name"/>)</t>
+                                <t t-if="o.partner_id.company_id.phone">- <span t-field="o.partner_id.company_id.phone"/></t>
+                                <t t-if="o.partner_id.company_id.email">- <span t-field="o.partner_id.company_id.email"/></t>
+                                <t t-if="o.partner_id.company_id.website">- <span t-field="o.partner_id.company_id.website"/></t>
+                            </p>
+                        </div>
+                    </div>
+                </t>
+            </div>
+        </template>
+
+        <!-- Contenido del informe -->
+        <template id="partner_report_document">
+            <t t-call="report.html_container">
+                <t t-call="repair_workorder_mejorado.workorder_partner"/>
+            </t>
+        </template>
+
+    </data>
+</openerp>

+ 298 - 0
views/clinic_history_sis.xml

@@ -0,0 +1,298 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<openerp>
+    <data>
+
+        <!-- tree view -->
+
+        <record id="tree_clinic_history_sis" model="ir.ui.view">
+            <field name="name">clinic.history.sis.tree</field>
+            <field name="model">clinic.history</field>
+            <field name="arch" type="xml">
+                <tree string="Orden Clinico">
+                    <field name="name"/>
+                    <field name="partner_id"/>
+                    <field name="paciente_id"/>
+                    <field name="order_date"/>
+                    <field name="planned_start_date"/>
+                    <field name="planned_end_date"/>
+                    <field name="lugar_visita"/>
+                    <field name="user_id"/>
+                    <field name="state"/>
+                </tree>
+            </field>
+        </record>
+
+        <!-- search view -->
+
+        <record id="search_clinic_history_sis" model="ir.ui.view">
+            <field name="name">clinic.history.sis.search</field>
+            <field name="model">clinic.history</field>
+            <field name="arch" type="xml">
+                <search string="Orden Clínico">
+                    <field name="name"/>
+                    <field name="user_id"/>
+                    <field name="partner_id"/>
+                    <field name="paciente_id"/>
+                    <field name="lugar_visita"/>
+                    <filter string="Mis tareas" domain="[('user_id','=',uid)]"/>
+                    <filter string="Realizada" domain="[('state','=','done')]"/>
+                    <separator/>
+                    <group expand="0" string="Agrupado por...">
+                        <filter string="Médico" domain="[]" context="{'group_by':'user_id'}" />
+                        <filter string="Cliente" domain="[]" context="{'group_by':'partner_id'}" />
+                        <filter string="Estado" name="State" context="{'group_by':'state'}"/>
+                    </group>
+                </search>
+            </field>
+        </record>
+
+        <!-- form view -->
+
+        <record id="form_clinic_history_sis" model="ir.ui.view">
+            <field name="name">clinic.history.sis.form</field>
+            <field name="model">clinic.history</field>
+            <field name="arch" type="xml">
+                <form string="Orden Clinico">
+                    <header>
+                        <!-- <button name="Facturado" string="Crear Factura" type="object" class="btn-primary" states="done"/> -->
+                        <button name="button_draft" string="Cambiar Estado" type="object"/>
+                        <button name="button_in_progress" type="object" states="draft,warranty" string="Crear" class="oe_highlight" groups="base.group_user"/>
+                        <button name="button_in_progress_back" type="object" states="in_progress" string="Atrás" class="oe_highlight" groups="base.group_user"/>
+                        <button name="button_done" type="object" states="in_progress" string="En progreso" class="oe_highlight" groups="base.group_user"/>
+                        <button name="button_done_back" type="object" states="done" string="Hecho" class="oe_highlight" groups="base.group_user"/>
+                        <button name="button_cancel" type="object" states="draft,warranty,in_progress" string="Cancelado" class="oe_highlight" groups="base.group_user"/>
+                        <field name="state" widget="statusbar" statusbar_visible="draft,in_progress,done" statusbar_colors='{"done":"red","warning":"blue","canceled":"red","in_progress":"blue"}'/>
+                    </header>
+                    <sheet>
+                        <div class="oe_title">
+                            <h1>
+                                <label string="Orden Clínico "/>
+                                <field name="name" class="oe_inline" readonly="1"/>
+                            </h1>
+                        </div>
+
+                        <group>
+                            <group>
+                                <field name="partner_id" on_change="onchange_partner_id(partner_id)" domain="[('customer','=',True)]" context="{'search_default_customer':1, 'show_address': 1}" options='{"always_reload": True}' attrs="{'readonly': [('state','!=', 'draft')]}" required="1"/>
+                                <field name="paciente_id" on_change="onchange_partner_id(partner_id)" domain="[('customer','=',True)]" context="{'search_default_customer':1, 'show_address': 1}" options='{"always_reload": True}' attrs="{'readonly': [('state','!=', 'draft')]}" required="1"/>
+                                <field name="user_id" required="1"/>
+                                <field name="name_movil"/>
+                                <field name="nro_salida"/>
+                                <field name="seguro"/>
+                                <field name="tipo_paciente"/>
+                                <field name="embarazada"/>
+                            </group>
+                            <group name="Dates">
+                                <field name="order_date" required="1"/>
+                                <field name="planned_start_date" required="1"/>
+                                <field name="planned_end_date" required="1"/>
+                                <field name="lugar_visita"/>
+                                <field name="nro_socio"/>
+                                <field name="alergico"/>
+                            </group>
+                        </group>
+                        <!-- <separator string="Causes"/>
+                        <field name="causes" placeholder="what happens to it"  /> -->
+                        <notebook>
+                            <page string="Signos Vitales">
+                                <group>
+                                    <group>
+                                        <field name="pa"/>
+                                        <field name="fc"/>
+                                        <field name="fr"/>
+                                    </group>
+                                    <group>
+                                        <field name="temp"/>
+                                        <field name="so"/>
+                                        <field name="hgt"/>
+                                    </group>
+                                </group>
+                            </page>
+                            <page string="Lineas de orden">
+                                <field name="line_ids"/>
+                            </page>
+                            <page string="Operaciones">
+                                <separator string="Motivos de consulta"/>
+                                <field name="motivo" placeholder="describe los motivos de consulta..."  />
+                                <separator string="Hallazgo Positivos del Examen Físico (o datos de importancia)"/>
+                                <field name="diagnostic" placeholder="describe hallazgo Positivos del Examen Físico (o datos de importancia)..."  />
+                                <separator string="Indicación Médica"/>
+                                <field name="indicacion" placeholder="describe la indicación médica..."  />
+                                <separator string="Acciones"/>
+                                <field name="actions" placeholder="describe las acciones..."  />
+                                <separator string="Recomendaciones y sugerencias"/>
+                                <field name="recommendations" placeholder="describe las recommendaciones..."  />
+                            </page>
+                            <page string="Otros datos">
+                                <separator string="Epicrisis"/>
+                                <field name="epicrisis" placeholder="describe el Epicrisis..."  />
+                                <separator string="Presuntivo"/>
+                                <field name="presuntivo" placeholder="describe presuntivo ..."  />
+                                <separator string="Clasificacion"/>
+                                <field name="clasificacion"   />
+                            </page>
+                        </notebook>
+                    </sheet>
+                    <div class="oe_chatter">
+                        <field name="message_follower_ids" widget="mail_followers" groups="base.group_user"/>
+                        <field name="message_ids" widget="mail_thread"/>
+                    </div>
+                </form>
+            </field>
+        </record>
+
+        <!-- calendar view -->
+
+        <record id="calendar_clinic_history_sis" model="ir.ui.view">
+            <field name="name">clinic.history.sis.calendar</field>
+            <field name="model">clinic.history</field>
+            <field name="arch" type="xml">
+                <calendar color="user_id" date_start="planned_start_date" string="Visitas">
+                    <field name="name"/>
+                </calendar>
+            </field>
+        </record>
+
+        <!-- gantt -->
+
+        <record id="gantt_clinic_history_sis" model="ir.ui.view">
+            <field name="name">clinic.history.sis.calendar</field>
+            <field name="model">clinic.history</field>
+            <field name="arch" type="xml">
+                <gantt date_start="planned_start_date" date_stop="planned_end_date" progress="progress" string="Actividades" default_group_by="project_id">
+                </gantt>
+            </field>
+        </record>
+
+        <!-- action -->
+
+        <record id="action_clinic_history_sis" model="ir.actions.act_window">
+            <field name="name">Historial de Visita</field>
+            <field name="type">ir.actions.act_window</field>
+            <field name="res_model">clinic.history</field>
+            <field name="view_type">form</field>
+            <field name="view_mode">tree,form,calendar,gantt</field>
+            <field name="search_view_id" ref="search_clinic_history_sis"/>
+        </record>
+
+        <!-- tree view -->
+
+        <record id="tree_clinic_history_line_sis" model="ir.ui.view">
+            <field name="name">clinic.history.line.tree</field>
+            <field name="model">clinic.history.line</field>
+            <field name="arch" type="xml">
+                <tree string="Lista de Pedidos" editable="bottom">
+                    <field name="description" required="1"/>
+                    <field name="brand" string="Cantidad" required="1"/>
+                    <field name="number" string="Logrado" required="1"/>
+                </tree>
+            </field>
+        </record>
+
+        <!-- search view -->
+
+        <record id="search_clinic_history_line_sis" model="ir.ui.view">
+            <field name="name">clinic.history.line.search</field>
+            <field name="model">clinic.history.line</field>
+            <field name="arch" type="xml">
+                <search string="Línea de servicios realizados">
+                    <field name="description"/>
+                    <field name="quantity"/>
+                    <newline />
+                    <group expand="0" string="Agrupado por...">
+                    </group>
+                </search>
+            </field>
+        </record>
+
+        <record id="form_clinic_history_line_sis" model="ir.ui.view">
+            <field name="name">clinic.history.line.form</field>
+            <field name="model">clinic.history.line</field>
+            <field name="arch" type="xml">
+                <form string="Línea de servicios realizados">
+                    <sheet>
+                        <group>
+                            <field name="description" required="1"/>
+                            <field name="brand" required="1"/>
+                            <field name="number" required="1"/>
+                        </group>
+                    </sheet>
+                </form>
+            </field>
+        </record>
+
+        <record id="action_clinic_history_line_sis" model="ir.actions.act_window">
+            <field name="name">Línea de servicios realizados</field>
+            <field name="type">ir.actions.act_window</field>
+            <field name="res_model">clinic.history.line</field>
+            <field name="view_type">form</field>
+            <field name="view_mode">tree,form</field>
+            <field name="search_view_id" ref="search_clinic_history_line_sis"/>
+        </record>
+
+        <!-- <record id="tree_clinic_history_consumed_sis" model="ir.ui.view">
+            <field name="name">clinic.history.consumed.sis.tree</field>
+            <field name="model">clinic.history.consumed</field>
+            <field name="arch" type="xml">
+                <tree string="Productos consumidos" editable="bottom">
+                    <field name="product_id"/>
+                    <field name="description"/>
+                    <field name="quantity"/>
+                    <field name="price_unit"/>
+                    <field name="subtotal"/>
+                    <field name="type"/>
+                </tree>
+            </field>
+        </record>
+
+        <record id="search_clinic_history_consumed_sis" model="ir.ui.view">
+            <field name="name">clinic.history.consumed.search</field>
+            <field name="model">clinic.history.consumed</field>
+            <field name="arch" type="xml">
+                <search string="Productos y servicios consumidos">
+                    <field name="type"/>
+                    <field name="product_id"/>
+                    <field name="description"/>
+                    <field name="quantity"/>
+                    <field name="price_unit"/>
+                    <field name="subtotal"/>
+                    <newline />
+                    <group expand="0" string="Agrupado por...">
+                        <filter string="Nombre" domain="[]" context="{'group_by':'type'}" />
+                    </group>
+                </search>
+            </field>
+        </record>
+
+        <record id="form_clinic_history_consumed_sis" model="ir.ui.view">
+            <field name="name">clinic.history.consumed.form</field>
+            <field name="model">clinic.history.consumed</field>
+            <field name="arch" type="xml">
+                <form string="Productos y servicios consumidos">
+                    <sheet>
+                        <group>
+                            <field name="product_id"/>
+                            <field name="type"/>
+                            <field name="description"/>
+                            <field name="quantity"/>
+                            <field name="price_unit"/>
+                            <field name="subtotal"/>
+                        </group>
+                    </sheet>
+                </form>
+            </field>
+        </record>
+
+        <record id="action_clinic_history_consumed_sis" model="ir.actions.act_window">
+            <field name="name">Productos y servicios consumidos</field>
+            <field name="type">ir.actions.act_window</field>
+            <field name="res_model">clinic.history.consumed</field>
+            <field name="view_type">form</field>
+            <field name="view_mode">tree,form</field>
+            <field name="search_view_id" ref="search_clinic_history_consumed_sis"/>
+        </record> -->
+
+        <menuitem id="clinic_history_sis" parent="base.menu_sales" action="action_clinic_history_sis" name="Orden de historia visita clínica" sequence="20"/>
+
+    </data>
+</openerp>