Creating custom reports in Odoo 8

Hi guys

In this tutorial you will learn how to create a new QWeb report from scratch.
During this tutorial I will create a second invoice report, but this time without prices. Some companies do not want to show prices per record for example, so I’ll take this as a sample.

1. Creating a new XML file

The first step to create your own new report is to make a new XML file. This file should be placed under yourModuleName/views and you can name it as you wish. In this tutorial I will create a new invoice that is made in the module account.
I’ve named the file report_without_prices.xml as you can see here:
View structure

In this file you will define the template id’s and names, which will later on be used by your Odoo to find the correct report.
The minimal code looks like this:

So, what is important about this? The name of the template id (from the first record) should be the same as the name for the t-raw that handles translations. In the t-raw you need to add the module name before this name with a dot. Here’s an image to make things more clear:
Code structure
The second template_id then needs to be identical to the name that you will set in the next file. So let us continue.

2.Add the report to the XML file responsible for reports

This brings us to part 2. Every module has a file that makes a reference to every single report in the module. This is done by a item, which can be found in the XML file.
This file always has the same name structure. It starts with the name of your module, an underscore and then report.xml. Its found in the first level of the directory of your module, as you can see here:
XML file for reports
The filename is always yourModuleName_report.xml. Now open up this file and you will see a tag for every report that exists in this module.
The next step for us is to add a new tag for our own report. The code looks like this:

Now that you’ve added this code you’re almost there! The last step is to notify Odoo of the new report.

3. Notify Odoo from the new report

So how do we tell Odoo there is a new report? In every module is a file named __openerp__.py. This file is used to import (include) all files in a module.
As all files are loaded in here we should also add our new XML file in this list. Without this Odoo will not find or use the XML file which will result in a not working report and errors.
Add a new line to the __openerp__.py file, right under ‘data’:[

4. Wrapping things up

Now that you’ve made a new report (a new XML file),added the template id to the moduleName_report.xml file and added your XML file to __openerp__.py you’re done!
The last thing you need to do is reload your module (by command or by a module update) and you’ll see the new report showing up.
If you then look under accounting > Customer Invoices and make a new invoice you will see your new print option:
Print option custom report

And, finally, if you print it out you’ll get your custom report!
Custom report lay-out

NOTE:If you want a more advanced code, which shows a full report without the prices just paste this code in reports_without_prices.xml

Looking for more information about reports?
Check out the official documentation




Odoo Experts

Change invoice numbering in Odoo 8

Today’s tutorial will explain you how to easily change both the name and the numbering for an invoice.

1. Go to Settings > Configuration > Accounting.
You’ll get a view that looks like this:
Default accounting setup

2. Now edit the ‘Next Invoice number’ and ‘Next credit note number’ to your likings.
If you want for example a custom name in front of it you can do name/(%year)s/ this will give you the invoice name name/2014/
The second field is your sequence, this means from where on you want to start your numbering. If you want to start it from 100 you set it to 100. You can do exactly the same for your credit note number, or give it another name.
For example:
New settings

3. Now make a new invoice and save it. You’ll see the name has changed!
Custom name invoice

Tip: do you want to go further and also modify the number steps etc? Go to settings > Sequences & Identifiers > Sequences and open the record ‘Sales Order’.
Enjoy!

Odoo Experts

Remove Odoo Support from Odoo chat

Today I’ll learn you how to remove the ‘Odoo Support’ user from the Odoo chat. Most of us do not want this to show up in our list of people to chat with and especially not when you’re selling Odoo to customers.
Originally in Odoo you will get this:

So how do you remove this user?
1. Go to your addons folder and search for the addon im_odoo_support. Open this folder up, you’ll now see this structure:

2. Open up the folder views and then open the XML file im_odoo_support.xml. In this file you can directly see that there is a function and it looks to Odoo Support. So go ahead and comment this block out, like this:

2. Go to im_odoo_support/static/src/xml/ and open the file im_odoo_support.xml. You’ll see an li class here for Odoo Support too. Comment it out like this:

3. Now restart your Odoo server and update your module. You can do it with this command:
./odoo.py -u im_odoo_support
4. Open Odoo in your browser and you’ll see there is no more ‘Odoo Support’ user in the list!

Odoo Experts