How to create Qweb report in odoo

Hello All,

         I would like to share with you how to create a Qweb report in odoo [OpenERP].let we go stap by stap to create Qweb report in odoo [OpenERP].

What is Qweb Report ??

Qweb Report is the newest version of the Odoo reporting Format and its uses the bootstrap css classes and Qweb Template Engine for Make Quick Report Design in Odoo.

About Bootstrap :

Bootstrap is a free collection of tools for creating websites and web applications.It contains HTML and CSS-based design templates for typography, forms, buttons, navigation and other interface components, as well as optional JavaScript extensions

Expressions used in Odoo report templates :

There are some magic variables used in the report rendering. The main ones are the following:
docs
        records for the current report
doc_ids
        list of ids for the docs records
doc_model
       model for the docs records
time
       a reference to time from the Python standard library

translate_doc 
 
a function to translate a part of a report. It must be used as follow:
<t t-foreach="doc_ids" t-as="doc_id">
<t t-raw="translate_doc(doc_id, doc_model, 'partner_id.lang', account.report_invoice_document')"/>
</t>
user
     res.user record for the user printing the report
res_company
      record the current user‘s company

Custom Report

A generic report use the default rendering context, containing the magic variables as explained before. If you want a new rendering context containing anything you want to process your data Odoo AbstractModel, a custom module is needed. These reports are called “particular report”.

For a particular report, you have to write an Odoo Model containing a render_html method. Classically, this method returns a call to the original QWeb render with a custom rendering context.


from openerp import api, models

class ParticularReport(models.AbstractModel):
_name = 'report.<<module.reportname>>'
@api.multi
def render_html(self, data=None):
report_obj = self.env['report']
report = report_obj._get_report_from_name('<<module.reportname>>')
docargs = {
'doc_ids': ids,
'doc_model': report.model,
'docs': self.env[report.model].browse(ids),
}
return report_obj.render('<<module.reportname>>', docargs)



Create Report  in Qweb odoo [OpenERP]

Steps to create in Following Ways ::

STEP 1 ::

Create View File For Rendring the Qweb in Odoo
the view file it self uses the the Bootstrap classes for designing the Qweb Report.

Create custom module in odoo and then  Navigate

YOUR MODULE NAME/View/yourview_file.xml

And also add the Entry of xml in the __openerp__.py file

STEP 2 ::

Create Python class for report in report Dir

import time
from openerp.report import report_sxw
from openerp.osv import osv

class your_class_name(report_sxw.rml_parse):

def get_lines(self, user,objects):
lines=[]
for obj in objects:
if user.id==obj.user_id.id:
lines.append(obj)
return lines

What ever function Which You want to access in the Qweb Template which are define in the class

We must have to add the Entry in it constructor like this

def __init__(self, cr, uid, name, context):
super(your_class_name, self).__init__(cr, uid, name, context)
self.net_total=0.0
self.localcontext.update({
'time': time,
'get_lines': self.get_lines,

Add the Entry For the report class which is inherited the osv.AbstractModel object

class report_your_class_name(osv.AbstractModel):
_name = 'report.Your_Module_name.report_reportname'
_inherit = 'report.abstract_report'
_template = 'Your_Module_name.report_reportname'
_wrapped_report_class =your_class_name

Navigate :

YOUR MODULE NAME/report/reportclass.py

And also add the Entry in the __init__.py file


STEP 3 ::

Add the Menu Action for Print The Report
YOUR MODULE NAME/report_file.xml

<report
id="action_report_report_id"
string="String to Display in Menu"
model="your_model"
report_type="qweb-pdf"
name="your_module_name.report_your_reportid"
file="your_module_name.report_yourreportid"
/>
And also add the Entry of xml in the __openerp__.py file


Special function ::

Hear In odoo use the special widget for print the currency symbol,
add the company address,partner address and many more

like this..

<div class="row">
<div class="col-xs-5 col-xs-offset-7">
<address t-field="o.partner_id"
t-field-options='{"widget": "contact", "fields": ["address", "name"], "no_marker": true}' />
<span t-field="o.partner_id.vat"/>
</div>
</div>
hear t-field-options attribute use the widget to print the partner detail in Odoo
like name,address,street,country etc... 

Same things for the currency symbol

<td class="text-right">
<span t-field="o.amount_untaxed" t-field-options='{"widget": "monetary", "display_currency": "o.currency_id"}'/>
</td>


Thanks,
Mayur Maheshwari (OpenERP/odoo)
Skype: mayur_maheshwari1


How to run query on database from pgAdmin and terminal - OpenERP (Odoo)

Hello,

I would like to share how to run query on database from pgAdmin and terminal. - OpenERP (Odoo) .This was too easy to do but this post is specially for beginner in query.





Hope that was helpful.


If I just made your day a little better then thank me with a coffee or maybe a  pizza

What is product and How to configure product in OpenERP


Hello Friends,

Today we will discuss about the product and how to configure product in OpenERP.

Product module in OpenERP


What is product :

    A product is the item offered for sale. A product can be a service or an item. It can be physical or in virtual form.In short it will offered and serves the basic business needs like sales, purchase, manufacture and services.

    We can also say product is key of ERP. To unlock the erp with the key of product we should know about the product and how to configure product If product is not properly configured then it will creates so many issue and ERP flow is break down.

Product kanban View in OpenERP


How to configure product in OpenERP :

    In OpenERP Product Form, There are three fields are important for stock management when you are configuring a new product
 
    Product Type
    Procurement Method
    Supply Method

1] Product Type :
            The Product Type determines how the product will be managed in stock management.
In OpenERP three distinct product types are:

 (a) Stockable Product : This product is used in stock management and it will demanded in stock less or more based on it's defined reordering rule [minimum stock rule] in the system. Examples:- Computer, shoes, beg
 
 (b) Consumable : This product is not used in stock management. once you receive it and delivery it because this type of product stock is not maintain in the system . it just like a stock of some time of duration. Examples:- Fruit, Milk, Food ...

 (c) Service : This product is not used in stock management. This type of product will configure when your company is providing any type of services. Examples:- Man Power, a consulting service.


2] Procurement Method :
            The procurement method determines how the product will be replenished.
   In OpenERP two distinct procurement method are:
 
   (a) Make to Stock : when stock is needed then the product will take from the stock, If the quantities in stock is too low to fulfill the order then it will set a quantity based on the reordering rule [minimum stock rule] in Procurement and generate purchase or manufacturing order [depends on supply method] to meet the needs of product
 
   (b) Make to Order : when sale order is confirmed, it will not check the stock level and immediately it will generate the purchase or manufacturing order [depends on supply method] with the same quantity of ordered.


3] Supply Method :
            The supply method determines the purpose of the product either it will be buy or produce.
   In OpenERP two distinct supply method are:
 
  (a) Produce : when the product is manufactured or the service is supplied from internal resources.
         
  (b) Buy : when the product is bought from a supplier


Hope that was helpful.

If I just made your day a little better then thank me with a coffee or maybe a  pizza


Cheers ENJOY OpenERP  !!
Thanks,

Mayur Maheshwari


Eclips xml template for OpenERP 7.0


Hello,

     OpenERP 7.0 basically brings about huge improvements in the area of usability. By usability we mean a better user experience through a better user interface. We know that in OpenERP, the user interface is designed via XML. OpenERP 7.0 has introduced some new features in XML.

Here I have made a very good Eclipse XML templates which may prove useful to OpenERP developers as well as beginners. These templates will provide a fast and easy method of coding in XML. Now no need to remember all syntax of XML,  just play with these Eclipse snippets!






To get Eclipse XML templates can contact me :
mail : mayurmaheshwari07@gmail.com
Thanks,

Mayur Maheshwari


Audit Trail in OpenERP - (Odoo)

In business there are number of users. It is tedious task for administrator to track all user's activity. Here OpenERP (Odoo) brings good feature to track user activity on any model. It means user perform any action [like create, modify, delete] on any model that all performed action can see administrator by logs. This feature is introduced in Audit Trail module

Audit Trail allows you to log every user operation on all system models. (such as sales, leads or products)

Required module: - Audittrail

First you just need to install the Audit Trail module in OpenERP (Odoo). After installing it, you will see in the Reporting menu an Audit menu item


Install Audit Trail Module


To track user activity you need to create audit rule. Audit rules are specified on a particular model that you want and assign user that you want to track that activity. The rules tell the system which activities performed by the user need to be logged.

How to create an audit rule :-


Navigate to : Reporting/Audit/Audit Rules

  
For example: - I have created a rule for sale order model to track activity of sale_user

Create an audit rule

   
To activate the audit rule you need to first 'Subscribe' to the audit rule.


Subscribe audit rule


To test this, login with sale_user, make changes to any in sale order. I have just created a sale order to show logs.


Create sale order to check audit logs


Now login with administrator. To see the logs of the activities performed on the sale order model by sale_user :-


Navigate to : Reporting/Audit/Audit Logs



Audit logs

You will see a list of the changes made to the sale order model. Click on logs to see the changes sale_user made to the sale order. You can also check old values and new values for comparison.

You can track every user operation on all the objects of the system. [
operation such as: create, modify, delete]    



Cheers Enjoy OpenERP (Odoo)    :)
Thanks,

Mayur Maheshwari 

  Skype : mayur_maheshwari1

How to add custom field on any object in OpenERP - Odoo



How to add custom field on any object in OpenERP (Odoo) without doing any hardcode!!

Say for example we need a field “Weight” on Vehicle.

Step 1: Activate Developers Mode.

a) To do that click on user name at the right upper corner of your screen and select About OpenERP (Odoo) option.

Add custom field in OpenERP

Activate Developer Mode

 
b) You will get window as shown in image below. Click on the link Activate the developer mode.

Add custom field in OpenERP


Activate Developer Mode

c) We will get a debug view From where we can edit all views of selected object.

Add custom field in OpenERP

Debug View


Step 2: Identify your object

To do that just hover your mouse on any of the field. It will show you some information like field name, object, field type etc.

Add custom field in OpenERP

Field information

As we know now that our object name is 'fleet.vehicle' and we have to add a new field to this object say for example 'weight', type of this field is integer. Let's edit our object. Here one thing is to notice that these changes are for the existing database only, it will not reflect in other database.

a) Go to the menu Settings → Techniacl → Database Structure → Models and search for fleet.vehicle

Add custom field in OpenERP

Object Search

b) Open that object and click on edit, drag the mouse to reach bottom of the page and click on Add an item link.

Add custom field in OpenERP

Object View


c) Add all detail like field name, label, type then click on 'Save & Close' button and finally click on Save button which is in Red color.

Add custom field in OpenERP

Add new field

As a field x_weight is added to our object fleet.vehicle we will now edit different views of vehicle to see the changes.

Step 3: Edit View(Form, tree)

a) Before editing excising views lets observe our current view.
Open Vehicle form view and see there is not any field with label “Weight” on it.

Add custom field in OpenERP

Vehicle's form view without any Change


b) Select the option Edit Form View from Debug View window.

Add custom field in OpenERP


Edit Form View

c) You will get a window as below. Insert the new field to appropriate position, and click on save button.

Add custom field in OpenERP

Insert new field

d) Close the window and reload the page. Here we can notice that a new field is on vehicle form view. Same way we can edit search, tree view.

Add custom field in OpenERP


Vehicle's form view with a new weight field 



Cheers ENJOY OpenERP / ODOO  !! 

Hope that was helpful.

If I just made your day a little better then thank me with a coffee or maybe a pizza


Thanks,

Mayur Maheshwari( Odoo Developer)

What's app : +91 99245 42042
Mail : mayurmaheshwari07@gmail.com


Configure Thunderbird plugin in OpenERP - Odoo


This article describes how to configure Thunderbird plugin in OpenERP (Odoo). OpenERP (Odoo )Thunderbird plug-in provides integration which allows you communicate and co-ordained with CRM data and shared across the company.user can work with OpenERP (Odoo) from their email client with this integration

This will not only simplify the work and save time but also provides the user a lot of options without the dire need to switch between applications.

This plug-in add many features to OpenERP (Odoo) such as

    1)   Create a contact or partner from an e-mail,
    2)  Create record/document in OpenERP (Odoo),
    3)  Send any attachment to an OpenERP (Odoo) document (such as proposals,proof of payment, order receipts, employee CV or annual appraisal).

It works for the EXCHANGE SERVER MAILS too!!

Require module : Thunderbird Plug-In
   
step 1: How to Install Thunderbird plugin-in openerp (Odoo).

 
Navigate settings/apps and search Thunderbird Plug-In and install it.


Install Thunderbird plugin


step 2: How to download Thunderbird plugin file from openerp (Odoo)

Navigate  sales/configuration/Thunderbird plug-in 
menu. 
It will open a wizard. Now download plugin /addons/plugin_thunderbird/static/openerp_plugin.xpi. you can save this plugin file to your desktop or any other location on your computer.


Download Thunderbird plugin xpi


Step 3: How to Install OpenERP (Odoo) extension (plugin) in Thunderbird.

    First of all, To do this process use the file "openerp_plugin.xpi" that you saved on your desktop.


Then follow this simple step :
1.  From Thunderbird, open the menu => Tools => Add-ons.
2.  Click Extensions,  beside the search addons there is a button Tool For All add-on click on it
3.  Go to your desktop and select that file openerp_plugin.xpi. Install it
4.  Once the openerp_plugin.xpi is installed then restart Thunderbird.

Now check menu of Thunderbird you find new OpenERP menu item is added in your Thunderbird menu bar.

A)  How to Connect openerp (Odoo) Server with use of Thunderbird plugin.

Navigate to OpenERP/Configuration menu item and click it.
A configuration window appears enabling you to enter configuration data about your OpenERP (Odoo) server.


   server   : 127.0.0.1:8069 (type your server settings and xml-rpc port)
   database : Select the database you want to connect
   user name : provide user name
   password : provide password (****)



Connect OpenERP server
 


Click the Connect button to test the connection.If given parameters are right the it will connect to the OpenERP (Odoo) Database.After that Thunderbird will ready to fit your needs. ;)

B)  How to  Create a New Partner/Link with Partner in Thunderbird

If you cannot find a partner for your e-mail in OpenERP (Odoo), the Thunderbird plugin allows you to create new partner or link with existing partner simply by using the information contained in the e-mail.

First of all, You have to select the mail from which you want to create a new contact

Navigate OpenERP/contact menu
A contact window appears which allows you to enter name, email for create new partner and link with existing partner.


Create Partner via Thunderbird in OpenERP

    click create partner button so it will create new partner in OpenERP (Odoo) or you can create a partner with the existing partner linked to it.when you click create Partner, It will redirect the Partner form in OpenERP (Odoo) according to the name and e-mail partner will create.If partner is already cretaed then it will directly open that partner form.
  
C) How to  Create a Document in Thunderbird

Navigate OpenERP/Document 
A document window appears which allows you to create the document in OpenERP directly from your e-mail.


Create Document via Thunderbird in OpenERP

Suppose you would like to create a new lead from an e-mail.open document window click create document 


Create lead via Thunderbird in OpenERP

so it will ask type of document then select lead/Opportunity in selection and click on push button. A new lead will be created in OpenERP (Odoo) from the selected e-mail.you will redirect to that page once you create a lead.

3) How to Send any attachment/email to an OpenERP (Odoo) document

As same way you can also push email to particular OpenERP (Odoo) document 


Attach Document via Thunderbird in OpenERP

suppose you would like to push your email to phone call. open document window and click push email so it will ask for type of document where you want to push. select phone call , search phone call record , Now select your record where you want to push and click on push. it will pushed to that record.

Note : If the document is already created ! 
       It shows the "SUBJECT OF THAT SELECTED MAIL " message on the dialog.
       That meas that mail in already pushed in openerp (Odoo) database.

       IN THIS CASE IT SHOWS ONE MORE BUTTON "Open Document



Configure Thunderbird plugin in  OpenERP (Odoo) : --




Cheers Enjoy OpenERP (Odoo)   :)

Thanks,

Mayur Maheshwari 

Skype : mayur_maheshwari1