Skip to content

Instantly share code, notes, and snippets.

@akhmadkresna
akhmadkresna / index.html
Last active June 9, 2019 14:35
css/js typewriter
<html>
<head>
<link href="style.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="typedtext"></div>
<script src="script.js"></script>
</body>
</html>
sfdsfsfsdfsdfsf
@akhmadkresna
akhmadkresna / controller.py
Last active July 19, 2018 04:28
odoo route
# -*- coding: utf-8 -*-
import odoo.http as http
class your_class(http.Controller):
@http.route('/custom/url', type='http', auth='user', website=True)
def show_custom_webpage(self, **kw):
# render qweb template and parse another parameter data type dictionary, so we have 2 parameter in render method.
return http.request.render('your_module.new_web_page', {})
@akhmadkresna
akhmadkresna / web_page.xml
Created July 19, 2018 04:19
web page odoo
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<!-- webpage record -->
<template id="new_web_page" name="Your page name" page="True">
<t t-call="website.layout">
<div id="wrap" class="oe_structure oe_empty">
<!-- Your content here -->
</div>
</t>
@akhmadkresna
akhmadkresna / odoo_website_filename.xml
Created July 8, 2018 14:29
odoo get file name from website
<div class="col-md-7 col-sm-8">
<input id="upload" type="file" class="form-control o_website_form_input" name="file" required=""/>
<input id="upload_name" type="text" class="form-control o_website_form_input" name="filename" required=""/>
</div>
<script>
$(function(){
$('#upload').change(function(e){
var fileName = e.target.files[0].name;
alert('The file "' + fileName + '" has been selected.');
$('#upload_name').val(fileName)
@akhmadkresna
akhmadkresna / odoo_filename.xml
Last active July 4, 2018 08:14
get file name of binary file
<!-- IN PYTHON, ADD ANOTHER FIELD DECLARATION TO STORE FILE NAME (CHAR)-->
file = fields.Binary("Attachment")
file_name = fields.Char("File Name")
<!-- IN XML VIEW, SET THE 'FILENAME' ATTRIBUTE OF THE BINARY FIELD WITH THE CHAR FIELD (FIELD_NAME)-->
<field name="file" filename="file_name"/>
<field name="file_name" invisible="1"/>
@akhmadkresna
akhmadkresna / odoo_seq.py
Created July 4, 2018 06:35
odoo sequence set via python code
class SaleDoc(models.Model):
_name = 'sale.doc'
name = fields.Char('No Dokumen')
tanggal = fields.Date('Tanggal')
sale_id = fields.Many2one('sale.order', string="Order")
keterangan = fields.Text('Keterangan')
file = fields.Binary('File Dokumen')
# Magic suppose to be happen in here. NOT BUGS
@akhmadkresna
akhmadkresna / odoo_sequence.xml
Last active July 4, 2018 07:22
create sequence odoo
<!-- Here i create sequence for model 'sale.doc' with prefix 'SK'. Padding is the length of increment number. padding 5 = 00001 -->
<!-- Later to be used in python code for running number of 'sale.doc' -->
<odoo>
<data noupdate="1">
<record id="seq_sale_doc" model="ir.sequence">
<field name="name">doc sequence</field>
<field name="code">sale.doc</field>
<field name="prefix">SK</field>
<field name="padding">5</field>
</record>
@akhmadkresna
akhmadkresna / odoo_tree_color.xml
Created July 3, 2018 04:01
add color in record odoo treeview
<tree decoration-success="state=='confirm'" decoration-danger="state=='reject'">
<field name="product_id"/>
<field name="state" invisible="1"/>
</tree>
<!-- Here is the detail for available color -->
decoration-bf - shows the line in BOLD
decoration-it - shows the line in ITALICS
decoration-danger - shows the line in LIGHT RED
decoration-info - shows the line in LIGHT BLUE
@akhmadkresna
akhmadkresna / wkhtmltopdf.sh
Created June 30, 2018 14:11
wkhtmltopdf install on ubuntu 18.04
sudo wget https://builds.wkhtmltopdf.org/0.12.1.3/wkhtmltox_0.12.1.3-1~bionic_amd64.deb
sudo dpkg -i wkhtmltox_0.12.1.3-1~bionic_amd64.deb
sudo apt-get install -f
sudo ln -s /usr/local/bin/wkhtmltopdf /usr/bin
sudo ln -s /usr/local/bin/wkhtmltoimage /usr/bin