Tuesday, June 16, 2020

Introduction To Java

JAVA

Computer & Programs :

Programing means to create a software which is contain the instructions that tell the computer or any other computerized device what to do , and this instructions called the program , so the program is a set of instructions that are telling the computer what to do , in order to do some tasks


         Computer is an electronic device that stores and processes data ,and it is consist of hardware and software

The hardware of the computer contain

A central processing unit (CPU) >> the computer’s brain and it’s contain of two main units ( the control unit which is coordinating the action , and the logic unit which is performs the numeric operations

Memory store the programs and its data

I/O devices

Communication devices , which are help the computer to networking and communicated with the other computers and computerized devices

Storage devices

The software which are the programs and software that are stored in the computer



Programing languages :

         The computer can’t understand the human language , so to make the human communicate with the computer they must use some language that the computer can understand

Machine Language : is the computer language that its instructions written in binary code just as 01101100

Assembly Language : Assembly language uses a short descriptive word, known as a mnemonic, to represent each of the machine-language instructions

Assembler : is a program that used to translate assembly-language program into machine code




Assembly Language known as low level programming language because it’s close in the nature to machine language & is machine dependent

High level programing languages

Start at 1950s

Platform dependent which means you can write your program and run it in different types of machines

Just as English text

EG : area =9*9*3.14159



High level programing language as

Java
++C
#C
python
C
Cobol
Pascal
Basic

Introduction to java

Java is a powerful and versatile programming language for developing software running on mobile devices, desktop computers, and servers.

developed by a team led by James Gosling in 1991 at Sun Microsystems. Sun Microsystems was purchased by Oracle in 2010 , was called Oak , and renamed to java at 1995

Java is a full-featured, general-purpose programming language

Java initially became attractive because Java programs can be run from a Web browser applets

The application program interface (API), also known as library, contains predefined classes and interfaces for developing Java programs ,and it’s still expanded

Java Development Toolkit is called JDK , set of separate programs, each invoked from a command line, for developing and testing Java programs

Instead of using the JDK, you can use a Java development tool (e.g., NetBeans, Eclipse, and TextPad) software that provides an integrated development environment (IDE) for developing Java programs quickly


to download textpad :

https://www.textpad.com/download/

to download JDK :

https://www.oracle.com/java/technologies/javase-jdk8-downloads.html

 

watch on YouTube


 

NEXT STEP

Saturday, April 25, 2020

orm methods in odoo

ODOO

ORM

 
ORM Methods in odoo :
  • ORM is stands for Object Relational Mapping 
  • Used to convert data between incompatible type system
  • Odoo modeling is based on "objects" but it's data is stored in a classical relational database 

žsearch()

 
           Use to search for records in object
ž           Input > search domain
ž           Output > list of ids
ž           Employee_ids = self.env[‘hr.employee’].search([‘age’,’=‘,65])

browse()  



žUse to get record set
žInput > list of ids
žOutput > record set
žfaculty =  self.pool.get('op.faculty').browse(self.cr, self.uid, faculty_id)

 create()


ž           Used to create new records in object
ž           Input > field’s values
ž           Output > create new reord in object
ž           Employee_id = self.env[‘hr.employee’]
ž           Employee_ids.create({‘name’:Juhn,’age’:28,’gender’:’male’})

write()


ž          Used to write our update values of records
ž          Input > field’s values
ž          Output > write these values to all records in it’s record set
ž          Employee_id = self.env[‘hr.employee’].search([(‘id’,’=’,1)])
ž          Employee_ids.write({‘name’:’mark’,’age’:38})
            Write () with relational fields
            0, 0, { values }) link to a new record that needs to be created with the given values dictionary
ž(1, ID, { values }) update the linked record with id = ID (write values on it)
ž(2, ID) remove and delete the linked record with id = ID
ž(3, ID) cut the link to the linked record with id = ID
ž(4, ID) link to existing record with id = ID (adds a relationship)
ž(5) unlink all (like using (3,ID) for all linked records)
ž(6, 0, [IDs]) replace the list of linked IDs
  

exists()


žReturns a new recordset containing only the records which exist in the database
žif not record.exists(): raise Exception("The record has been deleted")

ensure_one ()

           checks that the recordset is a singleton
self.ensure_one()

PREVIOUS STEP                    NEXT STEP

Tuesday, January 28, 2020

design report in odoo

ODOO

reports

 
In this step we will show how to design report bellow 


You can design this report by adding the template bellow 

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

        <!-- ...Define Template... -->

        <template id="booking_custom_report_temp">
            <t t-call="web.html_container">
                <t t-call="web.external_layout">
                    <div class="page">
                        <header>
                            <div style="float:left;border-bottom: 2px solid black;border-color:#1f7b91 ! important;width:70%;">
                                <b style="font-size:32px;color:#1f7b91 ! important;">
                                    Shilal Software Company
                                </b>
                                <br></br>
                                <b style="font-size:22px;color:#1f7b91 !important;">
                                    Clinic Managment System
                                </b>
                            </div>
                            <div style="float:right;">
                                <!-- <img src=\"/logo.png?company=${company.id}\"/> -->
                                <img src="/clinic/static/img/shilal.png" style="width:160px;height:100px;"/>
                            </div>
                        </header>
                        <br></br><br></br><br></br><br></br><br></br><br></br><br></br>
                        <div>
                            <center>
                                <u>
                                    <b style="font-size:20px;">
                                        Clinic Booking Report
                                    </b>
                                </u>
                            </center>
                        </div>
                        <br></br><br></br>
                        <div style="width:50%;float:left;font-size:14;">
                            <t t-if="doctor_id != 'no'">
                                <b>
                                    Doctor :
                                </b>
                                <span t-esc="doctor_id" />
                                <br></br>
                            </t>
                            <t t-if="patient_id != 'no'">
                                <b>
                                    Patient :
                                </b>
                                <span t-esc="patient_id" />
                                <br></br>
                            </t>
                            <t t-if="meeting_date != 'no'">
                                <b>
                                    Meeting Date :
                                </b>
                                <span t-esc="meeting_date" />
                                <br></br>
                            </t>
                            <br></br>
                        </div>
                        <div style="width:50%;float:right;font-size:14;">
                            <t t-if="date != 'no'">
                                <b>
                                    Date :
                                </b>
                                <span t-esc="date" />
                                <br></br>
                            </t>
                            <t t-if="state != 'no'">
                                <b>
                                    State :
                                </b>
                                <span t-esc="state" />
                                <br></br>
                            </t>
                        </div>
                        <table style="width:100%;">
                            <tr style="font-size:18px; border: 2px solid black;text-align: center;background-color:#d6d6c2 !important;">
                                <td style="font-size:14px; border: 2px solid black;padding-top:5px;padding-bottom:5px;">
                                    <b>
                                        Doctor
                                    </b>
                                </td>
                                <td style="font-size:14px; border: 2px solid black;padding-top:5px;padding-bottom:5px;">
                                    <b>
                                        Paient
                                    </b>
                                </td>
                                <td style="font-size:14px; border: 2px solid black;padding-top:5px;padding-bottom:5px;">
                                    <b>
                                        Booking Date
                                    </b>
                                </td>
                                <td style="font-size:14px; border: 2px solid black;padding-top:5px;padding-bottom:5px;">
                                    <b>
                                        Meeting Date
                                    </b>
                                </td>
                                <td style="font-size:14px; border: 2px solid black;padding-top:5px;padding-bottom:5px;">
                                    <b>
                                        State
                                    </b>
                                </td>
                            </tr>
                            <t t-foreach="data" t-as="object_line">
                                <tr style="font-size:18px; border: 2px solid black;text-align: center;">
                                    <td style="font-size:14px; border: 2px solid black;padding-top:5px;padding-bottom:5px;">
                                        <n>
                                            <span t-esc="object_line.doctor_id.name" />
                                        </n>
                                    </td>
                                    <td style="font-size:14px; border: 2px solid black;padding-top:5px;padding-bottom:5px;">
                                        <n>
                                            <span t-esc="object_line.patient_id.name" />
                                        </n>
                                    </td>
                                    <td style="font-size:14px; border: 2px solid black;padding-top:5px;padding-bottom:5px;">
                                        <n>
                                            <span t-esc="object_line.date" />
                                        </n>
                                    </td>
                                    <td style="font-size:14px; border: 2px solid black;padding-top:5px;padding-bottom:5px;">
                                        <n>
                                            <span t-esc="object_line.meeting_date" />
                                        </n>
                                    </td>
                                    <td style="font-size:14px; border: 2px solid black;padding-top:5px;padding-bottom:5px;">
                                        <n>
                                            <span t-esc="object_line.state" />
                                        </n>
                                    </td>
                                </tr>
                            </t>
                        </table>
                        <br></br><br></br>
                        <div>
                            <b style="font-size:14px;width:50%;float:left;">
                                Print By : <span t-esc="request.env.user.partner_id.name" />
                                <br></br>
                                Signiture : _____________________________
                            </b>
                        </div>
                        <div>
                            <b style="font-size:14px;width:50%;float:right;">
                                Print On : <span t-esc="context_timestamp(datetime.datetime.now()).strftime('%A %d-%B-%Y')"/>
                            </b>
                        </div>
                    </div>
                </t>
            </t>
        </template>

        <!-- """create report """ -->

        <report
            id="booking_custom_report_action"
            string="Booking Report"
            model="clinic.booking"
            report_type="qweb-pdf"
            name="clinic.booking_custom_report_temp"
            menu="False"
        />
         <record id="paperformat_euro_no_margin" model="report.paperformat">
            <field name="name">European A5</field>
            <field name="default" eval="True" />
            <field name="format">A4</field>
            <field name="page_height">0</field>
            <field name="page_width">0</field>
            <field name="orientation">Portrait</field>
            <field name="margin_top">5</field>
            <field name="margin_bottom">5</field>
            <field name="margin_left">7</field>
            <field name="margin_right">7</field>
            <field name="header_line" eval="False" />
            <field name="header_spacing">0</field>
            <field name="dpi">90</field>
        </record>

</odoo>



PREVIOUS STEP            NEXT STEP

Saturday, January 18, 2020

report in odoo

ODOO

 

  
 In this step we will design report for clinic.booking object by wizard so
  • first we have to create wizard in which the user will inter important data to print the report he want as bellow
# -*- coding: utf-8 -*-
##############################################################

from odoo import fields, models, api, _
import time
from datetime import date
from odoo.exceptions import ValidationError ,UserError

class ClinicBookingWiz(models.TransientModel):
    _name = "clinic.booking.report.wiz"

    state = fields.Selection([('draft','Draft'),('wait_d_meeting','Wait Doctor Meeting'),('stay_on_ward','Stay On Ward'),('medical_bill','Medical Bill')], string='State')
    patient_id = fields.Many2one('clinic.patient', string='Patient')
    doctor_id = fields.Many2one('clinic.doctor', string='Doctor')
    date = fields.Date(string="Date")
    meeting_date = fields.Date(string="Meeting Date")

    @api.multi
    def print_booking_report(self):
        """
        This Function Get The Data For Booking Reports
        """
        booking_ids = self.env['clinic.booking'].search([])
        data = {}
        booking_list = []

        if self.state:
            for rec in booking_ids:
                if rec.state == self.state:
                    booking_list.append(rec.id)
            booking_ids = booking_ids.search([('id','in',booking_list)])
            booking_list = []

        if self.patient_id:
            for rec in booking_ids:
                if rec.patient_id == self.patient_id:
                    booking_list.append(rec.id)
            booking_ids = booking_ids.search([('id','in',booking_list)])
            booking_list = []  

        if self.doctor_id:
            for rec in booking_ids:
                if rec.doctor_id == self.doctor_id:
                    booking_list.append(rec.id)
            booking_ids = booking_ids.search([('id','in',booking_list)])
            booking_list = []

        if self.date:
            for rec in booking_ids:
                self_date = str(self.date)
                rec_date = str(rec.date)
                if self_date == rec_date:
                    booking_list.append(rec.id)
            booking_ids = booking_ids.search([('id','in',booking_list)])
            booking_list = []

        if self.meeting_date:
            for rec in booking_ids:
                self_meeting_date = str(self.meeting_date)
                rec_meeting_date = str(rec.meeting_date)
                if self_meeting_date == rec_meeting_date:
                    booking_list.append(rec.id)
            booking_ids = booking_ids.search([('id','in',booking_list)])
            booking_list = []

        for rec in booking_ids:
            booking_list.append(rec.id)
        data = {'booking_ids':booking_list}
        return self.env.ref('clinic.booking_custom_report_action').report_action(self, data=data)


class ClinicBookingReportDetails(models.AbstractModel):
    _name = "report.clinic.booking_custom_report_temp"

    @api.model
    def get_report_values(self, docids, data=None):
        booking_ids = self.env['clinic.booking'].search([('id','=',data['booking_ids'])])
        docids = docids
        # self.get_menus_skel(docids, data)
      
        return {
            'data': booking_ids
            }
  • then we have to 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>
                        <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>

        <!-- """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>

  • last thing we have to create report template file as bellow
<?xml version="1.0" encoding="utf-8" ?>
<odoo>

        <!-- ...Define Template... -->

        <template id="booking_custom_report_temp">
            <t t-call="web.html_container">
                <t t-call="web.external_layout">
                    <div class="page">
                        <table style="width:100%;">
                            <tr style="font-size:18px; border: 2px solid black;text-align: center;">
                                <td style="font-size:14px; border: 2px solid black;padding-top:5px;padding-bottom:5px;">
                                    <b>
                                        Doctor
                                    </b>
                                </td>
                                <td style="font-size:14px; border: 2px solid black;padding-top:5px;padding-bottom:5px;">
                                    <b>
                                        Paient
                                    </b>
                                </td>
                                <td style="font-size:14px; border: 2px solid black;padding-top:5px;padding-bottom:5px;">
                                    <b>
                                        Booking Date
                                    </b>
                                </td>
                                <td style="font-size:14px; border: 2px solid black;padding-top:5px;padding-bottom:5px;">
                                    <b>
                                        Meeting Date
                                    </b>
                                </td>
                                <td style="font-size:14px; border: 2px solid black;padding-top:5px;padding-bottom:5px;">
                                    <b>
                                        State
                                    </b>
                                </td>
                            </tr>
                            <t t-foreach="data" t-as="object_line">
                                <tr style="font-size:18px; border: 2px solid black;text-align: center;">
                                    <td style="font-size:14px; border: 2px solid black;padding-top:5px;padding-bottom:5px;">
                                        <n>
                                            <span t-esc="object_line.doctor_id.name" />
                                        </n>
                                    </td>
                                    <td style="font-size:14px; border: 2px solid black;padding-top:5px;padding-bottom:5px;">
                                        <n>
                                            <span t-esc="object_line.patient_id.name" />
                                        </n>
                                    </td>
                                    <td style="font-size:14px; border: 2px solid black;padding-top:5px;padding-bottom:5px;">
                                        <n>
                                            <span t-esc="object_line.date" />
                                        </n>
                                    </td>
                                    <td style="font-size:14px; border: 2px solid black;padding-top:5px;padding-bottom:5px;">
                                        <n>
                                            <span t-esc="object_line.meeting_date" />
                                        </n>
                                    </td>
                                    <td style="font-size:14px; border: 2px solid black;padding-top:5px;padding-bottom:5px;">
                                        <n>
                                            <span t-esc="object_line.state" />
                                        </n>
                                    </td>
                                </tr>
                            </t>
                        </table>
                    </div>
                </t>
            </t>
        </template>

        <!-- """create report """ -->

        <report
            id="booking_custom_report_action"
            string="Booking Report"
            model="clinic.booking"
            report_type="qweb-pdf"
            name="clinic.booking_custom_report_temp"
            menu="True"
        />
         <record id="paperformat_euro_no_margin" model="report.paperformat">
            <field name="name">European A4</field>
            <field name="default" eval="True" />
            <field name="format">A4</field>
            <field name="page_height">0</field>
            <field name="page_width">0</field>
            <field name="orientation">Portrait</field>
            <field name="margin_top">40</field>
            <field name="margin_bottom">28</field>
            <field name="margin_left">7</field>
            <field name="margin_right">7</field>
            <field name="header_line" eval="False" />
            <field name="header_spacing">0</field>
            <field name="dpi">90</field>
        </record>

</odoo>

Watch On YouTube



PREVIOUS STEP            NEXT STEP

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