Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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',
]
@sehrishnaz
sehrishnaz / return_multiple_search_filters_on_many2many_domain_odoo.py
Created May 20, 2022 05:40
Set Multiple Domain Filter on Many2many Field Onchange of Many2one in Odoo
@api.onchange('field_1','field_2','field_3','field_4','field_5')
def onchange_of_fields(self):
res={}
res['domain'] = {'many2many_field': []}
for each in self:
if each.field_1:
res['domain']['many2many_field'].append(('field_1', '=', each.field_1.id))
if each.field_2:
res['domain']['many2many_field'].append(('field_2', '=', each.field_2.id))
if each.field_3:
@sehrishnaz
sehrishnaz / percentpie_widget_odoo.py
Created May 12, 2022 08:42
How to use and implement Percentpie widget in Odoo
class gym_body_parts_config(models.Model):
_name = 'gym.body.parts.config'
sequence = fields.Integer(default=10,help="Gives the sequence order when displaying a list of records.")
name = fields.Char(string="Name", required=True)
progress_percentpie = fields.Integer(compute='_compute_progress_percentpie')
@api.depends('name','sequence')
def _compute_progress_percentpie(self):
for u in self:
@sehrishnaz
sehrishnaz / gauge_widget_odoo.py
Created May 12, 2022 08:41
How to use and implement Gauge widget in Odoo
class gym_body_parts_config(models.Model):
_name = 'gym.body.parts.config'
sequence = fields.Integer(default=10,help="Gives the sequence order when displaying a list of records.")
name = fields.Char(string="Name", required=True)
progress_gauge = fields.Integer(compute='_compute_progress_gauge')
@api.depends('name','sequence')
def _compute_progress_gauge(self):
for u in self: