Skip to content

Instantly share code, notes, and snippets.

@danmana
danmana / example_model.py
Created August 16, 2021 15:08
Add support for custom json fields in Odoo
from odoo import models, fields, api
from json_field import JsonField
class Person(models.Model):
_name = 'example.person'
_description = 'Person with json details'
details = JsonField() # a json object represented as dict / list / python primitives
[MASTER]
profile=no
ignore=CVS,.git,scenarios,.bzr
persistent=yes
cache-size=500
load-plugins=pylint.extensions.docstyle, pylint.extensions.mccabe
[ODOOLINT]
readme_template_url="https://github.com/OCA/maintainer-tools/blob/master/template/module/README.rst"
manifest_required_authors=Vauxoo,
@drkpkg
drkpkg / size.py
Last active August 26, 2023 13:59
Dynamic size report invoice odoo
"""
Dynamic size in account_invoice report
Just send the account_invoice_line_id take the len() and multiply it with 7 (millimeters)
This example is simulating the paper of a supermarket invoice, the default size in my country is 24 millimeters for a correct
format, but you can change it!
How it works: You need pass this method inside the qweb report sending the lines.
"""
#Qweb
<t t-esc="o.change_size_page(o.lines)"/>
@travishathaway
travishathaway / pyscopg2_decorator.py
Last active July 9, 2023 16:38
Postgres Connections with Python Decorators
from functools import wraps
import psycopg2
####################
# Define Decorator #
####################
def psycopg2_cursor(conn_info):
"""Wrap function to setup and tear down a Postgres connection while
providing a cursor object to make queries with.
@mrkara
mrkara / Powerline.md
Last active December 8, 2022 20:18
Install Powerline on Debian 9 Stretch
  1. Install pip sudo apt-get install python-pip
  2. Install powerline sudo pip install powerline-status
  3. Install fonts sudo apt-get install fonts-powerline
  4. Add these lines to respective files:

.vimrc > set rtp+=/usr/local/lib/python2.7/dist-packages/powerline/bindings/vim/

@nrollr
nrollr / nginx.conf
Last active June 9, 2024 23:39
NGINX config for SSL with Let's Encrypt certs
# UPDATED 17 February 2019
# Redirect all HTTP traffic to HTTPS
server {
listen 80;
listen [::]:80;
server_name www.domain.com domain.com;
return 301 https://$host$request_uri;
}
# SSL configuration
@ivanleoncz
ivanleoncz / flask_app_logging.py
Last active May 23, 2021 07:25
Demonstration of logging feature for a Flask App.
#/usr/bin/python3
""" Demonstration of logging feature for a Flask App. """
from logging.handlers import RotatingFileHandler
from flask import Flask, request, jsonify
from time import strftime
__author__ = "@ivanleoncz"
import logging
@chmarr
chmarr / blocked.sql
Created November 5, 2015 18:30
PostgreSQL query to display blocked and blocking queries. Updated from PG Wiki.
SELECT blocked_locks.pid AS blocked_pid,
blocked_activity.usename AS blocked_user,
now() - blocked_activity.query_start
AS blocked_duration,
blocking_locks.pid AS blocking_pid,
blocking_activity.usename AS blocking_user,
now() - blocking_activity.query_start
AS blocking_duration,
blocked_activity.query AS blocked_statement,
blocking_activity.query AS blocking_statement
@sylvaindethier
sylvaindethier / odoo8-install.md
Created December 8, 2014 22:10
Odoo8 (OpenERP) installation on Ubuntu 14.04

1. Update OS

sudo apt-get update && sudo apt-get upgrade

2. Create the Add Odoo user (own & run application)

sudo adduser --system --home=/opt/odoo --group odoo

3. Install & configure PostgreSQL

sudo apt-get install postgresql sudo su - postgres createuser --createdb --username postgres --no-createrole --no-superuser --pwprompt odoo

@shymonk
shymonk / customize-save-in-django-admin-inline-form.org
Last active April 14, 2024 02:55
How to customize save in django admin inline form?

Customize Save In Django Admin Inline Form

Background

This is a common case in django ORM.

from django.db import models

class Author(models.Model):