![](/images/ajax-loade.gif)
Featured
-
Function calling on button click in OpenERP
Adding a button on an OpenERP view is very easy an
by dinesh.singh
Tags
How to set the useful remarks in Odoo?
In odoo useful remarks have three useful step-
1- Twitter Bootstrap and FontAwesome classes can be used in your report template
2- Local CSS can be put directly in the template
3- Global CSS can be inserted in the mai...
Barcodes in Odoo
Barcodes are images returned by a controller and can easily be embedded in reports thanks to the QWeb syntax:
<img t-att-src="'/report/barcode/QR/%s' % 'My text in qr code'">
If you want more parameters can be passed as a query stri...
How to make minimal template in Odoo ?
In minimal template you can call the translatable document from your main template with the attribute t-lang set to a language code or to a record field.
You also need to re-browse the related records with the proper context if you use fields t...
How to provided external identifier in test module in OpenERP/Odoo ?
In Odoo-9 by default, tests are run once right after the corresponding module has been installed. Test cases can also be configured to run after all modules have been installed, and not run right after the module installation.For example code is ...
How to make report template in Odoo ?
There are some specific variables accessible to make template reports.
1. docs : records for the current report
2. doc_ids : list of ids for the docs records
3. doc_model : model for the docs records
4. time : a reference to time from the Pyt...
Report in OpenERP/Odoo
In Odoo-9 reports are written in HTML/QWeb, like all regular views in Odoo. You can use the usual QWeb control flow tools. The PDF rendering itself is performed by pdf.For example code is below.
report
id="account_invoices"
model="ac...
Consume product with specific quantity from specific source location in openerp
The quantity from specific source location with Consumed product and param product_qty means that Consumed product quantity and param location_id is Source location and returns Consumed lines in this function. Use the below function in .py file
...
How to Override of the base.stage method in project module in openerp
To Override the base.stage method in project module and Parameter of the stage search taken from the lead and also section_id if set, stages must belong to this section or be a default stage; if not set, stages must be default stages in project m...
How to retrieve all children projects of project ids in openerp
TO retrieve all children projects of project ids in project module and return a dictionary mapping each project to appiar its parent.id in parent project in project module (or None)in openerp. use this code given below in .py file in openerp.
...
Benefits of testing module in OpenERP/Odoo
Odoo provides support for testing modules using unittest.
To write tests, simply define a tests sub-package in your module, it will be automatically inspected for test modules. Test modules should have a name starting with test_ and should be im...
How to define workflow transition rules in OpenERP/Odoo ?
Workflow transitions can be restricted to a specific group. Users outside the group can not trigger the transition.For example code is like below..
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<re...
How to set Default option methods in openerp
Options apply standard CSS classes to the snippet. Depending on the method that you choose, the UI will behave differently.
data-select_class=" class name "
More data-select_class in the same group defines a list of classes that the user ...
How to define Access Control in OpenERP/Odoo ?
Access control has a model to which it grants permissions, the permissions it grants and optionally a group.
Access controls are additive, for a given model a user has access all permissions granted to any of its groups:
if the user belongs to...
get_encodings, ustr and exception_to_unicode were originally from tools.misc in openerp
Set encoding to default and find value to get_encodings, ustr and exception_to_unicode were originally from tools.misc in openerp and use this method in openerp. Use this code in .py file in openerp
ef get_encodings(hint_encoding='utf-8'):
...
How to called except block to allow converting exceptions to arbitrary
To Called within an except block to allow converting exceptions to arbitrary responses. Anything returned (except None) will be used as response. use this code given below in openerp.
def _handle_exception(self, exception):
"""Called ...
How to implement translations system in OpenERP/Odoo ?
The procedure to translate text in Python and JavaScript code is very similar. You could have noticed these lines at the beginning of the petstore.js file.
var _t = instance.web_t,
_lt = instance.web_lt;
These lines are simply used to ...
How to set inspection and introspection in OpenERP/Odoo ?
Odoo stores most model metadata inside a few meta-models which allow both querying the system and altering models and fields on the fly over XML-RPC.
For example code like below.
models.execute _kw(db, uid, password, 'ir.model', 'create', [{
...
How to make workflow manipulations in OpenERP/Odoo ?
Workflows can be moved along by sending them signals. Instead of using the top-level execute_kw, signals are sent using exec_workflow. For example code is like below.
client = models.execute_kw(
db, uid, password,
'res.partner', 'sea...
How to create more Action in OpenERP(Odoo)
Actions are used to trigger one or more actions to be performed on the server side, when a specific stage of a workflow is reached. To write this code in .xml file in openerp(odoo), use the Code given below.
<record id="company_normal_actio...
ir.model.fields in OpenERP/Odoo ?
ir.model.fields provides information about the fields of Odoo models and allows adding custom fields without using Python code.
model_id: Many2one to ir.model to which the field belongs
name: the field's technical name (used in read or write)
...
ir.model in OpenERP/Odoo ?
ir.model provides information about Odoo models via its various fields. such as
name : a human-readable description of the model
model : the name of each model in the system
state : whether the model was generated in Python code (base) or by c...
How to delete records in OpenERP/Odoo ?
Records can be deleted in bulk by providing their ids to unlink().
For example code like below.
models.execute_kw(db, uid, password, 'res.partner', 'unlink', [[id]])
check if the deleted record is still in the database
models.execute_kw(db, ...
How to update records in OpenERP/Odoo ?
In update records can be updated using write(), it takes a list of records to update and a mapping of updated fields to values similar to create() .for example code is like below.
models.execute_kw(db, uid, password, 'res.partner', 'write', [[...
How to read records in OpenERP/Odoo ?
In record data is accessible via the read() method, which takes a list of ids (as returned by search()) and optionally a list of fields to fetch.
ids = models.execute_kw(db, uid, password,
'res.partner', 'search',
[[['is_company', '=...
How to get count records in OpenERP/Odoo ?
In count records retrieve a list of records and count them, search_count() can be used to retrieve only the number of records matching the query. It takes the same domain filter as search() and no other parameter.For example code is like below.
...
How to get the current Cordinate in OpenERP/Odoo ?
For current cordinate we have to add a button resetting the product's coordinates to the location of the user, you can get these coordinates using the javascript geolocation API.
Now we would like to display an additional button to automatically...
How to show the cordinates on Google Map in OpenERP/Odoo ?
To Add two fields to product for storing a latitude and a longitude, then for this you have to create a new form widget to display the latitude and longitude of a product's origin on a map.
Displaying the two position fields and a map widget usi...
How to Create a transit location with company_id in odoo-9
To Create a transit location with company_id being the given company_id. This is needed in case of resupply routes between warehouses belonging to the same company, because we don't want to create accounting entries at that time. For this use thi...
How to create a color field in OpenERP/Odoo ?
To create a Field Color class, the value of this field should be a string containing a color code like those used in CSS. This color field should display in block whose color corresponds to the value of the field. In read-write mode. For more see...
How to make read-write field in OpenERP/Odoo ?
In Read-only fields, which only display content and don't allow the user to modify it can be useful, but most fields in Odoo also allow editing.
In the write field the Abstract field class sets a widget property named effective_readonly. The fie...
How to create Account Analytic Line class to compute the line in odoo-9
To create Account Analytic Line to compute the line and inherit the class account_analytic_line in odoo-9 then write this function in .py file in your module in odoo.
Use this code show in given below
def _compute_accountanalytic(self, d...
How to use query() method in OpenERP/Odoo ?
Odoo web provides a helper for easy and clear questioning of models query() which functions as a shortcut for the usual combination of search() and read(). As shown in example code given below.
model.query(['name', 'login', 'user_email', 'si...
How to use compound context in OpenERP/Odoo ?
The context is like a "magic" argument that the web client will always give to the server when calling a method.
The context is a dictionary containing multiple keys. One of the most important key is the language of the user, used by the server ...
How to calls my_method() in OpenERP/Odoo ?
In below example a sample widget that calls my_method() and displays the result.
local.HomePage = instance.Widget.extend({
start: function() {
var self = this;
var model = new instance.web.Model("oepetstore.message_of_th...
How to communicate with the Odoo Server ?
Most operations with Odoo involve communicating with models implementing business concern, these models will then interact with some storage engine.
JQuery provides ajax function for network interactions, communicating with Odoo requires additio...
How to modify existing widgets and classes in OpenERP/Odoo ?
In the class system of the Odoo web framework allows direct modification of existing classes using the include() method.
This system is similar to the inheritance mechanism, except it will alter the target class in-place instead of creating a ne...
How to make Qweb template engine in OpenERP/Odoo ?
QWeb is an XML-based templating language, similar to Genshi, Thymeleaf or Facelets. It has the following characteristics:
It's implemented fully in JavaScript and rendered in the browser
Each template file (XML files) contains multiple template...
How to make your first widget in OpenERP/Odoo ?
The initial demonstration module already provides a basic widget:
For example code look like below.
local.HomePage = instance.Widget.extend({
start: function() {
console.log("pet store home page loaded");
},
});
It extend...
How we can use this._super() to call the original method in OpenERP/Odoo ?
If you want to use this._super() to call the original method in OpenERP/Odoo When overriding a method using inheritance below is the example.
For example code look like below.
say_hello: function () {
setTimeout(function () {
...
How to make Odoo javascript module in OpenERP/Odoo ?
Javascript does not have built-in modules. As a result variables defined in different files are all mashed together and may conflict. This has given rise to various module patterns used to build clean namespaces and limit risks of naming conflic...
How to make the simple module OpenERP/Odoo ?
In simple Odoo module holding basic web component configuration and letting us test the web framework.
The example module is available online and can be downloaded using the following command:
git clone http://github.com/odoo/petstore
If...
How to use initializer receives the parameters passed when using the new operator OpenERP/Odoo ?
If you use to initializer receives the parameters passed when using the new operator in OpenERP(Odoo) follow the below mentioned code and paste it in your .js file.
var MyClass = instance.web.Class.extend({
init: function(name) {
...
How to Create procurements based on quantity ordered in openerp-9
To Create procurements based on quantity ordered in openerp-9 If the quantity is increased and
new procurements are created then use this code given below in .py file
def _action_procurement_create(self):
precision = self.env['deci...
How to use instantiate classes using the new operator in OpenERP/Odoo ?
If you want to instantiate classes using the new operator in OpenERP(Odoo) follow the below mentioned code and paste it in your .js file.
var MyClass = instance.web.Class.extend({
say_hello: function() {
console.log("hello", this...
How to use classes in .js file in OpenERP/Odoo ?
In object-oriented languages, javascript does not build in classes although it provides equivalent (if lower-level mechanisms.
For simplicity and developer-friendliness Odoo web provides a class system based on John Resig's Simple JavaScript ...
How to Compute the quantity invoiced If case of a refund in openerp(odoo)-9
To Compute the quantity invoiced If case of a refund in openerp to Compute the quantity invoiced. If case of a refund, the quantity invoiced is decreased. Note that this is the case only if the refund is generated from and function given below t...
How to check product quantity in openerp
To check product quantity in openerp
You have to write this function in .py file to check product quantity in product module and relate his to
the inventory management. See code given below
def check_product_quantity(self, cr, uid, product,...
How to use destroying widgets in OpenERP/Odoo ?
If you display content to your users, you should also be able to erase it. This is done via the destroy() method.
greeting.destroy();
First thing you see on destruction of a widget is calling destroy() on all its children. Then comes remova...
How to use widget parents and Children in OpenERP/Odoo ?
If you want to widget parents and Children in OpenERP(Odoo) follow the below mentioned code and paste it in your wizard .js file:
local.HomePage = instance.Widget.extend({
start: function() {
var greeting = new local.GreetingsWi...
How to adding a class to their root elements in OpenERP/Odoo ?
If you want to adding a class to their root elements in OpenERP(Odoo) follow the below mentioned code and paste it in your wizard .js file:
local.HomePage = instance.Widget.extend({
className: 'oe_petstore_homepage',
...
});
local...