Skip to content

Instantly share code, notes, and snippets.

View ofelix03's full-sized avatar

Felix Otoo ofelix03

View GitHub Profile
@ofelix03
ofelix03 / FormSaveReasonDialog.xml
Created April 11, 2025 23:34
FormSaveReasonDialog
<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
<t t-name="fotoo.FormSaveReasonDialog">
<Dialog title="'Contact Modification Reason'" technical="true">
<div>
<label class="form-label">Reason</label>
<div>
<input t-att-value="state.reason" class="form-control" autofocus="true" />
</div>
</div>
@ofelix03
ofelix03 / FormSaveReasonDialog.js
Created April 11, 2025 23:28
FormSaveReasonDialog
import {patch} from "@web/core/utils/patch";
import {FormController} from "@web/views/form/form_controller";
import {useService} from "@web/core/utils/hooks";
// import our custom dialog component
import {FormSaveReasonDialog} from "../../../custom_dialog/customer_dialog";
patch(FormController.prototype, {
setup() {
super.setup();
@ofelix03
ofelix03 / gantt_renderer.js
Last active April 30, 2025 15:36
Medium Article - Gantt Renderer JS - Fetch Employee Time-off Periods
patch(GanttRenderer.prototype, {
getEmployeeTimeOffType(row, column) {
column.leaveType = null;
column.leaveTypeIcon = null;
column.showLeaveTypeText = false;
if (!row.isGroup) {
const {resId} = row;
const start = column.start.toISODate();
const stop = column.stop.toISODate();
@ofelix03
ofelix03 / hr.leave.py
Last active April 30, 2025 17:35
Medium Article - HR Leave - Model Override
from collections import defaultdict
from odoo import models, api
class HrLeave(models.Model):
_inherit = "hr.leave"
@api.model
def get_employee_timeoff_periods(self, res_model, res_ids):
if res_model == "planning.slot":
<odoo>
<data>
<record id="interested_property_template" model="mail.template">
<field name="name">Realtor: I'm Intersted In Property</field>
<field name="model_id" ref="model_realtor_property" />
<field name="subject">Someone's Interested in Your Property</field>
<field name="email_from">[email protected]</field>
<field name="email_to">${object.env.user.email}</field>
<field name="body_html" type="html">
<div>
<odoo>
<data>
<record id="interested_property_template" model="mail.template">
<field name="name">Realtor: I'm Intersted In Property</field>
<field name="model_id" ref="model_realtor_property" />
<field name="body_html" type="html">
<div>
<p>Hello <strong>--property-manager-name--</strong>,</p>
<p>An individual has shown interest in your property <strong>--property-name--</strong>.</p>
from odoo import fields, models
class Property(models.Model):
_name = "realtor.property"
_description = "Real Estate Property"
name = fields.Char(required=True)
manager_id = fields.Many2one(
comodel_name="realtor.property.manager", string="Manager", required=True
from odoo import fields, models
class Property(models.Model):
_name = "realtor.property"
_description = "Real Estate Property"
name = fields.Char(required=True)
manager_id = fields.Many2one(
comodel_name="realtor.property.manager", string="Manager", required=True
)
from odoo import models
class SomeModel(models.Model):
_name = 'some.model'
# Defines the field used to to store records archive state
# Odoo supports only two fields for archiving and unarchiving records, active and x_active field
_active_name = 'x_active'
def action_archive_method(self):
@api.model
def create(self, vals):
try:
# if user has right permission, continue with create operation
return super(Customer, self).create(vals)
except AccessError:
raise ValidationError(_("Sorry! you don't have the right permission to create this record"))