Skip to content

Instantly share code, notes, and snippets.

@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 / 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)
@sehrishnaz
sehrishnaz / create_sequence_number_in_odoo.xml
Created August 13, 2020 06:22
Generate Sequence Numbesr in Odoo | What is Sequence Number in Odoo
<record id="unique_sequence_id" model="ir.sequence">
<field name="name">Sequence Name Goes Here</field>
<field name="code">your.sequence.code</field>
<field name="active">TRUE</field>
<field name="prefix">OR</field>
<field name="padding">5</field>
<field name="number_next">1</field>
<field name="number_increment">1</field>
</record>
@sehrishnaz
sehrishnaz / create_sequence_number_in_odoo.py
Created August 13, 2020 06:30
Generate Sequence Numbesr in Odoo | What is Sequence Number in Odoo
class your_model(models.Model):
_name = 'your.model'
application_no = fields.Char('Application No.', default='/')
# on create method
@api.model
def create(self, vals):
obj = super(your_model, self).create(vals)
if obj.application_no == '/':
@sehrishnaz
sehrishnaz / create_custom_report_using_qweb_odoo.xml
Created August 17, 2020 13:09
Creating custom reports using qweb in Odoo
<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data>
<!-- Add the report to the XML file responsible for reports -->
<report id="report_unique_xml_id"
model="your.model.name"
string="Report Name"
name="module_name.report_name"
file="module_name.report_unique_xml_id"
@sehrishnaz
sehrishnaz / hide_breadcrumb_in_odoo.xml
Created August 27, 2020 11:34
Hide or Disable Breadcrumb in Odoo
<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data>
<template id="assets_backend" name="web_helloworld assets" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<script type="text/javascript" src="/your_module_name/static/src/js/hide_your_model_breadcrumb.js" />
</xpath>
</template>
<record model="ir.ui.view" id="your_form_id">
<field name="name">your.form.name</field>
@sehrishnaz
sehrishnaz / hide_breadcrumb_in_odoo_using_javascript.js
Created August 27, 2020 11:35
Hide or Disable Breadcrumb in Odoo us JavaScript
(function() {
var instance = openerp;
t = instance.web._t;
instance.web.ActionManager.include({
get_title: function() {
var titles = [];
if (this.breadcrumbs.length > 1){
console.log('->'+this.breadcrumbs.length)
var result_model = this.breadcrumbs[0].action['res_model']
if (result_model != 'your.model.goes.here'){
@sehrishnaz
sehrishnaz / countdown_timer_widget_odoo.js
Created August 28, 2020 11:21
Time Counter Widget in Odoo | Custom Widget in Odoo
openerp.my_custom_module = function (instance){
instance.web.form.MyCustomWidget = instance.web.form.AbstractField.extend(instance.web.form.ReinitializeFieldMixin,
{
init: function(field_manager, node) {
this._super.apply(this, arguments);
},
start: function() {
var self = this;
this._super.apply(this, arguments);
@sehrishnaz
sehrishnaz / disable_right_click_text_selection.js
Created September 4, 2020 09:45
Disable Right Click and Text Selection in Blogger | WordPress
<script type="text/javascript">
function disableselect(e){
return false
}
function reEnable(){
return true
}
//if IE4+
@sehrishnaz
sehrishnaz / create_model_in_odoo13.py
Created September 9, 2020 07:38
Create New Model in Odoo13
# -*- coding: utf-8 -*-
from odoo import models, fields, api
class ModelA(models.Model):
_name = 'model.a'
name = fields.Char(string="Name")
age = fields.Integer(string="Age")