Skip to content

Instantly share code, notes, and snippets.

@sehrishnaz
sehrishnaz / return_action_with_sticky_notification_odoo.py
Created June 27, 2022 08:49
Return Action With Sticky Notification in Odoo15
def cmd_send_notification(self):
action = self.env.ref('module_name.id_of_custom_action_window')
return {
'type': 'ir.actions.client',
'tag': 'display_notification',
'params': {
'title': _('Your Custom Notification Title'),
'message': '%s',
'links': [{
'label': self.customer_id.name,
@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 / boost_website_traffic_using_python_selenium.py
Created December 2, 2021 05:44
Advance Python Bot to Increase Website Traffic using Selenium
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.common.keys import Keys
import time
import pandas as pd
import random
driver = webdriver.Chrome(executable_path=ChromeDriverManager().install())
driver.maximize_window()
col_name = ['url']
@sehrishnaz
sehrishnaz / append_hyphens_in_django_url_using_slug_utils.py
Created January 3, 2022 05:06
Making Perfect Readable URL in Django Using Slug
import string, random
from django.utils.text import slugify
def random_string_generator(size=10, chars=string.ascii_lowercase + string.digits):
return ''.join(random.choice(chars) for _ in range(size))
def unique_slug_generator(instance, new_slug=None):
if new_slug is not None:
slug = new_slug
else:
@sehrishnaz
sehrishnaz / put_url_inside_qr_code_odoo.py
Created June 30, 2022 08:27
How to put URL inside QR Code in odoo
base_url = self.env['ir.config_parameter'].get_param('web.base.url')
if not 'localhost' in base_url:
if 'http://' in base_url:
base_url = base_url.replace('http://', 'https://')
base_url = base_url + '/web#id=' + str(self.id) + '&model=your.model.goes.here&view_type=form&cids='
@sehrishnaz
sehrishnaz / generate_qr_code_qweb_odoo.py
Created June 30, 2022 08:25
How to Generate QR Code using Python and Odoo
class res_company(models.Model):
_inherit = 'res.company'
@api.multi
def generate_qr(self, txt=''):
qr_code = qrcode.QRCode(version=4, box_size=4, border=1)
qr_code.add_data(txt)
qr_code.make(fit=True)
qr_img = qr_code.make_image()
im = qr_img._img.convert("RGB")
@sehrishnaz
sehrishnaz / repeat_header_footer_odoo_qweb.xml
Last active June 29, 2022 12:08
Repeat Header and Footer on each page in QWEB Custom Report
@sehrishnaz
sehrishnaz / display_sticky_notification_with_link_button_odoo.py
Created June 27, 2022 08:47
Display Sticky Notification with a Link Button in Odoo
@sehrishnaz
sehrishnaz / display_sticky_notification_odoo.py
Created June 27, 2022 08:46
Display Only Sticky Notification in Odoo15
def cmd_send_notification(self):
return {
'type': 'ir.actions.client',
'tag': 'display_notification',
'params': {
'title': _('Your Custom Notification Title'),
'message': 'Your Custom Message...',
'sticky': False,
}
}
@sehrishnaz
sehrishnaz / fold_kanban_states_odoo.py
Created June 23, 2022 07:58
Dynamically Fold Kanban States (Selection Field) in Odoo8
class some_model(models.Model):
_name = "some.model"
STATES = [('Draft','Draft'),('Submit','Submit'),('Closed','Closed')]
# States that should be folded in Kanban view
# used by the `state_groups` method
FOLDED_STATES = [
'Closed',
]