Create setup module for odoo and change company logo

This is first article about creating setup module for odoo.
You can create setup module for odoo and change company logo or add other customizations (module dependencies etc.).

There is no need for installing modules one by one and after that change company name, address, phone numbers, vat number, logo etc.

Please refer the following link to learn about creating a module in Odoo 8:

https://www.odoo.com/documentation/8.0/howtos/backend.html#build-an-odoo-module

With this code you can change company logo:

# -*- coding: utf-8 -*-
import openerp
from openerp.osv import osv
from openerp import tools
import os
from openerp.tools import image_resize_image
class res_company(osv.osv):
 _inherit="res.company"
 _name="res.company"
 
 def init(self, cr):
   img=open(os.path.join(os.path.dirname(__file__), 'static', 'src', 'img','logo.png'), 'rb') .read().encode('base64')
   cr.execute('UPDATE res_partner SET image=%s WHERE is_company=TRUE', (img,))
   size = (180, None)
   cr.execute('UPDATE res_company SET logo_web=%s', (image_resize_image(img, size),))

1.) Inherit from res.company
2.) Update default image in res_partner and res_company tables

Place your logo in static\src\img folder

Complete module is available for download from github:

Create setup module for odoo and change company logo

https://github.com/netjunky-hub/company_setup

Related articles:

http://netjunky.net/create-setup-module-for-odoo-and-change-company-info/

More soon…

 

Backup odoo 8 database automatically

Great tool if you need to backup odoo 8 database periodically.
Work as odoo module.
Take automated back-ups, remove them automatically and even write them to an external server through an encrypted tunnel. You can even specify how long local backups and external backups should be kept, automatically.

Write your backups to an external server. Specify the credentials to the server, specify a path and everything will be backed up automatically. This is done through an SSH (encrypted) tunnel, thanks to pysftp, so your data is safe!

Module can send E-mail on backup failure.

backup odoo

 

You can download and try module from odoo apps:
https://www.odoo.com/apps/modules/8.0/auto_backup/

Requirement is pysftp package.
To install package run:

sudo pip install pysftp