Saturday, December 7, 2019

object with simple view in odoo

ODOO

 

views

 

On this step we will create object with simple view
    As we decided we are going to design clinic erp system as today we will start to create patient model so as we know in our module structure we create models folder which is contain python files , also we will create views folder which will contain xml files so let us start …
First : create patient object in python file by name “clinic_patient.py” inside models folder which we must create inside our module just as bellow …

# -*- coding: utf-8 -*-
from odoo import api, fields, models, _

class ClinicPatient(models.Model):
    _name = 'clinic.patient'
    _description = "object contain all patient data"

    first_name = fields.Char(string='First Name', required=True)
    second_name = fields.Char(string='Second Name', required=True)
    third_name = fields.Char(string='Third Name', required=True)
    forth_name = fields.Char(string='Fourth Name', required=True)


   Now we created new object with name "clinic.patient" which will create new table in the database by name "clinic_patient" which is also contain four fields (names) , then we must create view file for this model by name “clinic_patient_view.xml” inside views folder which we create inside our module as bellow …
 First : create new file inside view folder and save it by name "
clinic_patient_view.xml"
second : open it and and edit it as bellow ...

 <?xml version="1.0" encoding="utf-8"?>
<odoo>
    <data>

        <!-- """Create Form View""" -->

        <record id="clinic_patient_form_view" model="ir.ui.view">
            <field name="name">clinic.patient.form</field>
            <field name="model">clinic.patient</field>
            <field name="arch" type="xml">
                <form string="Patient">
                    <sheet>
                        <table style="width:100%;">
                            <tr style="width:100%;">
                                <td style="width:20%;">
                                    <b style="font-size:13px;">
                                        Name
                                    </b>
                                </td>
                                <td style="width:20%;font-size:13px;">
                                    <field name="first_name" placeholder="First Name"/>
                                </td>
                                <td style="width:20%;font-size:13px;">
                                    <field name="second_name" placeholder="Second Name"/>
                                </td>
                                <td style="width:20%;font-size:13px;">
                                    <field name="third_name" placeholder="Third Name"/>
                                </td>
                                <td style="width:20%;font-size:13px;">
                                    <field name="forth_name" placeholder="Fourth Name"/>
                                </td>
                            </tr>
                        </table>
                    </sheet>
                </form>
            </field>
        </record>

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

        <record id="clinic_patient_tree_view" model="ir.ui.view">
            <field name="name">clinic.patient.tree</field>
            <field name="model">clinic.patient</field>
            <field name="arch" type="xml">
                <tree string="Patients">
                    <field name="first_name"/>
                    <field name="second_name"/>
                    <field name="third_name"/>
                    <field name="forth_name"/>
                </tree>
            </field>
        </record>

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

        <record id="clinic_patient_action_view" model="ir.actions.act_window">
            <field name="name">Patients</field>
            <field name="res_model">clinic.patient</field>
            <field name="view_type">form</field>
            <field name="view_mode">tree,form</field>
            <field name="view_id" ref="clinic_patient_tree_view"/>
        </record>


        <!-- """Create the root menu """ -->

        <menuitem id="clinic_root_menu"
            name="Clinic Patient"
            sequence="1"
        />

        <!-- """Create the Configration menu """ -->

        <menuitem id="clinic_patient_main_menu"
            name="Patients" sequence="2"
            parent="clinic_root_menu"
        />

        <!-- """Create the Company's Projects menu""" -->

        <menuitem
            name="Patients"
            parent="clinic_patient_main_menu"
            action="clinic_patient_action_view"
            id="patients_action_menu"
            sequence="5"
        />

    </data>
</odoo> 

 Whatch On YouTube 


 
  PREVIOUS STEP         NEXT STEP

2 comments:

  1. Thanks for sharing such a amazing information i hope you keep on sharing such kind of useful information daily......

    Odoo
    Odoo as an Ubuntu Service
    Odoo 14
    Odoo Installation ubuntu
    Ubuntu 18.04



    ReplyDelete

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