Monday, 30 December 2019

Steps to secure your Odoo

We suggest following steps to secure your Odoo.
  • Set private ssh key for your Odoo server.
  • Start your Odoo in SSL mode.
  • Install Nginx in your Ubuntu Server.
  • Stop access of all unnecessary ports from firewall of your Ubuntu Server.
  • Set proper data access rights & access rules into your Odoo instance.
  • Set proper authentication method for your PostgreSQL database user.
  • Set tricky password for PostgreSQL user.
  • Apply encryption on Database and Odoo user passwords.
  • Set Tricky password for Super Admin.
  • Request all your ERP users to set difficult password.
  • Give FTP access for your ERP users and don't allow them to create files out of their directory on your Ubuntu Server.
  • Set proper access rights on your custom addons and default Odoo addons via chmod and chown commands.
  • Have a look on /var/log/postgresql/postgresql-9.1-main.log file for malware attack on your database.
  • Manage your Odoo log file properly.
  • Transfer database & custom addons backup to remote place at frequent amount of time.
  • Change and set tricky password for detault postgres user in your database server.
  • Stop xmlrpc if you don't want your ERP to connect from 3rd party systems. ( set xmlrpc=False in your config file )
  • Remove "Manage Database" link from home page of your live Odoo instance. ( it's suggestion only )
  • Ignore installation of Odoo where multiple other websites are hosted.
  • We highly recommend to ignore creation of any kind of demo database in Live Odoo instance. 
  • Ignore to host your Odoo in Web hosting servers, always host Odoo in trusted VPS sites. ( Amazon, Raskspace, DigitalOcen, Myhosting etc..)
  • Monitor Incoming and outgoing TCP/IP traffics in your Ubuntu Server.  Few of our customers for whom we have implemented Odoo for more then 150+ users, they hired their own server administrator to monitor incoming and outgoing TCP/IP traffics. ( Visit this link )
  • Never give full access of your server to your Odoo service providers, always give them folder access of their own custom addons with their separate user. ( It's advisable to not share root user password to anyone. )
  • If customer can afford healthy cost, we always suggest them to set up their own in-house hosting server instead of VPS.

Tuesday, 26 November 2019

Customizing (Website) home page using Qweb in Odoo







Customizing (Website) home page using Qweb in Odoo





Webpage redirection using Odoo Controller

Webpage redirection using  Odoo Controller





from odoo import http
from odoo.http import request

class Custom(http.Controller):
    @http.route('/oldpage', auth='public', website=True)
    def newpage_redirect(self):
return request.redirect('newpage')

    @http.route('/newpage', auth='public', website=True)
    def newpage_render(self):
return http.request.render('appname.newpage', {})




Using the above code we can redirect the oldpage to newpage.



localhost:8069/oldpage        will redirect to    localhost:8069/newpage

Website showing product information using Odoo Controllers

Website showing product information using Odoo Controllers




Controller code







Template code:




Output Code:



Wednesday, 20 November 2019

Sublime Text editor Installation in terminal (Ubuntu)

Sublime Text editor Installation in terminal (Ubuntu)


The popular cross-platform Sublime Text editor finally offers official Linux apt repository to make it easy to install and receive update in Ubuntu.
Sublime Text is a proprietary source code editor with a Python API. It supports many programming languages and markup languages, and its functionality can be extended by users with plugins.
It’s available to download and use for free, but you’re supposed to buy a license if you plan on using it full-time.

Install Sublime Text 3 via the official apt repository:

1. Open terminal via Ctrl+Alt+T or by searching for “Terminal” from desktop app launcher. When it opens, run command to install the key:
wget -qO - https://download.sublimetext.com/sublimehq-pub.gpg | sudo apt-key add -
2. Then add the apt repository via command:
echo "deb https://download.sublimetext.com/ apt/stable/" | sudo tee /etc/apt/sources.list.d/sublime-text.list
3. Finally check updates and install sublime-text via your system package manager:
or by running commands:
sudo apt-get update

sudo apt-get install sublime-text
Once installed, launch it from your desktop app launcher and enjoy!

Uninstall:

To uninstall the editor, either use your system package manager or simply run command:
sudo apt-get remove sublime-text && sudo apt-get autoremove
And the official Sublime Text apt repository can be removed by going to System Settings -> Software & Updates -> Other Software tab.

Wednesday, 13 November 2019

Install Drupal on Ubuntu 18.04

Install Drupal on Ubuntu 18.04


1. sudo apt install -y curl tasksel2. sudo tasksel install lamp-server   sudo a2enmod rewrite3.sudo apt install php-fdomdocument php-gd
4. sudo gedit /etc/apache2/sites-enabled/000-default.conf(copy those lines )<Directory /var/www/html/>           Options Indexes FollowSymLinks           AllowOverride All</Directory>
5. sudo systemctl restart apache2
6. curl --output /tmp/drupal.tar.gz https://ftp.drupal.org/files/projects/drupal-8.4.5.tar.gz
7.sudo rm -fr /var/www/html  sudo tar xf /tmp/drupal.tar.gz -C /var/www/  sudo mv /var/www/drupal-8.4.5/ /var/www/html  sudo chown -R www-data.www-data /var/www/html
8.sudo mysqladmin create drupal sudo mysql -e "CREATE USER 'admin'@'%' IDENTIFIED BY 'pass';" sudo mysql -e "GRANT ALL PRIVILEGES ON drupal.* TO 'admin'@'%' WITH GRANT OPTION;"

How to install Odoo 12 on Ubuntu 18.04

How to install Odoo 12 on Ubuntu 18.04


STEP 1
sudo apt-get update

STEP 2
sudo apt-get -y upgrade

STEP 3
sudo apt-get install python3-pip

INSTALL DEPENDENCIES USING PIP3

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

STEP 4
sudo apt-get install -y npm
sudo ln -s /usr/bin/nodejs /usr/bin/node
sudo npm install -g less less-plugin-clean-css
sudo apt-get install node-less

STEP 5
sudo apt-get install python-software-properties
sudo vim /etc/apt/sources.list.d/pgdg.list
add a line for the repository
deb http://apt.postgresql.org/pub/repos/apt/ xenial-pgdg main
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get install postgresql-9.6

STEP 6
Create Database user for Odoo
sudo su postgres
cd
createuser -s odoo
createuser -s ubuntu_user_name
exit

STEP 7
Create Odoo user and group
sudo adduser --system --home=/opt/odoo --group odoo

STEP 8
Install Gdata
cd /opt/odoo
sudo wget https://pypi.python.org/packages/a8/70/bd554151443fe9e89d9a934a7891aaffc63b9cb5c7d608972919a002c03c/gdata-2.0.18.tar.gz
sudo tar zxvf gdata-2.0.18.tar.gz
sudo chown -R odoo: gdata-2.0.18
sudo -s
cd gdata-2.0.18/
python setup.py install
exit

STEP 9
Odoo 11 Download from GitHub
cd /opt/odoo
sudo apt-get install git
sudo su - odoo -s /bin/bash
git clone https://www.github.com/odoo/odoo --depth 1 --branch 12.0 --single-branch
exit

STEP 10
Create Odoo Log File
sudo mkdir /var/log/odoo
sudo chown -R odoo:root /var/log/odoo

STEP 11
Edit Odoo configuration file
sudo gedit /etc/odoo.conf

#Copy this lines and change with users and password
------------------------------------

[options]

; This is the password that allows database operations:

; admin_passwd = admin

db_host = False

db_port = False

db_user = odoo

db_password = False

logfile = /var/log/odoo/odoo-server.log

addons_path = /opt/odoo/addons,/opt/odoo/odoo/addons

---------------------------------------------------

sudo chown odoo: /etc/odoo.conf

STEP 12
sudo apt-get -f install
sudo wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.1/wkhtmltox-0.12.1_linux-trusty-amd64.deb
sudo dpkg -i wkhtmltox-0.12.1_linux-trusty-amd64.deb
sudo cp /usr/local/bin/wkhtmltoimage /usr/bin/wkhtmltoimage
sudo cp /usr/local/bin/wkhtmltopdf /usr/bin/wkhtmltopdf

STEP 13
Run Odoo Server
cd /opt/odoo/odoo

./odoo-bin

STEP 14
Open browser on :
http://localhost:8069

STEP 15

cd /usr/local/lib/
sudo git clone https://github.com/sass/sassc.git --branch 3.4.2 --depth 1
sudo git clone https://github.com/sass/libsass.git --branch 3.4-stable --depth 1
sudo git clone https://github.com/sass/sass-spec.git --depth=1

STEP 16
echo 'SASS_LIBSASS_PATH="/usr/local/lib/libsass"' | sudo tee -a /etc/environment
source /etc/environment

STEP 17
sudo make -C libsass

STEP 18
sudo make -C sassc
sudo make -C sassc install

STEP 19
Restart Odoo Server

How to install Odoo 12 on Ubuntu 19.04

How to install Odoo 12 on Ubuntu 19.04 


sudo apt update && sudo apt-get dist-upgrade -y

sudo apt install git python3-pip build-essential wget python3-dev python3-venv python3-wheel libxslt-dev libzip-dev libldap2-dev libsasl2-dev python3-setuptools python3-img2pdf node-less


sudo apt-get install libpcap-dev libpq-dev

sudo apt-get install libtiff5-dev libjpeg8-dev zlib1g-dev libfreetype6-dev liblcms2-dev libwebp-dev libharfbuzz-dev libfribidi-dev tcl8.6-dev tk8.6-dev python-tk


** Install WkhtmlToPdf **


wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.4/wkhtmltox-0.12.4_linux-generic-amd64.tar.xz
tar xvJf wkhtmltox-0.12.4_linux-generic-amd64.tar.xz
sudo cp wkhtmltox/bin/wkhtmlto* /usr/bin/

** Create User Odoo 12 **

sudo useradd -m -d /opt/odoo12 -U -r -s /bin/bash odoo12

sudo apt-get install postgresql

sudo su - postgres -c "createuser -s odoo12"




sudo su - odoo12

git clone https://www.github.com/odoo/odoo --depth 1 --branch 12.0 /opt/odoo12/odoo



cd /opt/odoo12

** Python requirements **
python3 -m venv odoo-venv
source odoo-venv/bin/activate
pip3 install --upgrade setuptools
pip3 install fpdf img2pdf wheel gdata
pip3 install -r odoo/requirements.txt

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


deactivate


exit



su odoo12
mkdir /opt/odoo12/custom-addons
exit
sudo nano /etc/odoo12.conf
----------------------------------

[options]
; This is the password that allows database operations:
admin_passwd = my_admin_passwd
db_host = False
db_port = False
db_user = odoo12
db_password = False
addons_path = /opt/odoo12/odoo/addons,/opt/odoo12/custom-addons


----------------------------------


sudo nano /etc/systemd/system/odoo12.service


[Unit]
Description=Odoo12
Requires=postgresql.service
After=network.target postgresql.service
[Service]
Type=simple
SyslogIdentifier=odoo12
PermissionsStartOnly=true
User=odoo12
Group=odoo12
ExecStart=/opt/odoo12/odoo-venv/bin/python3 /opt/odoo12/odoo/odoo-bin -c /etc/odoo12.conf
StandardOutput=journal+console
[Install]
WantedBy=multi-user.target


---------------------------------



sudo systemctl daemon-reload


sudo systemctl start odoo12

sudo systemctl enable odoo12

sudo systemctl status odoo12


How to install Odoo 11 on Ubuntu 16.04

How to install Odoo 11 on Ubuntu 16.04

STEP 1 sudo apt-get update STEP 2 sudo apt-get -y upgrade STEP 3 sudo apt-get install python3-pip INSTALL DEPENDENCIES USING PIP3 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 STEP 4 sudo apt-get install -y npm sudo ln -s /usr/bin/nodejs /usr/bin/node sudo npm install -g less less-plugin-clean-css sudo apt-get install node-less STEP 5 sudo apt-get install python-software-properties sudo vim /etc/apt/sources.list.d/pgdg.list add a line for the repository deb http://apt.postgresql.org/pub/repos/apt/ xenial-pgdg main wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - sudo apt-get update sudo apt-get install postgresql-9.6 STEP 6 Create Database user for Odoo sudo su postgres cd createuser -s odoo createuser -s ubuntu_user_name exit STEP 7 Create Odoo user and group sudo adduser --system --home=/opt/odoo --group odoo STEP 8 Install Gdata cd /opt/odoo sudo wget https://pypi.python.org/packages/a8/70/bd554151443fe9e89d9a934a7891aaffc63b9cb5c7d608972919a002c03c/gdata-2.0.18.tar.gz sudo tar zxvf gdata-2.0.18.tar.gz sudo chown -R odoo: gdata-2.0.18 sudo -s cd gdata-2.0.18/ python setup.py install exit STEP 9 Odoo 11 Download from GitHub cd /opt/odoo sudo apt-get install git sudo su - odoo -s /bin/bash git clone https://www.github.com/odoo/odoo --depth 1 --branch 11.0 --single-branch exit STEP 10 Create Odoo Log File sudo mkdir /var/log/odoo sudo chown -R odoo:root /var/log/odoo STEP 11 Edit Odoo configuration file sudo gedit/etc/odoo.conf #Copy this lines and change with users and password ------------------------------------ [options] ; This is the password that allows database operations: ; admin_passwd = admin db_host = False db_port = False db_user = odoo db_password = False logfile = /var/log/odoo/odoo-server.log addons_path = /opt/odoo/addons,/opt/odoo/odoo/addons --------------------------------------------------- sudo chown odoo: /etc/odoo.conf STEP 12 sudo apt-get -f install sudo wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.1/wkhtmltox-0.12.1_linux-trusty-amd64.deb sudo dpkg -i wkhtmltox-0.12.1_linux-trusty-amd64.deb sudo cp /usr/local/bin/wkhtmltoimage /usr/bin/wkhtmltoimage sudo cp /usr/local/bin/wkhtmltopdf /usr/bin/wkhtmltopdf STEP 13 Run Odoo Server cd /opt/odoo/odoo ./odoo-bin STEP 14 Open browser on : http://localhost:8069

Monday, 29 July 2019

How to redirect HTTP traffic to HTTPS in Nginx and Apache.

How to redirect HTTP traffic to HTTPS in Nginx and Apache

 You should always use HTTPS instead of HTTP to protect your website, even if it doesn’t handle sensitive communications. The main reasons to use HTTPS are:
  • Security – this is the main and most important reason to use HTTPS,  all communications between the visitor’s browser and the website are encrypted.
  • SEO Google uses HTTPS as a ranking signal, which means that if your website is using HTTPS it may get a certain boost in Google rankings.
  • Browser warnings –  if you are not using HTTPS, Google Chrome and other browsers will flag your site as “Not Secure”.
  • Trustworthiness – people usually trust a website much more if they have an SSL certificate.
To use HTTPS, you’ll need an SSL Certificate.

1. Redirect HTTP to HTTPS using Apache mod_rewrite

To automatically redirect all your visitors to the HTTPS version of your site, add the following code in your site .htaccess file
RewriteEngine On
# redirect http to https
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
If you want to redirect all your visitors to the HTTPS NON-WWW version of your, site use the following code:
RewriteEngine On
# redirect all www to https non-www
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [L,R=301]
# redirect http non-www to https non-www
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
and to redirect all your visitors to the HTTPS WWW version of your site, use the following code:
RewriteEngine On
# redirect all non-www to https www
RewriteCond %{HTTP_HOST} !^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://www.%1/$1 [L,R=301]
# redirect http www to https www
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

2. Redirect HTTP to HTTPS with Nginx

We need to create three server blocks, one for HTTP, one for HTTPS NON-WWW and one for HTTPS WWW versions of the site. The first server block will redirect all visitors entering the site via HTTP to HTTPS and the two other blocks will redirect visitors entering the site via WWW to NON-WWW or vice-versa.
To redirect all HTTP and HTTPS NON-WWW traffic to HTTPS WWW, use the following code:
server {
  listen [::]:80;
  listen 80;

  server_name yourdomain.com www.yourdomain.com;

  # redirect http to https www
  return 301 https://www.yourdomain.com$request_uri;
}

server {
  listen [::]:443 ssl http2;
  listen 443 ssl http2;

  server_name yourdomain.com;

  # SSL code

  # redirect https non-www to https www
  return 301 https://www.yourdomain.com$request_uri;
}

server {

  listen [::]:443 ssl http2;
  listen 443 ssl http2;

  server_name www.yourdomain.com;

  # SSL code
  # other code
}
and to redirect all HTTP and HTTPS WWW traffic to HTTPS NON-WWW, use the following code:
server {
  listen [::]:80;
  listen 80

  server_name yourdomain.com www.yourdomain.com;

  # redirect http to https non-www
  return 301 https://yourdomain.com$request_uri;
}

server {
  listen [::]:443 ssl http2;
  listen 443 ssl http2;

  server_name www.yourdomain.com;

  # SSL code

  # redirect https non-www to https www
  return 301 https://yourdomain.com$request_uri;
}

server {

listen [::]:443 ssl http2;
listen 443 ssl http2;

  server_name yourdomain.com;

  # SSL code
  # Other code
}

Don’t forget to replace ‘yourdomain.com’ with your actual domain name.

Sunday, 16 June 2019

Correct way to add translations to Odoo through .po files

Correct way to add translations to Odoo through .po files

Follow below steps:
1) Go to
Settings ‣ Translations ‣ Import / Export ‣ Export Translations
leave the language to the default (new language/empty template) # DO NOT CHANGE THIS
select the PO File format
select your module
click Export and download the file
2) Add your translation terms in the downloaded file. i.e. msgstr "" section depending on your translation language
3) change the filename to language_iso_code.po
e.g. for portugese => pt.po
4) create i18n folder under your module and add po file in it.
5) restart Odoo
6) Go to:
Settings ‣ Translations ‣ Load a Translation
select translation language (in my eg. Portugese)
make sure you check this : Overwrite Existing Terms
click LOAD.

***********


Done 

Monday, 6 May 2019

Example: API to send teachers data from odoo

Example: API to send teachers data from odoo:

# -*- coding: utf-8 -*-
from odoo.tools.translate import _
from odoo import http
from odoo.http import request
import json
import sys

class odoo_public_data(http.Controller):
    @http.route('/get/teachers', type='http', methods=['GET'], auth="public")

    def get_teachers(self, **kwargs):
        teacher_model = request.env['dps.teacher']
        teacher_ids = teacher_model.sudo().search([])
        teacher_list = {'status': 1, 'data': []}
        try:
            if teacher_ids:
                for teacher in teacher_ids:
                    vals = {
                        'id': teacher.id,
                        'name': teacher.name,
                        'email': teacher.email,
                        'phone': teacher.phone,
                        'school': teacher.partner_id.name,
                    }
                    teacher_list['data'].append(vals)
            return json.dumps(teacher_list)
        except Exception as e:
            print str(e)
            return json.dumps({'status': 0, 'data': 'Some problem with API'})

Introduction to Odoo (Formerly Open ERP)



History

Odoo also known as Open ERP was founded by Fabien Pinckaers who is the founder and current CEO of Odoo. In 2005, he started to develop his first software product, TinyERP. Three years later, the name was changed to OpenERP. The company started to evolve quickly.
 In 2014, OpenERP moved beyond the boundaries of traditional ERP players and the company was renamed Odoo, a name without restrictions, to allow the company to grow in whichever direction

What is Odoo?

The word Odoo is the acronym of On Demand Open Object. 

Odoo 12e homepage.png

Odoo is a large collection of business-related applications and modules like CRM, Sales management, E-commerce, Warehouse management, Purchase management, Accounting suit, Manufacturing management, HRMS etc. 
All these basic modules collectively called as Enterprise Resource Planning software. 

The prime benefit of Odoo is its extensible architecture. A large number of freelancers and organizations develop Odoo Apps or Modules and place them in the marketplace for sale or to be downloaded for free. 
The main Odoo components are the OpenObject[5] framework, about 30 core modules (also called official modules) and more than 5000 community modules. Most Odoo modules are available in Odoo S.A's marketplace where community could buy or download many modules for free.  15759 Apps or modules were found on the marketplace in different categories. Most modules 
are served in all active versions of 9.0, 10.0, 11.0 and 12. 

Odoo has website builder that lets users generate websites and handle online operations. It’s integrated with an e-commerce platform and helps online shops to carry out plenty of tasks. 


Odoo Web Controller have been equipped with strong facility that it can create frontend modules (functionalities like a website, website sale, website blog etc. With the help of these modules, we can create website pages with both static and dynamic contents) to integrate with backend modules. 


Software & architecture 

Odoo uses Python scripting and PostgreSQL database. The software is accessed via a web browser in a one-page app developed in JavaScript. The Community edition repository is on GitHub. 

There are two versions available for your business needs.  
They are: 
  1. 1. Community Version:   
The Community version is the open source version. 

  1. 2. Enterprise Version: 
An enterprise version supplements the Community edition with commercial features and services. 


Why Odoo is more popular? 
  • It is open source 
  • Flexible 
  • Scalable 
  • Custom Ready-made Apps 
  • Global Support 
  • Proven Product 
  • User-Friendly 
  • Up to date with Technology 
  • Highly Modular 
  • Easily Integrate with Third-party services 
  • Industry-Specific Modules 
  • Less Implementation Cost 
  • Less implementation Time Frame. 

Page Break 

Odoo implementation: 

There are two type professionals who can perform Odoo implementation services. 

1. Odoo ERP Developer 

2. Odoo ERP Techno functionalist. 

A well experienced Odoo consultant can sketch the entire business diagram. They can provide the chart of application that must be installed and other customization requirements. 

An Odoo developer can enhance/customize the existing source code as per the consultant's suggestions. 

Odoo can be implemented in two ways. Either you can host it on any server (preferably Linux based) or you can use it locally. It depends on the user needs. In both cases. 

Why to choose Odoo ?

  • Comprehensive  
  • Modular 
  • Lower Total Cost of Ownership (TCO) 
  • Consolidation Strategy 
  • Configurable and Customizable 
  • Updated Technology 
  • No Lock-in   

Most of the countries are started using Odoo.



Vendor support 

The three last LTS versions are supported in parallel. This means that when a new LTS version is released, an older version reaches its end-of-life and is not supported any more. As an example, 10.0 LTS will be supported along with 11.0 LTS and 12.0 LTS, but it will reach end-of-life when 13.0 LTS is released.