Thursday, January 2, 2020

workflow in odoo

ODOO

 

Workflow 


 
In this step we will continue with clinic booking work flow , so we will

  • add booking data for ‘clinic.booking’ object as bellow

state = fields.Selection([('draft','Draft'),('wait_d_meeting','Wait Doctor Meeting'),('stay_on_ward','Stay On Ward'),('medical_bill','Medical Bill')], string='State', default='draft')

patient_id = fields.Many2one('clinic.patient', string='Patient', required=True)

doctor_id = fields.Many2one('clinic.doctor', string='Doctor', required=True)

date = fields.Date(string="Date", default=fields.date.today())

meeting_date = fields.Date(string="Meeting Date", required=True)

paid_fees = fields.Boolean(string="Paid Fees")

note = fields.Html(string="Note")

  • create clinic booking views as bellow
<!-- """Create Form View""" -->

        <record id="clinic_booking_form_view" model="ir.ui.view">
            <field name="name">clinic.booking.form</field>
            <field name="model">clinic.booking</field>
            <field name="arch" type="xml">
                <form string="Doctor">
                    <header>
                        <button name="action_to_wait_d_meeting" states="draft" string="Confirm" type="object" class="oe_highlight" style="margin-left:2px;"/>
                        <button name="clinic_ward_action" states="wait_d_meeting" string="Stay On Ward" type="object" class="oe_highlight" style="margin-left:2px;"/>
                        <button name="medical_bill_action" states="wait_d_meeting" string="Medical Bill" type="object" class="oe_highlight" style="margin-left:2px;"/>
                        <field name="state" widget="statusbar" readonly="1"/>
                    </header>
                    <sheet>
                        <group colspan="4" col="4">
                            <field name="patient_id" />
                            <field name="doctor_id" />
                            <field name="date" />
                            <field name="meeting_date" />
                            <field name="paid_fees" />
                        </group>
                        <group colspan="4" col="4" string="Note">
                            <field name="note" nolabel="1"/>
                        </group>
                    </sheet>
                </form>
            </field>
        </record>

        <!-- """Create Tree View""" -->

        <record id="clinic_booking_tree_view" model="ir.ui.view">
            <field name="name">clinic.booking.tree</field>
            <field name="model">clinic.booking</field>
            <field name="arch" type="xml">
                <tree string="doctors">
                    <field name="patient_id" />
                    <field name="doctor_id" />
                    <field name="date" />
                    <field name="meeting_date" />
                    <field name="paid_fees" />
                    <field name="state"/>
                </tree>
            </field>
        </record>



  • edit work flow function as bellow

@api.one

def action_to_wait_d_meeting(self):

"""

function to be sure that the paient had registered to meet doctor

"""

if self.paid_fees == False:

raise ValidationError(_("The Patient did not paid fees yet !"))

self.state = 'wait_d_meeting'





@api.one

def clinic_ward_action(self):

"""

function will call if the doctor decied that the patient must stay for sometime in clinin's ward

"""

self.patient_id.write({'met_doctor': True})

self.patient_id.write({'last_meeting': self.meeting_date})

self.state = 'stay_on_ward'



@api.one

def medical_bill_action(self):

"""

function will call if the doctor give the patient a medical bill

"""

self.patient_id.write({'met_doctor': True})

self.patient_id.write({'last_meeting': self.meeting_date})

self.state = 'medical_bill'

Watch On YouTube



 PREVIOUS STEP              NEXT STEP

No comments:

Post a Comment

Odoo Invoice Qr code issues

There are two main issues must of us facing with the QR code in Odoo invoice & these issues are 1/ QR code displayed as broken image w...