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

Saturday, 20 December 2014

How to display custom header and footer in all page in RML report in OpenERP 7?

Here is page template tag that may used it for display custom header and footer in all pages.

According to the report view, we need to change x and y co-ordinates. 

<pageTemplate id="first">
  <frame id="first" x1="30.0" y1="27.0" width="508" height="815"/>
    <pageGraphics>
        <image x="1.3cm" y="26.0cm" height="90.0">
              [[company.logo or removeParentNode('image')]]</image>
        <place x="16.6cm" y="25.3cm" height="1.8cm" width="15.0cm">
        <para fontSize="7.0" fontName="Helvetica" >
              [[ display_address(company.partner_id) or  '' ]]</para>
        </place>
        <lines>1.3cm 24.9cm 19.9cm 24.9cm</lines>
    </pageGraphics>
</pageTemplate>

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

Youtube Video 

Saturday, 13 December 2014

How to hide small edit button beside many2one field in Odoo?


Here is Purchase order form view.


For that we need to Active debug mode from the right hand side and click to the Admin and than About Odoo.


Click to the Active the Active Developer mode.


Now select Edit Formview from the Debugview.


Edit this attribute to partner_id field => options='{"no_open": True}'


Save it and Refresh the browse or press F5. We may see it now navigate menu is hide from there.



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

Youtube Video 

How to create recurring invoice in Odoo?

First install "Recurring Documents" module.
 

Now follow this path. Settings => Technical => Automation => Recurring Types and create record with name should be any thing and object must be Invoice.


Settings => Technical => Automation => Recurring Documents and create document for invoice. In Source Document, we may select which invoice we need to create recurring.

 
Save this record and click on red button called "Process"


We can see that Cron Job is created.



Documents Created tab is empty because currently no invoice is created.


 After Scheduler run the document is created. (NOTE: I have changed interval unit from Months to Days so next interval can match and create invoice instantly. Otherwise it will create once on monthly basis.)
 
 
Cron Job look like.


Below image is a old invoice which is we select in Source Document.


 
Here is new Invoice which is created from cron job. 
 


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

Youtube Video 

Friday, 12 December 2014

XML-RPC web services in OpenERP

XML-RPC is known as a web service. Let's understand how's work in OpenERP.


import xmlrpclib

username = 'admin' #the login user name
pwd = 'admin'      #the password of the user
dbname = 'my_db'    #the database name

# Connection String ........

sock_common = xmlrpclib.ServerProxy('http://localhost:8069/xmlrpc/common')
uid = sock_common.login(dbname, username, pwd)
sock = xmlrpclib.ServerProxy('http://localhost:8069/xmlrpc/object')

#create partner record

partner = {
   'name': 'Odedra',
   'lang': 'en_US',
}

partner_id = sock.execute(dbname, uid, pwd, 'res.partner', 'create', partner) #partner is created

print "\n\n===Partner Create id => ", partner_id

#how to update partner record?

vals = {'street': 'Chhaya Road',
   'zip': '360575',
   'city': 'Porbandar',
   'phone': '+2244202',
   'fax': '+2244202222',
}

update_data = sock.execute(dbname, uid, pwd, 'res.partner', 'write', partner_id, vals) #record update successfully

print "\n\n===Is Partner updated? => ", update_data

#how to read partner record?

fields = ['name', 'city', 'zip']

read_data = sock.execute(dbname, uid, pwd, 'res.partner', 'read', partner_id, fields) #read data successfully

print "\n\n===Yes, Here is value for Partner record => ", read_data

#how to search a partner record?

query = [('name', 'ilike', 'Odedra')] #query clause
ids = sock.execute(dbname, uid, pwd, 'res.partner', 'search', query) #give the id of searched record otherwise it's return empty list

print "\n\n===how many partner founds? => ", len(ids)
print "\n\n===What their id? => ", ids

#how to call method?
#NOTE: First we have too method on res.partner object than and than we can call that method

res = sock.execute(dbname, uid, pwd, 'res.partner', 'method_name', [partner_id])

print "\n\n===Is method called? => ", res

#how to delete partner record?

result = sock.execute(dbname, uid, pwd, 'res.partner', 'unlink', partner_id) #delete the partner

print "\n\n===Is Partner deleted ? => ", result

print "\n\nGoodBye...."

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

Youtube Video

ModuleNotFoundError: No module named 'psycopg2'

  Odoo 18:  Traceback (most recent call last): File "/home/bodedra/odoo18/demo/src/odoo/./odoo-bin", line 5, in ...