Showing posts with label odoo9. Show all posts
Showing posts with label odoo9. Show all posts

Thursday, 13 April 2017

How to call model objects at xml qweb?

<t t-foreach="request.env['your.model'].search([])" t-as="obj">
    <t t-esc="obj.name"/>
</t>

Monday, 20 March 2017

How i can create module openerp 7 / Odoo 8 ?

Hi,

Quick Start Guide

For Odoo v8: https://www.odoo.com/documentation/8.0/
1°-Start reading:

Quick start :

Technical_Memento_v0.7.3(En)
Technical_Memento_v 7 (FR)
Official doc : Modules OpenERP v7

2°-Sample module :

Example 1 : Basics of developing a simple module in OpenERP

Example 2 : How to create a module in OpenERP ?

Example 3: Custom Sample Module Development

Example 4:Module structure of OpenERP module

Example 5:Adding additional fields

3°- Videos

Create a module (through interface not with python code)

Tools / IDE OpenERP

1°-IDE : I suggest Eclipse IDE : Eclipse Classic

2°-Python : plugin PyDev for eclipse : Installing the Eclipse PyDev plugin

3°-XML : Editor integrated with eclipse

4°-Templates Openerp :Template for eclipse of openerp code snippets. This snippets are build to help rapid building openerp project with great ease.

For Python Snippets

For XML Snippets

5°-OpenERP in eclipse.

Debug your openERP+python code in eclipse

OpenERP development environment in Windows using Eclipse.

6°-OpenERP V7.0 installation on ubuntu 12.04 x64

How to install OpenERP V7.0 on Ubuntu 12.04 from launchpad repository?

Thursday, 16 March 2017

How to Create service in odoo10

On Ubuntu 16.04, this is how you create a service for Odoo10:

[Unit]
Description=Odoo
Documentation=http://www.odoo.com/
[Service]
# Ubuntu/Debian convention:
Type=simple
User=odoo
ExecStart=/opt/odoo10/odoo-bin -c /etc/odoo-server.conf
[Install]
WantedBy=default.target


You put this in /etc/systemd/system and I called my file odoo10.service so you can then do:

sudo systemctl start odoo10.service (starts service)
sudo systemctl stop odoo10.service (stops service)
sudo systemctl restart odoo10.service (restarts Service)
sudo systemctl status odoo10.service (status of service)
sudo systemctl enable odoo10.service (starts service at boot)
sudo systemctl disable odoo10.service (disables service at boot)

Wednesday, 15 March 2017

ValueError Expected singleton in Odoo

Expected Singleton:

Class methods required single invoking object (Single Browsable Record) to invoke the method and suppose it will call by multiple invoking objects (Browsable Recordsets) then method is not able to identify for which object it should process, therefore it will raise an error Expected Singleton.

New API decorator is used to define method calling pattern whether methods allows only single object or multiple objects to invoke this method.


For Example:


if self.location_id:     #face ValueError Expected singleton because self contains multiple recordset.

    ########

Need to change with following:

for warehouse in self:

    if warehouse.location_id:

        ########


@api.one

This decorator loops automatically on Records of RecordSet for you. Self is redefined as current record

Note:

Caution: the returned value is put in a list. This is not always supported by the web client, e.g. on button action
methods. In that case, you should use @api.multi to decorate your method, and probably call self.ensure_one() in
the method definition.

@api.multi

Self will be the current RecordSet without iteration. It is the default behavior (multiple browsable objects). Methods which returns non premitive type data(list, dictionary, function) must be decorated with @api.multi

@api.model

This decorator will convert old API calls to decorated function to new API signature. It allows to be polite when
migrating code. Self does not contain any record/recordset in methods which are decorated by this decorator.

So simply call like this

self.env['model_name'].method_name(arguments)

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)

Friday, 10 March 2017

How to Add Search View Filters In Odoo ?

Filters for Datetime field

Today Filter

<filter icon="terp-go-month" string="Today " separator="1" domain="[('date','&lt;=', (datetime.date.today()).strftime('%Y-%m-%d')),('date','&gt;=',(datetime.date.today()).strftime('%Y-%m-%d'))]" help="Created today"/>
                                    OR

<filter icon="terp-go-today" string="Today" domain="[('date','&lt;=', datetime.datetime.combine(context_today(), datetime.time(23,59,59))), ('date','&gt;=', datetime.datetime.combine(context_today(), datetime.time(0,0,0)))]" help="Orders processed Today or planned for Today"/>


This Year


<filter string="This Year" name="year" domain="[('date','&lt;=', time.strftime('%%Y-12-31')),('date','&gt;=',time.strftime('%%Y-01-01'))]"/>




Last Week

<filter string="Last week" domain="[('date_order', '&gt;=', ((context_today()+relativedelta(weeks=-2,                                         days=1, weekday=0)).strftime('%Y-%m-%d'))),('date_order', '&lt;=', ((context_today()+relativedelta(weeks=-1,weekday=6)).strftime('%Y-%m-%d')))]"/>


This Month 

  <filter icon="terp-go-month" string="Month" name="month" domain="[('date_order','&lt;=',(datetime.date.today()+relativedelta(day=31)).strftime('%Y-%m-%d')),('date_order','&gt;=',(datetime.date.today()-relativedelta(day=1)).strftime('%Y-%m-%d'))]" help="Current Month"/>



Current week


<filter icon="terp-go-week"
        string="Current Week"
        separator="1"
        name="week"
        domain="[('date_order','&lt;=', (context_today() + relativedelta(weeks=0,day=7, weekday=-1)).strftime('%Y-%m-%d')),('date_order','&gt;=',(context_today() - relativedelta(weeks=1, weekday=0)).strftime('%Y-%m-%d'))]"
        help="Current Week"
        context="{'group_by':'date_order'}"/>


Previous Month


<filter string="Prev Month" name="prev_month" domain="[('date_order','&gt;=',(context_today()-relativedelta(months=1)).strftime('%Y-%m-01')),('date_order','&lt;',time.strftime('%Y-%m-01'))]"/>


Expiry checking

<filter string="Immediate Expiry" name="od_imm" domain="[('expiry_date','&gt;=', ((context_today()+datetime.timedelta(days=1)).strftime('%Y-%m-%d'))),('expiry_date','&lt;=', ((context_today()+datetime.timedelta(days=45)).strftime('%Y-%m-%d')))]"/>

Yesterday


<filter string="Yesterday" domain="[('date_order','&gt;=', ((context_today()-datetime.timedelta(days=1)).strftime('%Y-%m-%d 00:00:00'))), ('date_order','&lt;=', ((context_today()+datetime.timedelta(days=0)).strftime('%Y-%m-%d 00:00:00')))]"/>

Tomorrow


<filter string="Tomorrow" domain="[('date_order','&gt;=', ((context_today()+datetime.timedelta(days=0)).strftime('%Y-%m-%d 23:59:59'))), ('date_order','&lt;=', ((context_today()+datetime.timedelta(days=1)).strftime('%Y-%m-%d 23:59:59')))]"/>

Filters for Selection Field

Eg:<filter string="Quotations" name="draft" domain="[('state','in',('draft','sent'))]" help="Sales Order that haven't yet been confirmed"/>
Eg:<filter string="To Invoice" domain="[('state','=','manual')]" help="Sales Order ready to be invoiced"/>


Filters for Boolean Field

Eg:<filter icon="terp-gtk-jump-to-ltr" string="To Review" domain="[('to_check','=',True)]" help="Journal Entries to Review"/>

Filters for Many2one Field

<filter domain="[('user_id','=',uid)]" help="My Invoices" string="My Invoices"/>
for many2one field we are usually adding group by instead of filters.
you can add filters for many2one field by hard coding ids

Eg:-<filter domain="[('partner_id','in',(1,2,9,8,22)]" help="Selected" string="Special Partners"/>
Eg:-<filter domain="[('partner_id','=',1]" help="Selected" string="My Order"/>



Filters for Date Field


This week


<filter string="This Week"  name="This Week" separator="1"
                         domain="[('date_from','&gt;=', ((context_today()).strftime('%Y-%m-%d'))), ('date_from','&lt;=', ((context_today()+datetime.timedelta(days=7)).strftime('%Y-%m-%d')))]"
                           help="This Week"/>
Last Week


<filter string="Last Week"  name="Last Week" separator="1"
                         domain="[('date_from','&gt;=', ((context_today()+datetime.timedelta(days=-7)).strftime('%Y-%m-%d'))), ('date_from','&lt;=', ((context_today()).strftime('%Y-%m-%d')))]"
                           help="This Week"/>

yesterday

<filter string="Yesterday"  name="Yesterday" separator="1"
                         domain="[('date_from','&gt;=', ((context_today()+datetime.timedelta(days=-1)).strftime('%Y-%m-%d'))), ('date_from','&lt;=', ((context_today()+datetime.timedelta(days=-1)).strftime('%Y-%m-%d')))]"
                           help="Yesterday"/>

Today

<filter string="Today"  name="Today" separator="1"
                         domain="[('date_from','&gt;=', ((context_today()+datetime.timedelta(days=0)).strftime('%Y-%m-%d'))), ('date_from','&lt;=', ((context_today()+datetime.timedelta(days=0)).strftime('%Y-%m-%d')))]"
                           help="Today"/>

Tomorrow


<filter string="Tomorrow"  name="Tomorrow" separator="1"
                         domain="[('date_from','&gt;=', ((context_today()+datetime.timedelta(days=1)).strftime('%Y-%m-%d'))), ('date_from','&lt;=', ((context_today()+datetime.timedelta(days=1)).strftime('%Y-%m-%d')))]"
                           help="Tomorrow"/>

Expiry


<filter string="Immediate Expiry"  name="Immediate Expiry" separator="1"
                         domain="[('date_from','&gt;=', ((context_today()+datetime.timedelta(days=0)).strftime('%Y-%m-%d'))), ('date_from','&lt;=', ((context_today()+datetime.timedelta(days=45)).strftime('%Y-%m-%d')))]"
                           help="Immediate Expiry"/>


Last Month

<filter icon="terp-go-month" string="Last Month"
                         domain="[('date_from','&lt;=', (context_today()-relativedelta(day=31, months=1)).strftime('%Y-%m-%d')),
                         ('date_from','&gt;=',(context_today()-relativedelta(day=1,months=1)).strftime('%Y-%m-%d'))]"
                         help="last month"/>

Current Month



<filter string="Current Month" name="current_month" domain="[('date_from','&lt;',(context_today()+relativedelta(months=1)).strftime('%Y-%m-01')), ('date_from','&gt;=',time.strftime('%Y-%m-01'))]"/>


Last Year
<filter  icon="terp-go-month" string="Last Year"
                domain="[('date', '&gt;=' ,(context_today()-relativedelta(years=1)).strftime('%Y-01-01')),('date','&lt;=',time.strftime('%Y-01-01'))]" help="last year"/>


This Year
<filter icon="terp-go-year" string="Year"
                            domain="[('date_from','&lt;=', time.strftime('%Y-%m-%d')),('date_from','&gt;=',time.strftime('%Y-01-01'))]"
                            help="Current Year"/>


Tuesday, 7 March 2017

How to call a wizard from js in odoo ?

this.do_action({

                   type: 'ir.actions.act_window',

                  res_model: 'Model name',

                 view_mode: 'form',

                 view_type: 'form',

                 views: [[false, 'form']],

                 target: 'new',

                 context:{}
});

Sunday, 20 September 2015

How to Install OpenERP/Odoo 9 on Ubuntu Server 14.04 LTS. | OpenERP

Hi Guys..

First get newest versions possible as per version requirements of dependencies of packages existing on the machine using.
sudo apt-get update && sudo apt-get dist-upgrade

Create User

Create Odoo System User that will own and run the odoo application.
sudo adduser --system --home=/opt/odoo --group odoo
Here we have specified /opt/odoo as home, so when ever you change user to odoo it will by default land to /opt/odoo.
we gonna put all the odoo code under /opt/odoo. you can change the path of your choice, and do the configuration accordingly.after creating user you can login with the created user by below command.
sudo su - odoo -s /bin/bash
you can press ctrl + d or write exit and press enter to logout.

Install and Configure Postgres

sudo apt-get install postgresql
This command will install postgres 9.1 by default in ubuntu 14.04 or any debian distribution. if you want to use any specific version of postgres(i.e 9.3, 9.4) you need to update the source list. for example to install postgres-9.4 you can follow below steps.
Create the file /etc/apt/sources.list.d/pgdg.list, and add a line for the repository using vim or nano editor
deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main
Import the repository signing key, and update the package lists
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
and update the packages using
sudo apt-get update
after that you can search/install the available/supported postgres version
sudo apt-get install postgresql-9.4
After installing postgres 9.4, change to the postgres user so we have the necessary privileges to configure the database
sudo su - postgres
Now create a new database user with access to create and drop database.
createuser --createdb --username postgres --no-createrole --no-superuser --pwprompt odoo
Enter password for new role: ********
Enter it again: ********
Finally exit from the postgres user account:
exit

Install the necessary libraries

sudp apt-get install python-pip python-dev libevent-dev gcc libxml2-dev libxslt-dev node-less

Note
Odoo 9 is depends on node-less
After installing this system libraries we can install python libraries using pip. Create requirement.txt file in server. create the file using below command and paste the content from this file.
sudo nano /tmp/requirement.txt
press ctrl + x and y to save & exit the file
after creating requirement.txt file it’s time to install odoo python library
sudo pip install -r /tmp/requirements.txt
After that all the dependencies for installing Odoo 9.0 are now satisfied.
for Qweb templating we need to install wkhtmltopdf. download deb file of  wkhtmltopdf 32 bit or wkhtmltopdf 64 bit.
Here We have downloaded wkhtmltopdf in /tmp directory. You can go to the download directory using cd and run the command depending on your file name.
for 64 bit:
sudo dpkg -i /tmp/wkhtmltox-0.12.2.1_linux-trusty-amd64.deb
for 32 bit:
sudo dpkg -i /tmp/wkhtmltox-0.12.2.1_linux-trusty-i386.deb

Install the Odoo server

Install Git:
sudo apt-get install git
Switch to the Odoo user:
sudo su - odoo -s /bin/bash
Grab a copy of the most current Odoo 9(master) branch (Note the “.” at the end of this command!):
git clone https://www.github.com/odoo/odoo --depth 1 --branch 9.0 --single-branch .
–depth 1 to the command will only retrieves the latest version without all the history. The download is now quite a bit faster.
Once it’s finished exit from the odoo user using crtl+d:

Configuring the Odoo application

The default configuration file for the server is under /opt/odoo/debian/openerp-server.conf. we’ll copy that file to where we need it and change it’s ownership and permissions:
sudo cp /opt/odoo/debian/openerp-server.conf /etc/odoo-server.conf
sudo chown odoo: /etc/odoo-server.conf
sudo chmod 640 /etc/odoo-server.conf
Above commands make the file owned and writable only by the odoo user and group and only readable by odoo and root.
To allow odoo to use default addons you need to change the addons_path line in config file addons_path = /usr/lib/python2.7/dist-packages/openerp/addons in the config file to addons_path = /opt/odoo/addons.
you can also change other line as per your server deployment needs.

Installing the Init script

This script will be used to start-up and shut down the odoo server automatically and also run the application as the defined user. we will user script /opt/odoo/debian/init by doing few small modifications. Here’s a link to the one I’ve already modified for Odoo 9.
Now you need to either copy it or paste the contents of this script to a file in /etc/init.d/ and call it odoo-server. and you need to make it executable and owned by root:
sudo chmod 755 /etc/init.d/odoo-server
sudo chown root: /etc/init.d/odoo-server
we also need to make log file /var/log/odoo/odoo-server.log and give access rights using
create odoo directory under /var/log/
sudo mkdir /var/log/odoo
go to the directory
cd /var/log/odoo
create file
cat > odoo-server.log
give the permission to writable by the odoo user
sudo chmod 755 /var/log/odoo/odoo-server.log
sudo chown odoo:root -R /var/log/odoo/

Testing the odoo server

To start the Odoo server type:
sudo /etc/init.d/odoo-server start
You should now be able to view the log file and see that the server has started.
sudo tail -f /var/log/odoo/odoo-server.log
If the log file looks OK, now point your web browser at the domain or IP address of your Odoo server which by default use port 8069. try below in your browser
http://IP_or_domain.com:8069
for the first time you will see database manager to create your first database.
Now it’s time to make sure the server stops properly too:
sudo /etc/init.d/odoo-server stop
Check the log file again to make sure odoo has stopped properly.
sudo tail -f /var/log/odoo/odoo-server.log

Atomizing Odoo server startup

If everything working well we can do a entry of odoo-sever in update-rc.d which will automatically start & stops the odoo server along with ubuntu,
sudo update-rc.d odoo-server defaults