Skip to content

Instantly share code, notes, and snippets.

@sehrishnaz
sehrishnaz / send_email_using_template_code.py
Created October 1, 2021 11:06
Send Email on Button Click using Code
@api.one
def btn_send_email(self):
template_obj = self.env['email.template'].sudo().search([('name','=','Email Template Name')], limit=1)
if template_obj:
receipt_list = ['abc@gmail.com','xyz@yahoo.com']
email_cc = ['test@gmail.com']
body = template_obj.body_html
body=body.replace('--department--',self.department_id.name)
@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:
@sehrishnaz
sehrishnaz / progressbar_widget_odoo.py
Created May 12, 2022 08:40
How to use and implement ProgressBar 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_bar = fields.Integer(compute='_compute_progress_bar')
@api.depends('name','sequence')
def _compute_progress_bar(self):
for u in self:
@sehrishnaz
sehrishnaz / remove_fold_delete_add_new_column_from_task_odoo.xml
Created May 10, 2022 05:30
Remove Fold, Edit Stage, Delete, Archive All and Add New Column From Task Kanban View
<record id="inherit_view_task_kanban" model="ir.ui.view">
<field name="name">inherit.project.task.kanban</field>
<field name="model">project.task</field>
<field name="inherit_id" ref="project.view_task_kanban" />
<field name="arch" type="xml">
<xpath expr="//kanban" position="attributes">
<attribute name="group_create">0</attribute>
<attribute name="group_delete">0</attribute>
<attribute name="group_edit">0</attribute>
<attribute name="archivable">0</attribute>
@sehrishnaz
sehrishnaz / inherit_project_search_view.xml
Created May 9, 2022 06:24
How to inherit project and task form, tree and search view in Odoo
<record id="inherited_view_project_project_filter" model="ir.ui.view">
<field name="name">inherited.project.project.select</field>
<field name="model">project.project</field>
<field name="inherit_id" ref="project.view_project_project_filter"/>
<field name="arch" type="xml">
<!--Below example shows how to visible invisible fields in search view -->
<xpath expr="//search/field[@name='user_id']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
@sehrishnaz
sehrishnaz / inherit_task_search_view.xml
Created May 9, 2022 06:25
How to inherit task search view in Odoo
<!--Inherit task search view -->
<record id="inherit_task_search_view" model="ir.ui.view">
<field name="name">project.task.search.form</field>
<field name="model">project.task</field>
<field name="inherit_id" ref="project.view_task_search_form"/>
<field name="arch" type="xml">
<!--Below example shows how to visible invisible fields in search view -->
<xpath expr="//search/field[@name='name']" position="attributes">
<attribute name="string">You can change string or label of a field</attribute>
@sehrishnaz
sehrishnaz / inherit_task_tree_view.xml
Created May 9, 2022 06:26
How to inherit task tree view in Odoo
<!--Inherit task tree view -->
<record id="inherit_project_task_tree" model="ir.ui.view">
<field name="name">project.task.tree.inherit</field>
<field name="model">project.task</field>
<field name="inherit_id" ref="project.view_task_tree2"/>
<field name="arch" type="xml">
<xpath expr="//tree" position="attributes">
<attribute name="delete">1</attribute>
</xpath>
@sehrishnaz
sehrishnaz / inherit_task_form_view.xml
Created May 9, 2022 06:27
How to inherit task form view in Odoo
<record id="inherit_project_task_view_form" model="ir.ui.view">
<field name="name">project.task.view.inherit.form</field>
<field name="model">project.task</field>
<field name="inherit_id" ref="project_enterprise.project_task_view_form"/>
<field name="arch" type="xml">
<xpath expr="//label[@for='planned_date_begin']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
<xpath expr="//div[hasclass('w-100')]" position="attributes">
<attribute name="invisible">1</attribute>