Wednesday, December 4, 2019

View types in odoo

ODOO

 

Views



In this step we will explain
  • View types in odoo
  • How to create your first python class (python class structure)


View types :
 
Form view : show editable form for your object just like in the image bellow

List view (tree view) : show existing records for your models in the database as list with some fields , just like bellow

Kanban view : show existing records in card view just like in the image bellow 
 
Calendar view : view to display and edit information about dates and durations in your records in a visual way
 
Graph view : show your data in graph views as bar chart, line chart and pie chart
Pivot view : show your data in dynamic views
Search view : design search view with some attributes like (group by ,filters …) to make search more easy for the user 

Now how to create your first python class ?

We can define the class (object) structure as bellow
Import packages : here we will import all packages that we will use
Class class_name.. : here we define our class (class name and type)
Class attributes : here we define the attributes for the class
Class attributes :
_name = ‘the object name’ … eg : _name = ‘clinic.patient’
_description = ‘object description’
_order = ‘field_name’ … to order the records by this field
_rec_name = ‘field_name’… to show record in relational fields by this field
_inherit = ‘object.object’ … write the inherited here


Class body : will define as
Fields

Constraints

Functions

Watch On YouTube 



PREVIOUS STEP          NEXT STEP

Module's standard structure in odoo

ODOO

odoo module

 

On this step we will explain :
  • Field’s attributes
  • Module's standard structure 
     
To see field’s attributes click here

Module’s standard structure is just as bellow 
 
 module
    __init__.py
    __manifest__.py
    >< controllers
    >< models
    >< data
    >< i18n
    >< views
    >< security
    >< demo
    >< static
    >< wizard
    >< report
    >< doc
    >< test
Now let us explain them one by one :
Controllers : contains the code files for the website controllers, for modules which are providing that kind of feature .

Models : contains the backend code files, creating the Models and their business logic (contain the python files which create models)

Data : contains other data files with module initial data 

I18n : is where Odoo will look for the translation (contain translation file for many languages)

Views : contains the XML files for the user interface, with the actions, forms, lists, and so on

Security : contains the data files defining access control lists (contain files which define permissions)

Demo : contains data files with demonstration data

Static : is where all web assets are expected to be placed (contain web assets files such as css, js … files)

Wizard : Wizards describe stateful interactive sessions with the user through dynamic forms (contain all wizard files)

Report : contain reports files
 
Doc : contain documentation files

Test : contain the test files which are python file have names start with test_ "eg: test_patient.py"

Watch on YouTube 




PREVIOUS STEP           NEXT STEP

Tuesday, December 3, 2019

create module in odoo

ODOO

odoo mdule

 

 In this step we will explain how to build simple empty module and the data types in odoo

how to start build your module

odoo module is afolder that contain two files , so to create new module me must start with the steps bellow 

    - create new folder with name "module_name"
    - inside it create file with name "__init__.py"
    - inside it create another file with name "__manifest__.py"
now create  __manifest__.py as bellow 
    # -*- coding: utf-8 -*-
{
    'name' : 'clinic
',
    'version' : '1.1',
    'summary': 'clinic
erp system',
    'sequence': 10,
    'description': """
        manage
patient data 
        doctors data
        Patient dormitory data
     """,
    'category': 'Health',
    'author': 'Shilal,
    'website': 'https://shilalg.blogspot.com',
    'images' : [],
    'depends' : [],
    'data': [
    ],
    'demo': [
    ],
    'installable': True,
    'active': True,
}

 
Now let us explain what that is mean  
first __manifest__ file is contain the data of the module so 
  'name' : 'clinic', is define the name for our module
  'version' : '1.1', the current version for this module , I use it when I have more than one version for my module 
 'summary': short description for your module
 'description': description for your module and the tasks that your module do  
 'category': the category that your module belong to 
 'author': the company or the engineer who build the module
 'website': EG  the web site of the company or the engineer who build the module 
 'images' : the image for your module
 'depends' : any other module that must be installed in the system to make your module work (other modules name)
 'data': here we call the xml files in which we made our views 

now we will create empty file by name __init__.py , then our module will be created then we can install it by following the steps bellow 
  • restart the Odoo server (be sure that you call the directory which contain your modules with the run command by editing the addons path just like we explain) 
  • go to your browser and login to your database 
  • then go to setting to activate the developer mode 
  • the go to apps menu and click on update app list menu (load your module )
  • the search for your module by it's name in apps view and install it 


Data types :
Numeric : on which we are storing numbers and it has two types
     Integer > on which we store integers
     Float > on which we can store numbers with decimal part
Textual : on which we can store text data, and it has three types
     Char : on which we can store string maximum 255 characters
     Text : on which we can store string and it view as text area with unlimited characters
     Html : on which we can store string but it view as text editor
Date : on which we can store date and it has two types
     Date : on this field we can enter the date only without the time (month, day ,year)
     Datetime : on this field we can enter date and time too(month , day ,year hours ,minutes , seconds)
Boolean : has one type by name Boolean which can has True or False vale only
Binary : has one type too my name Binary in which we can store binary date (docs , images , sounds , videos …)
Selection : it also has one type by name selection and in it the user will select one value from the values in this field
Relational Fields : on this type we store the relation between objects , and we have three types of relational fields
    One2many > just when we say there are one record in object A will has relations with many records in object B just like (in the table of doctors one doctor will take care of more than one patient)
    Many2one > the reverse of One2many
    Many2many > in this type many records in object A will has relation with many records in object B just like (more than one medication will be given for many patients)
Now what is the syntax to define fields ?
All fields have one syntax just as
Field_name = fields.datatype(field attributes)

Watch On YouTube 
 

PREVIOUS STEP             NEXT STEP

Tuesday, November 26, 2019

calculate age from birthdate in odoo

ODOO 



here we know the birth date of the user (birth_date) and we want to calculate his age so let's do it 
  • add the birth date field and age field in your model as 
birth_date = fields.Date(string="Birth Date")
age_year = fields.Float(string="Years", compute='calculate_age')
age_month = fields.Float(string="Months", compute='calculate_age') 
age_day = fields.Float(string="Days", compute='calculate_age')
 

  • the add calculate_age() function to calculate the age and store it in age field 
@api.one 
def calculate_age(self):
        """
        function to calcolate the age of he user

        """

        if self.birth_date :

            birth_date = str(self.birth_date)

            current_date = str(fields.Date.today())



            birth_date_year_as_int =     int(birth_date[0]+birth_date[1]+birth_date[2]+birth_date[3])

            birth_date_month_as_int = int(birth_date[5]+birth_date[6])

            birth_date_day_as_int = int(birth_date[8]+birth_date[9])



            current_date_year_as_int = int(current_date[0]+current_date[1]+current_date[2]+current_date[3])

            current_date_month_as_int = int(current_date[5]+current_date[6])

            current_date_day_as_int = int(current_date[8]+current_date[9])



            period_years = current_date_year_as_int-birth_date_year_as_int

            period_months = current_date_month_as_int-birth_date_month_as_int

            period_days = current_date_day_as_int-birth_date_day_as_int



            months_list_1 = ['04','06','09','11']

            months_list_2 = ['01','03','05','07','08','10','12']



            if period_days < 0:

                if str(current_date_month_as_int) == '02':

                    if current_date_year_as_int%4 == 0:

                        period_days = 29+period_days

                    if current_date_year_as_int%4 != 0:

                        period_days = 28+period_days

                for index in range(0,4):

                    if current_date_month_as_int == int(months_list_1[index]):

                        period_days = 30+period_days

                for index in range(0,7):

                    if current_date_month_as_int == int(months_list_2    [index]):

                        period_days = 31+period_days

                period_months = period_months-1

            if period_months < 0:

                period_months = 12+period_months

                period_years = period_years-1



            self.age_year = period_years

            self.age_month = period_months

            self.age_day = period_days

Monday, November 25, 2019

Run odoo server

ODOO

configurations

   
 In this step we will see how to run Odoo server , change add-ons path , change default odoo port , create new database from the browser and from pg admin too 

how to run odoo server ?
  -open your terminal and enter the odoo server folder by the command (in my pc the odoo server is in the desktop )

   cd Desktop/odoo11 

  -then we have to run the command bellow to run odoo server  
  
   ./odoo-bin 

now we run the server as in the image bellow 



how to change addons path and why ? 

    by default odoo is call the standard modules which are located in odoo server folder/addons so when we run the server by the command above we can only see and install the standard modules , by what about installing our own modules ?
    to do that we only have two ways :
  • create our modules and put theme with the standard modules in the same path (odoo sever/addons) , of course the way is so easy but it's not right so we will not use it 
  • create our modules and put them in one folder and then call this folder with the standard modules folder (addons) as bellow 
let us say that we created folder by name custom_addons which is located in the desktop so to call this folder we must run odoo server by the command bellow

     ./odoo-bin --addons-path=/home/student/Desktop/odoo-11.1.1/addons,Desktop/custom_addons

how to change the default port (8069) for odoo server ? 

     as we know the odoo server is run on 8069 as default port , but can we change this port ?
 of course we can change it by any port we want by adding --xmlrpc-port= to the command above to become as  

     ./odoo-bin --addons-path=/home/student/Desktop/odoo-11.1.1/addons,Desktop/custom_addons -- xmlrpc-port=8080 

* here we had change the default port to 8080  

how to create new data base from the browser ?

    after running the odoo server we have to open our browser and write down localhost:8069 in the url "in we run the server in the default port" and press enter to get the page as in the image bellow 


then we have to write the name email and the password for our database (and demo data if we want ) , "I will write database : test , email:admin , password:123 and I will not load demo data"

how to create new database from pg admin ?

    to create database from the pg admin you have to follow the steps bellow 
  1. open the pg admin
  2. connect the pg admin to odoo server
  3. over the databases menu right click and chose new database 
  4. write down the name of the data base and owner of it (postgres role) as in the image bellow   

Watch onYouTube



PREVIOUS STEP         NEXT STEP

introduction to technical odoo


ODOO

introduction

 

    Before start our lessons to explain how we can use odoo to build ERP system for our organizations we have to have to know
  • What is odoo ?  
      Odoo is stand for On-Demand Open Object , and it's open source , web base  ERP  framework , built with Python , designed for small and medium-size companies with many standard modules like (account , hr , crm , stock , sale , purchase ...) which can be customize as you want , and also you can create your own modules from scratch .
  • What is ERP ? 
      ERP is stand for Enterprise Resource Planning and it's type of software that is used by the organizations to manage their activities in all levels inside the organization 
  • What is Python ? 
      Python is object-oriented, high-level programming language with dynamic semantics (ref) 
Now to start technical odoo first you have to have some knowledge with 
  • Python (Necessary)
  • xml (Necessary)
  • html , css and js (As possible)
Now let us start by install Odoo in Ubuntu 

to install odoo 9 in ubuntu  

to install odoo 11 in ubuntu   

* we will work with odoo 11 


Watch on YouTube


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