Wednesday, 14 June 2017

Odoo 10: Close wizard and open standard form

Hi, Today we are going to learn how to open standard form after saving data in wizard.

Let's say I have created an wizard to fill basic User details and once saved open default User form. Here is the xml code for my wizrd:

<record id="view_custom_user_wizard" model="ir.ui.view">
        <field name="name">Create User</field>
        <field name="model">res.users</field>
        <field name="arch" type="xml">
            <form string="Create User">
            <field name="company_id" />
            <field name="name" required="1"/>
            <field name="login" required="1"/>
            <field name="password" required="1" password="True" />
                        <button name="create_user" string="Create User" type="object" class="btn-primary"/>

And here is the python code for "create_user" function:

def create_user(self):
    # We need to get view_id where we are going the user to redirect
    self._cr.execute("select res_id from ir_model_data where name = 'view_users_form'")
    result = self._cr.fetchone()
    form_obj_id = result[0]
    return {
        'name': _('User'),
        'view_type': 'form',
        'view_mode': 'form',
        'view_id': form_obj_id,
        'res_model': 'res.users',
        'domain': [],
        'context': dict(self._context, active_ids=self.ids),
        'type': 'ir.actions.act_window',
        'target': 'current',
        'res_id':, #represents user id


That's it!!!

Thanks!!!!!!!! Enjoy Programming!! :)

Tuesday, 6 June 2017

Odoo: Download Binary File in v10

To download any binary file in Odoo10 following is the link:<module_name>&field=<field_name>&filename_field=<field_filename>&id=<object_id>

module_name   - the name of the model with the Binary field
field_name        - the name of the Binary field
object_id           - id of the record containing particular file.
field_filename   - name of a Char field containing file's name (optional).

So if you want to call a function on button click and download the file, code is as follow:

file_url = "<module_name>&field=<field_name>&filename_field=<field_filename>&id=<object_id>"
return {
    'type': 'ir.actions.act_url',
    'url': file_url,
    'target': 'new'

In Reports or web page, you can use it as:

<t t-foreach="files" t-as="f">
        <td><t t-esc=""/></td>
        <td><a t-attf-href="/web/content?model=<module_name>&field=<field_name>&filename_field=<field_filename>&id=<object_id>">Download</a></td>

Where files is a list of files

Thanks!!!!!!!!! Enjoy Programming!! :)

Emails not working in PHP/Ubuntu

Hi, lot of solutions are there to fix this problem but I feel somewhere, sometimes we miss the basic part...

It may be possibility that we don't have sendemail utility itself not installed. Please install by running following command.

sudo apt-get install sendmail -y

If issue is still there please check following link:

Thanks!!!! Enjoy Programming :)

Thursday, 1 June 2017

Odoo: Set/use context in email templates

Today we are going to discuss, how to use/change context in dynamic/custom templates.

Let's say we want to send some values to email template other than normal object id, here is the code for that

In controllers/

local_context = request.env.context.copy()

in file

local_context = self.env.context.copy()
    'name': 'Shiv',
    'place': 'Bangalore'

template = request.env.ref('module_name.email_template_id')
            template.with_context(local_context).send_mail(, force_send=True, raise_exception=True)

In email template code you can access context as:


That's it.

Thanks!!! Enjoy Programming!!! :)

To know how to create custom email template, please check here:

Gmail: Download blocked file

Hi, today we are going to learn, how to download blocked file in gmail. Sometimes you see following message in gmail: and you can...