Thursday, July 11, 2019

demo data in odoo

ODOO
 

demo data here means that records which will insert automatically will we install the module , and in order to do that we have to go to our module then add new folder by name"data" _ as standard _ then inside data add new xml file in which we will add our demo data record by record , so let me give an example 

let us say we have object with name student.py which is contain data about the student "name , age , phone , email"

from openerp import models, fields, api, _

class Student(models.Model):
    _name = 'student'

    """
        contain all student data
    """
    name = fields.Char('Name', required=True)
    age = fields.Integer('Age', required=True)
    phone = fields.Integer('Phone', required=True)
    email = fields.Char('Email', required=True)

then we will create the demo data file by name student_demo.xml as

<?xml version="1.0" encoding="utf-8"?>
<odoo>
    <data noupdate="1">
   
        <!-- Student Demo Data -->
        <record id="student_1" model="student.py">
            <field name="name">A</field>
            <field name="age">15</field>
            <field name="phone">123456</field>
            <field name="email">A@mail.com</field>
        </record>

        <record id="student_1" model="student.py">
            <field name="name">B</field>
            <field name="age">15</field>
            <field name="phone">123457</field>
            <field name="email">B@mail.com</field>
        </record>

        <record id="student_1" model="student.py">
            <field name="name">C</field>
            <field name="age">15</field>
            <field name="phone">123458</field>
            <field name="email">C@mail.com</field>
        </record>

     </data>
</odoo> 


now we create the student "A,B,C" and the will be insert automatically when we install our module

deference between ./odoo-bin and python odoo-bin

ODOO

 

 
before answer this question let me define the pyc file 
  • pyc file is the a file which contain the compiled code of py file and it will usually created in the same directory of the py file 
     so we we use python odoo-bin that will call python first and it will run the server but may be make some unclear errors and can't check out if all necessary packages are installed in your system or not  

     on the other hand when we use ./odoo-bin that with directly call the pyc file which will contain the compiled file so it will check all necessary before sun the server , so it's better than the other way

install all odoo packages

ODOO

to install all packages needed for odoo 11 you have to 
  • open your terminal a
  • write the command bellow

pip3 install Babel decorator docutils ebaysdk feedparser gevent greenlet html2text Jinja2 lxml Mako MarkupSafe mock num2words ofxparse passlib Pillow psutil psycogreen psycopg2 pydot pyparsing PyPDF2 pyserial python-dateutil python-openid pytz pyusb PyYAML qrcode reportlab requests six suds-jurko vatnumber vobject Werkzeug XlsxWriter xlwt xlrd

if it's not work that means you have problem with pip3 in your system but don't worry and try 

sudo python3 -m pip install Babel decorator docutils ebaysdk feedparser gevent greenlet html2text Jinja2 lxml Mako MarkupSafe mock num2words ofxparse passlib Pillow psutil psycogreen psycopg2 pydot pyparsing PyPDF2 pyserial python-dateutil python-openid pytz pyusb PyYAML qrcode reportlab requests six suds-jurko vatnumber vobject Werkzeug XlsxWriter xlwt xlrd

ImportError: No module named 'PyPDF2'

ODOO

configurations

PyPDF2

 

"ImportError: No module named 'PyPDF2' "
this error means that PyPDF2 package is not installed in your system so you have to install it first , in order to install it go to your terminal and write 
  • sudo apt-get install python-PyPDF2
if it's not work then you have to install it by using pip , by write 
  • pip3 install PyPDF2
if it's not work then try 
  • python3 -m pip install PyPDF2
or 
  • sudo python3 -m pip install PyPDF2
>>>Hope this useful :)

Wednesday, July 10, 2019

create scheduler in odoo

ODOO

Before showing how to create auto action or scheduler in odoo let me give a Definition of what is the scheduler 

scheduler is a function called automatically by the system it self 



I think now you can guess the way of creating scheduler , yes it's by two steps 
  • create my function which can make the job I need , if it called 
  • create the way which make the system call that function automatically by time 
Now let me give an example of creating scheduler 
  • create function 
      @api.one
      def get_
even_numbers(self): 

       """ this function return the even numbers between 0 - 11 """
        
            even_list = [2,4,6,8,10]
            return even_list

  • create auto action
      <?xml version="1.0" encoding="utf-8"?>
      <openerp>
            <data noupdate="1">
                   <record id="ir_cron_scheduler_demo_action" model="ir.cron">
                          <field name="name">Even Number Scheduler</field>
                          <field name="user_id" ref="base.user_root"/>
                          <field name="interval_number">15</field>
                          <field name="interval_type">days</field>
                          <field name="numbercall">-1</field>
                          <field eval="False" name="doall"/>
                          <field eval="'even_number.scheduler'" name="model"/>
                          <field eval="'
get_even_numbers'" name="function"/>
                  </record>
           </data>
     </openerp> 

Now let me explain what that means 
  • first I create python file which contain get_even_numbers function which make what I wanna do 
  • create xml file that call my method every 15 days 

<record id="ir_cron_scheduler_demo_action" model="ir.cron"> // here I make id for my scheduler record 

<field name="user_id" ref="base.user_root"/> // define the user

<field name="interval_number">15</field> //  define number of time units that I wanna call me function after it 

<field name="interval_type">days</field> // define the time unit

<field name="numbercall">-1</field> // counter for number of calls and I set it for -1 to call my function for ever 

<field eval="False" name="doall"/> // set false value for doall

<field eval="'even_number.scheduler'" name="model"/> //  here I refers to my python file which contain my function 

<field eval="'get_even_numbers'" name="function"/> // here I put the function which I wanna call by the scheduler

ImportError: No module named pandas

ODOO

configurations

pandas

 

this error happen because pandas module isn't installed in your system so you have to install it , so you go to the terminal and write :

  pip install pandas

if it isn't work and you get message tell you that "pip not installed  or not found" so you have to install pip first by writing 

sudo apt-get install python-pip

and then try to install pandas , by you had already installed pip but the pandas installation command isn't work then you can try 

sudo apt-get install python-pandas 

 >>> hope this help :)

create new module in odoo

ODOO 

 

to create new module in odoo you have to follow these steps
  • create new folder "better with your module name" in your addons path , this folder will contain your module's files and folders
  • inside the folder you have to create two main files 
  1. the __init__.py file in which you have to import all of your module's python file , or the folder that contain python files 
  2. the __manifest__.py which is goona be like this 
         {
            'name': 'your module name',
            'version': 'the server version which can run your module',
            'license': 'LGPL-3', // your license
            'category': 'Education', // your module category
            "sequence": 3,
            'summary': 'short description for your module ',
            'complexity': "easy",
            'author': 'Tech Receptives', // the developer of the module
            'website': ' your web site  if you have ',
            'depends': [the other modules which are necessary for your module's  work],
            'data': [
                 import all of module's xml files by their path
            ],
            'demo': [
                 import all of module's xml files by their path which are contain 
                   your demo data
            ],
            'images': [
              import your module's icon
            ],
              'installable': True, // is you module installable or not
              'auto_install': False, // do you want to install your module auto or not
              'application': True, // is you module an app or not
         }
this image show the standard architecture of the module

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