Monday, December 30, 2019

design workflow in odoo

      In this step we will design work flow for clinic booking process as we had explain in the previous step so to make it we have to 
  • create new object by name ('clinic.booking') as bellow with workflow functions 
# -*- coding: utf-8 -*-
from odoo import api, fields, models, _
from odoo.exceptions import ValidationError

class ClinicBooking(models.Model):
    ###############################
    #Class for Booking data
    ###############################
    _name = 'clinic.booking'
    _description = "object contain all doctor data"

    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')


    @api.one
    def action_to_wait_d_meeting(self):
        """
        function to be sure that the paient had registered to meet doctor
        """
        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.state = 'stay_on_ward'

    @api.one
    def medical_bill_action(self):
        """
        function will call if the doctor give the patient a medical bill
        """
        self.state = 'medical_bill'
  • create view for this object as bellow 
<?xml version="1.0" encoding="utf-8"?>
<odoo>
    <data>

        <!-- """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>
                    </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="state"/>
                </tree>
            </field>
        </record>

        <!-- """Create Action View""" -->

        <record id="clinic_booking_action_view" model="ir.actions.act_window">
            <field name="name">Booking</field>
            <field name="res_model">clinic.booking</field>
            <field name="view_type">form</field>
            <field name="view_mode">tree,form</field>
            <field name="view_id" ref="clinic_booking_tree_view"/>
        </record>

        <!-- """Create the Booking Root menu """ -->

        <menuitem id="clinic_booking_root_menu"
            name="Booking" sequence="1"
        />

        <!-- """Create the Booking Mani menu""" -->

        <menuitem
            name="Booking"
            parent="clinic_booking_root_menu"
            action="clinic_booking_action_view"
            id="clinic_booking_action_menu"
            sequence="2"
        />

    </data>
</odoo>
 


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...