Skip to content

Instantly share code, notes, and snippets.

View CakJuice's full-sized avatar
🎯
Focusing

Hendra Suegeer Juice CakJuice

🎯
Focusing
View GitHub Profile
@CakJuice
CakJuice / odoo12_custom_report_template.xml
Created May 24, 2019 06:03
Odoo 12 custom report template
<odoo>
<record model="report.paperformat" id="paperformat_attendance_recap_report">
<field name="name">paperformat.attendance.recap.report</field>
<field name="default" eval="True"/>
<field name="format">A4</field>
<field name="page_width">0</field>
<field name="page_width">0</field>
<field name="orientation">Portrait</field>
<field name="margin_top">30</field>
<field name="margin_right">5</field>
@CakJuice
CakJuice / odoo12_custom_report_wizard.py
Created May 24, 2019 06:01
Odoo 12 custom report wizard
# -*- coding: utf-8 -*-
from datetime import datetime
from odoo import models, fields, api
from odoo.tools import DEFAULT_SERVER_DATE_FORMAT as DATE_FORMAT, DEFAULT_SERVER_DATETIME_FORMAT as DATETIME_FORMAT
class AttendanceRecapReportWizard(models.TransientModel):
_name = 'attendance.recap.report.wizard'
@CakJuice
CakJuice / odoo12_custom_report_wizard.xml
Created May 24, 2019 05:57
Odoo 12 custom report wizard view
<odoo>
<record model="ir.ui.view" id="attendance_recap_report_wizard">
<field name="name">HR Attendance Custom Recap Report</field>
<field name="model">attendance.recap.report.wizard</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Attendance Recap Report">
<group>
<group>
<field name="date_start"/>
@CakJuice
CakJuice / event_handling_bootstrap4.js
Created March 19, 2019 13:31
This is an example event handling to replace JQuery for Bootstrap 4.
const html = document.getElementsByTagName('html')[0];
html.addEventListener('click', function(e) {
/* Event listener handler for html element.
* This code will be executed when user clicked on all html area.
*/
if (e.target.className === 'nav-link dropdown-toggle') {
// Check whether element is 'nav-link dropdown toggle'.
// Set nextElementSibling to toggling 'show' class name.
@CakJuice
CakJuice / example_model.py
Last active October 8, 2022 18:00
Example code for Many2one & One2many fields
from odoo import models, fields
class ParentModel(models.Model):
_name = 'parent.model'
parent_field_1 = fields.Char(string="Parent Field 1")
parent_field_2 = fields.Integer(string="Parent Field 2")
# If you want to display child data, you must create One2many field.
@CakJuice
CakJuice / odoo_10_custom_gmap_widget.js
Created September 8, 2018 06:18
Example Odoo Custom Widget with Google Maps API
/**
* A menu that lets a user delete a selected vertex of a path.
* @constructor
*/
function DeleteVertexMenu() {
if (typeof google === 'undefined' || !google) return;
this.div_ = document.createElement('div');
this.div_.className = 'delete-menu';
@CakJuice
CakJuice / odoo_10_hr.py
Created September 8, 2018 06:17
Example Odoo HR
# -*- coding: utf-8 -*-
"""Author:
@CakJuice <hd.brandoz@gmail.com>
Website:
https://cakjuice.com
"""
import logging
@CakJuice
CakJuice / odoo_10_payroll.py
Last active September 8, 2018 06:17
Example Odoo Payroll Code
# -*- coding: utf-8 -*-
"""Author:
@CakJuice <hd.brandoz@gmail.com>
Website:
https://cakjuice.com
"""
from __future__ import division
@CakJuice
CakJuice / custom_report_template.xml
Created September 3, 2018 03:13
Custom report Odoo 11 - template report for medium
<odoo>
<record model="report.paperformat" id="paperformat_attendance_recap_report">
<field name="name">paperformat.attendance.recap.report</field>
<field name="default" eval="True"/>
<field name="format">A4</field>
<field name="page_width">0</field>
<field name="page_width">0</field>
<field name="orientation">Portrait</field>
<field name="margin_top">30</field>
<field name="margin_right">5</field>
@CakJuice
CakJuice / custom_report_wizard.py
Last active February 15, 2022 09:24
Custom report Odoo 11 - wizard & abstract model for medium
from datetime import datetime, timedelta
from odoo import models, fields, api
from odoo.tools import DEFAULT_SERVER_DATE_FORMAT as DATE_FORMAT, DEFAULT_SERVER_DATETIME_FORMAT as DATETIME_FORMAT
class AttendanceRecapReportWizard(models.TransientModel):
_name = 'attendance.recap.report.wizard'
date_start = fields.Date(string="Start Date", required=True, default=fields.Date.today)