Friday, 18 December 2015

Login in Odoo with Google Acoount

This article will help us to login In Odoo with Google account.

If you have Google Apps then you probably want to allow your Odoo users to login with their Google account. The good news is Odoo supports OAuth authentication which means it plays nicely with Google Apps.

However setting this up can be quite tricky. In this guide I’m going to step you through the process so you can get it working first time.


Note that Google Apps is different to standalone GMail. You must follow each of the steps below in sequence otherwise your authentication process will fail.

There are six main steps:
  1. Enable OAuth authentication support in Odoo
  2. Enable the Google App Engine Admin Console in your Google Apps domain
  3. Create Google Apps OAuth2 access for Odoo
  4. Add Google OAuth2 credentials to Odoo
  5. Create a new Odoo user with Google Apps authentication
  6. Activating Google Apps authentication for new user
Important: Make sure Odoo is correctly configured to send email before starting this. Odoo will need to email an activation link when you enable OAUTH.

So, let’s get started.

Please follow steps for more details

Monday, 23 November 2015

How to clone single branch from the GitHub?

Generally GitHub repository has multiple branch on it. But sometime we don't want to clone whole branch.

This command "git clone git://github/repository.git" will take all branches of its. But we want to only clone "Sub_Branch_2" branch.

For Example:

Main_Branch
        '
        ' - > Sub_Branch_1
       
        '
        ' - > Sub_Branch_2
       
        '
        ' - > Sub_Branch_3
 

This blog will help you for cloning single branch from GitHub.

First we need to check system git version using below command.

git --version

If git version is less than 1.8.x than we must to upgrade git version using below command.

sudo add-apt-repository ppa:pdoes/ppa
sudo apt-get update
sudo apt-get install git
git --version

Afterwards use below command for clone single branch

git clone -b branch_name --single-branch git://github/repository.git

For example:

git clone -b Sub_Branch_2 --single-branch git://github/repository.git

For more details, you may visit Git tutorial

I hope you like this article. Share your views to improve content. Happy Learning !!!

Tuesday, 29 September 2015

Domain in Odoo

In this article, we will see some theory of domain.

A domain is a list of criteria, each criteria being a triple (either a list or a tuple) of (field_name, operator, value).

Where,

 - field_name:

         It's string type and must be from the current model or any relational traversal field through the Many2one field using membership (.) dot operator.

 - operator:

         It's for comparing field's value with passed value.
Valid operator list (>, >=, <, <=, =, !=, =?, ilike, like =like, =ilike, not like, not ilike, childs_of, in, not in)

 - value:

         It's for comparing with field's value.

Multiple criteria can be joined with three logical operators. Logical AND, logical OR, logical NOT.

Let's take a real inputs example:

Suppose we have 10 records like:

Record 1: Openerp

Record 2: openerp

Record 3: Opensource

Record 4: opensource

Record 5: Open

Record 6: open

Record 7: Odoo

Record 8: odoo

Record 9: Odooopenerp

Record 10: OdooOpenerp

OUTPUT:

'like':

[('input', 'like', 'open')] -  Returns case sensitive (wildcards - '%open%') search.

O/p: open, opensource, openerp, Odooopenerp

'not like':

[('input', 'not like', 'open')] -  Returns results not matched with case sensitive (wildcards - '%open%') search.

O/p: Openerp, Opensource, Open, Odoo, odoo, OdooOpenerp

'=like':

[('name', '=like', 'open')] - Returns exact (=  'open') case sensitive search.

O/p: open

'ilike':


[('name', 'ilike', 'open')] - Returns exact case insensitive (wildcards - '%open%') search.

O/p: Openerp, openerp, Opensource, opensource, Open, open, Odooopenerp, OdooOpenerp

'not ilike': [('name', 'not ilike', 'open')] - Returns results not matched with exact case insensitive (wildcards - '%open%') search.

O/p: Odoo, odoo

'=ilike':

[('name', '=ilike', 'open')] - Returns exact (=  'open' or 'Open') case insensitive search.

O/p: Open, open

'=?': 

name = 'odoo'
parent_id = False
[('name', 'like', name), ('parent_id', '=?', parent_id)] - Returns name domain result & True

name = 'odoo'
parent_id = 'openerp'
[('name', 'like', name), ('parent_id', '=?', parent_id)] - Returns name domain result & parent_id domain result

'=?' is a short-circuit that makes the term TRUE if right is None or False, '=?' behaves like '=' in other cases

'in':

[('value1', 'in', ['value1', 'value2'])] - in operator will check the value1 is present or not in list of right term

'not in':

[('value1', 'not in', ['value2'])] - not in operator will check the value1 is not present in list of right term
While these 'in' and 'not in' works with list/tuple of values, the latter
'=' and '!=' works with string

'=':

value = 10
[('value','=',value)] - term left side has 10 in db and term right our value 10 will match

'!=':


value = 15
[('value','!=',value)] - term left side has 10 in db and term right our value 10 will not match

'child_of':


parent_id = '1' #Agrolait
'child_of':
[('partner_id', 'child_of', parent_id)]
- return left and right list of partner_id for given parent_id

'<=', '<', '>', '>=':

These operators are largely used in openerp for comparing dates - [('date', '>=', date_begin), ('date', '<=', date_end)]. You can use these operators to compare int or float also.



For details/reference visit domains in Odoo

I hope you like this article. Share your views to improve content. Happy Learning !!!

Sunday, 27 September 2015

Email validation in Odoo

This article will help us to validate Email field on Partner form.

First of all, we need to understand argument of _constraints.

    _constraint has list of arguments in which

          1. Method is name,

          2. Warning/Error message and

          3. List of field name.

Method will be fire based on, change of field value given as third argument in _constraint.

Now we need to set constraint for Email field.

Here is code for constraint.
  
    _constraints = [
        (_validate_email, 'Please enter a valid email address.', ['email']),
    ]

Here is code for method.

    @api.multi
    def _validate_email(self):
        for partner in self:
            if re.match("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$", partner.email) == None:
                return False
        return True

NOTE:

         Warning/Error message will be populate, only when method will return False.

I hope you like this article. Share your views to improve content. Happy Learning !!!

Monday, 17 August 2015

one2many, many2many, many2one field in openerp

In OpenERP/Odoo, we have one2many and many2many datatype field. For add, update, delete we have some trick to link with record, which are listed below.

1. (0, 0,  { values })    link to a new record that needs to be created with the given values dictionary

2. (1, ID, { values })    update the linked record with id = ID (write *values* on it)

3. (2, ID)                     remove and delete the linked record with id = ID (calls unlink on ID, that will delete the object completely, and the link to it as well)

4. (3, ID)                     cut the link to the linked record with id = ID (delete the relationship between the two objects but does not delete the target object itself)

5. (4, ID)                     link to existing record with id = ID (adds a relationship)

6. (5)                          unlink all (like using (3,ID) for all linked records)

7. (6, 0, [IDs])             replace the list of linked IDs (like using (5) then (4,ID) for each ID in the list of IDs)


one2mnay we will use 1,2,3 points and for many2many we will use all the points.

For many2one field we only need to set record ID.


For more details, Please visit Odoo documentation

Youtube Video 


Friday, 31 July 2015

Odoo 8 release notes


Here is reference link for more details.

Key improvements of version 8 include, by order of priority:
  • Usability & productivity improvements: Odoo 8 is faster, easier to use and configure 
  • Improvement of existing apps: 732 tasks covering most applications
  • New website builder and CMS 
  • New apps: Point of sales with full hardware support, marketing apps, a new WMS and a CMS,
  • The frontend to every app: online jobs offers, booking of events, quotation builder and electronic signature, etc.
  • Technical improvements: refactoring of the framework (new API)
  • Removed modules / features

Sunday, 21 June 2015

ImportError: No module named bs4 (BeautifulSoup)

Beautiful Soup is a Python library for pulling data out of HTML and XML files.

Recently face issue with python packages.

Server Traceback:

openerp@odedra-Lenovo-Z50-70:~$ python testing.py
Traceback (most recent call last):
  File "testing.py", line 1, in <module>
    from bs4 import BeautifulSoup
ImportError: No module named bs4

Here is command for resolving issue on Linux.

sudo apt-get update
sudo apt-get upgrade
pip install BeautifulSoup4

For other OS you may advice to visit Here

Once you completed download the compressed file , decompress the file and then inside you will see a python file named setup.py. This is the install file of the package, you need to run a command prompt in the folder and execute following line :

python setup.py install

I hope you like this article. Share your views to improve content. Happy Learning !!!

Youtube Video

ImportError: No module named phonenumbers

Sometime we install community module in our system and facing error like No module ****. This blog is for what I face the same error. Might be helpful to you guys.

Module name => base_phone

Server Traceback:

Traceback (most recent call last):
  File "/home/openerp/workspace/openerp/server/openerp/service/__init__.py", line 60, in load_server_wide_modules
    openerp.modules.module.load_openerp_module(m)
  File "/home/openerp/workspace/openerp/server/openerp/modules/module.py", line 415, in load_openerp_module
    getattr(sys.modules['openerp.addons.' + module_name], info['post_load'])()
  File "/home/openerp/workspace/openerp/web/addons/web/http.py", line 628, in wsgi_postload
    openerp.wsgi.register_wsgi_handler(Root())
  File "/home/openerp/workspace/openerp/web/addons/web/http.py", line 517, in __init__
    self.load_addons()
  File "/home/openerp/workspace/openerp/web/addons/web/http.py", line 580, in load_addons
    m = __import__('openerp.addons.' + module)
  File "/home/openerp/workspace/openerp/server/openerp/modules/module.py", line 133, in load_module
    mod = imp.load_module('openerp.addons.' + module_part, f, path, descr)
  File "/home/openerp/workspace/openerp/fpg/base_phone/__init__.py", line 22, in <module>
    from . import base_phone
  File "/home/openerp/workspace/openerp/custom_addons/base_phone/base_phone.py", line 26, in <module>
    import phonenumbers
ImportError: No module named phonenumbers


Here is command for resolving issue on Linux.

sudo apt-get update
sudo apt-get upgrade
pip install phonenumbers

For other OS you may advice to visit Here

Once you completed download the compressed file , decompress the file and then inside you will see a python file named setup.py. This is the install file of the package, you need to run a command prompt in the folder and execute following line :

python setup.py install


I hope you like this article. Share your views to improve content. Happy Learning !!!

Youtube Video 

Monday, 1 June 2015

How to remove autorun.inf virus in Window OS ?

An autorun.inf file is a text file that can be used by the AutoRun and AutoPlay components of Microsoft Windows operating systems. For the file to be discovered and used by these component, it must be located in the root directory of a volume.

This file is attached to many events of windows explorer including OPEN, REFRESH, etc. Simple stept to remove the virus activation:
You must close opened explorer windows.

1. Open up a command prompt (i.e. cmd.exe) >> to load it go to Run, type cmd, enter.

2. Now to remove virus's attributes (in order to delete it type following line by line and execute them pressing enter.
e.g.
D:\

D:\attrib -h -r -s *.*  >> If there are any malicious EXE files those are now visible so if unnecessary delete them too.

OR attrib -h -r -s autorun.inf and press enter. It will search for autorun.inf from computer

D:\del autorun.inf

3. After finishing above, quickly remove the pen as soon as possible (just after executing del command).

4. Now your pen is without virus activation config. file. Now you can safely delete unnecessary EXE files on it.

I hope you like this article. Share your views to improve content. Happy Learning !!! 

Thursday, 28 May 2015

How to set default value in Odoo ?

When User open a form view at that time default value display and than after save record it will display value based on our requirement.

Here is char type field example which will display a string before save record default and than it will show different string.

We will use function filed for that. This field will not take input from the user click that will only used for information purpose.

Here is code example:

def _default_get(self, cr, uid, context=None):
    print " This function called before new record create "
    res = 'bhavesh'
    return res     

def _set_value(self, cr, uid, ids, name, args, context=None):
    print " This function called at time of saving record and form view load "
    res = {}
    for i in self.browse(cr, uid, ids, context=context):
        res[i.id] = 'odedra'
    return res

_columns = {
    'value': fields.function(_set_value, type='char', string='Value'),
}

_defaults = {
    'value': _default_get,
}

I hope you like this article. Share your views to improve content. Happy Learning !!! 

Monday, 20 April 2015

How to start Libreoffice Server and Telnet Server in Ubuntu?

In Odoo/OpenERP, when we are generating a Aeroo report, we must start these below two server.
  1. Libreoffice Server and
  2. Telnet Server
If Libreoffice is not install in Ubuntu than first install with these command.

    sudo apt-get update
    sudo apt-get upgrade
    sudo apt-get install libreoffice

Start Libreoffice with these command.

cd /usr/lib/libreoffice/program/ #to move to the libreoffice:

./soffice -nologo -nofirststartwizard -headless -norestore -invisible "-accept=socket,host=localhost,port=8100,tcpNoDelay=1;urp;" #Open Libreoffice server

If Telnet Server is not install in Ubuntu than visit Telnet installation guidance

Don't stop Libreoffice server and open another terminal for test localhost with Telnet Server
 
    telnet localhost 8100

And than Go to Settings/ Modules / Update module list : Search for 'ooo' , you will find 'report_aeroo_ooo'. Install that module.

And Finally, Configure OpenOffice.org connection from Setting/Technical/Configure OpenOffice.org co. and press connect.


I hope you like this article. Share your views to improve content. Happy Learning !!!

Install and Enable Telnet server in Ubuntu Linux

1.Install telnet use this command in terminal(Applications/Accessories/Terminal):

sudo apt-get install xinetd telnetd

2.Edit /etc/inetd.conf using your favorite file editor with root permission,add this line:

telnet stream tcp nowait telnetd /usr/sbin/tcpd /usr/sbin/in.telnetd

3.Edit /etc/xinetd.conf, make its content look like following:

# Simple configuration file for xinetd
#
# Some defaults, and include /etc/xinetd.d/
defaults
{
# Please note that you need a log_type line to be able to use log_on_success
# and log_on_failure. The default is the following :
# log_type = SYSLOG daemon info
instances = 60
log_type = SYSLOG authpriv
log_on_success = HOST PID
log_on_failure = HOST
cps = 25 30
}

4.You can change telnet port number by edit /etc/services with this line:

telnet        8100/tcp

5.If you’re not satisfied with default configuration.Edit etc/xinetd.d/telnet, add following:

# default: on
# description: The telnet server serves telnet sessions; it uses
# unencrypted username/password pairs for authentication.
service telnet
{
disable = no
flags = REUSE
socket_type = stream
wait = no
user = root
server = /usr/sbin/in.telnetd
log_on_failure += USERID
}

add these lines as you like:

only_from = 192.168.120.0/24 #Only users in 192.168.120.0 can access to
only_from = .bob.com #allow access from bob.com
no_access = 192.168.120.{101,105} #not allow access from the two IP.
access_times = 8:00-9:00 20:00-21:00 #allow access in the two times
......

6.Use this command to start telnet server:

sudo /etc/init.d/xinetd start
sudo /etc/init.d/xinetd stop
sudo /etc/init.d/xinetd restart

Reference Link

Monday, 9 February 2015

How related field work in Odoo 8, 9, and 10?


Let's take an example of Sale Order Line. Scenario is like when we add Product in sale order line at time, the Product Category name should be fill up. For that we need to do two  things.

  1. add related field in 'sale.order.line' and give it in view at proper place
  2. need to override onchange of product, if we don't want to override the onchange than at the time of record save it will also save the product category name.

Here is .py code:

Old API:

class sale_order_line(osv.Model):
    _inherit = 'sale.order.line'

    _columns = {
        'product_categ_name': fields.related('product_id', 'categ_id', 'name', type='char', string='Product Category', store=True, readonly=True),
}

New API:

from openerp import api, fields, models, _

class SaleOrderLine(models.Model)
    _inherit = 'sale.order.line'

    product_categ_name = fields.Char(related='product_id.categ_id.name', string='Product Category', store=True, readonly=True)

Here is .xml file

<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
   
        <record id="view_product_category_related_sale_line" model="ir.ui.view">
            <field name="name">view.product.category.related.sale.line</field>
            <field name="model">sale.order</field>
            <field name="inherit_id" ref="sale.view_order_form" />
            <field name="arch" type="xml">
                <xpath expr="//field[@name='order_line']/form/group/group/field[@name='product_id']" position="after">
                    <field name="product_categ_name"/>
                </xpath>
            </field>
        </record>

    </data>
</openerp>


Here is screen shot of it


More about on related field, take a look here

I hope you like this article. Share your views to improve content. Happy Learning !!!

Youtubde Video 

Friday, 23 January 2015

How to replace kanban image using XPATH in Odoo?

We take an example for Partner Object like either partner has checked with Is a Company than we will show the different image or already uploaded image will show.

In Customer Form has field  " " based on it, we will show image in kanban view.

For that we only need to put .xml code.

Here is code:

<record model="ir.ui.view" id="res_partner_kanban_view_extened">
    <field name="name">res.partner.kanban.view.extened</field>
    <field name="inherit_id" ref="base.res_partner_kanban_view"/>
    <field name="model">res.partner</field>
    <field name="arch" type="xml">
        <xpath expr='//kanban/templates/t/div/a/t/t[@t-if="record.is_company.raw_value === true"]' position="replace">
        <!-- check condition weather IS A COMPANY is checked or not -->
            <t t-if="record.is_company.raw_value === true">
                <img  src="custom_patht_of_image" class="oe_kanban_image"/>
            </t>
        </xpath>
    </field>
</record>

I hope you like this article. Share your views to improve content. Happy Learning !!!

Youtube Video 

Monday, 5 January 2015

How to change "Powered by Odoo" footer in Odoo?



First go to your Odoo web module and open below file.

    addons => web => views => webclient_templates.xml

Now find this tag <div class="oe_footer">

<div class="oe_footer">
   Powered by <a href="http://www.openerp.com" target="_blank"><span>Odoo</span></a>
</div>

We can change anything like your company name or else. Now I change with "Odedra" save it and restart your server and upgrade your web module form GUI and you will got your changes.

<div class="oe_footer">
   Powered by <a href="http://www.openerp.com" target="_blank"><span>Odedra</span></a>
</div>
 


I hope you like this article. Share your views to improve content. Happy Learning !!!

Youtube Video



Thursday, 1 January 2015

Linkedin Integration with Odoo

How to integrate Linkedin with Odoo?

First of all we required following modules installed in Odoo.
  • web_linkedin
  • auth_oauth
After install above module in Odoo, We need API key of Linkedin to integrate with Odoo. For that purpose we need to create application in Linkedin, use this link https://www.linkedin.com/secure/developer

Click on Add New Application and follow below steps.

 
Here is an example of an Application. You may need to use your website URL.


 
Now agree with condition and it will generate a API key and Secret Key. Note API key because we need to use in Odoo.

Give API key to Odoo under Settings => Configuration => Sales => Social Network Integration


Apply and now go Sales => Sales => Customers and click on create button it will open below form.


Now Click on Blue button "in" it will open a pop-up below which will give you a company name and people name. And also we can find a people from the Linkedin form the right side of pop-up window.



I hope you like this article. Share your views to improve content. Happy Learning !!! 


Youtube Video

ImportError: No module named googleapiclient

Recently, I have faced ImportError: No module named googleapiclient and I would like to share knowledge to fix that problem. Open termina...