Skip to content

Instantly share code, notes, and snippets.

@sehrishnaz
sehrishnaz / odoo_xmlrpc.py
Last active February 17, 2020 06:30
Connecting to odoo using XML-RPC
import xmlrpclib
from openerp.exceptions import except_orm
url = "http://localhost:8009"
db = "your_db_name"
user = "abc@gmail.com"
pwd = "1234"
url = 'http://localhost:8069' or ''
try:
@sehrishnaz
sehrishnaz / odoo_scheduled_action.xml
Created May 8, 2020 05:01
Scheduled Actions In Odoo | Scheduler in Odoo
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="your_scheduler_action_id" model="ir.cron">
<field name="name">Name of your Scheduler Action</field>
<field name="user_id" ref="base.user_root"/>
<field name="interval_number">1</field>
<field name=" ">days</field>
<field name="numbercall">-1</field>
<field eval="False" name="doall"/>
@sehrishnaz
sehrishnaz / radio_button_widget.xml
Created May 23, 2020 05:55
Show one2many field records as radio button in odoo wizard, Convert one2many field into selection field | Odoo, Use radio widget in one2many field | Odoo, Set default value of selection field using context | Odoo, Fill selection field using context | Odoo, Mapping one2many field into selection field | Odoo
<?xml version="1.0"?>
<openerp>
<data>
<record model="ir.ui.view" id="wizard_model_form">
<field name="name">wizard.model.form.name</field>
<field name="model">wizard.model.name</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Form Name">
<sheet>
@sehrishnaz
sehrishnaz / writing_binary_field_into_zipfile_in_odoo.py
Created June 26, 2020 04:49
Write binary data into zip file and downlaod it on button click in odoo
@api.multi
def odoo_button_click(self):
print('****************odoo_button_click******************')
import os, zipfile
# function to convert binary data
def isBase64_decodestring(s):
try:
return base64.decodestring(s)
except Exception as e:
raise ValidationError('Error:', +str(e))
@sehrishnaz
sehrishnaz / employee_hierarchy_tree_server_action.py
Created July 28, 2020 04:40
Tree Data Structure for Manager Employee Hierarchy Server Action
class HREmployee(models.Model):
_inherit = 'hr.employee'
@api.multi
def load_employee_hierarchy(self):
domain = []
if self._context.get('params', False):
params = self._context.get('params', False)
if params.get('menu_id', False):
raise ValidationError(
@sehrishnaz
sehrishnaz / employee_hierarchy_tree.xml
Last active July 28, 2020 06:03
Tree Data Structure for Manager Employee Hierarchy
<record id="employee_hierarchy_tree_view" model="ir.ui.view">
<field name="name">hr.employee.hierarchy.tree</field>
<field name="model">hr.employee</field>
<field name="field_parent">child_ids</field>
<field eval="20" name="priority"/>
<field name="arch" type="xml">
<tree string="Employees" toolbar="True">
<field name="name"/>
<field name="company_id"/>
<field name="department_id"/>
@sehrishnaz
sehrishnaz / inherit_odoo_controller.py
Created August 7, 2020 11:02
Inherit web login controller in odoo
from openerp import http
from openerp.http import request
from openerp.addons.web.controllers.main import Home
class Extension_Home(Home):
@http.route()
def web_login(self, redirect=None, **kw):
if 'login' in kw:
#your_logic_goes_here()
return super(Extension_Home, self).web_login()
@sehrishnaz
sehrishnaz / Web.login_layout QWebException.py
Created August 11, 2020 10:57
Web.login_layout QWebException | <t t-call="web.login_layout"> | QWebException: "'NoneType' object has no attribute 'name'" while evaluating 'res_company.name'
class TestClass(http.Controller):
@http.route('/test/', type='http', auth='public')
def test_function(self, redirect=None, **kw):
if request.httprequest.method == 'POST':
return request.render('module_name.my_custom_form', {
'error': 'error message goes here',
'data': data,
})
# To resolve this issue modify above controller with below one
@sehrishnaz
sehrishnaz / Web.login_layout QWebException.xml
Created August 11, 2020 10:55
Web.login_layout QWebException | <t t-call="web.login_layout"> | QWebException: "'NoneType' object has no attribute 'name'" while evaluating 'res_company.name'
<openerp>
<data>
<template id="my_custom_form">
<t t-call="web.login_layout">
<form class="oe_signup_form" role="form" t-attf-action="/test/" method="post" onsubmit="this.action = this.action + location.hash">
<div class="form-group field-login">
<label for="name" class="control-label">Enter Name</label>
<input type="text" name="name" t-att-value="name" id="name" class="form-control" required="required" autofocus="autofocus"/>
</div>
@sehrishnaz
sehrishnaz / call-controller-function-from-another-controller.py
Last active August 11, 2020 12:56
unbound method web_login() must be called with instance as first argument (got nothing instead),Invoke controller function from another controller in odoo
class InheritedHome(Home):
@http.route()
def web_login(self, redirect=None, **kw):
if 'login' in kw:
#your_logic_goes_here()
return super(Extension_Home, self).web_login()
class MyCustomClass(http.Controller):
@http.route('/test/', type='http', auth='public', website=True)