Skip to content

Instantly share code, notes, and snippets.

@litnimax
litnimax / get_odoo_conf.py
Created February 6, 2024 08:21
Fetch Asterisk Plus SIP peers script (with caching)
#!/usr/bin/env python3
import argparse
import logging
import logging.config
import os
import sys
import yaml
from datetime import datetime
import requests
@litnimax
litnimax / gist:4af059f018f819494268e5724bd02d8f
Last active March 3, 2023 22:44
Odoo: suppress warnings WARNING 8_orders.x.x odoo.addons.base.models.ir_cron: Skipping database 8_x.x as its base version is not 16.0.1.3.
import logging
import psycopg2
import threading
import odoo
class BadVersion(Exception):
pass
class BadModuleState(Exception):
pass
@litnimax
litnimax / main.py
Created July 11, 2020 07:51 — forked from mlaitinen/main.py
Odoo 12 Prometheus instrumentation
##############################################################################
#
# Author: Miku Laitinen / Avoin.Systems
# Copyright 2019 Avoin.Systems
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
[options]
#
# WARNING:
# If you use the Odoo Database utility to change the master password be aware
# that the formatting of this file WILL be LOST! A copy of this file named
# /etc/odoo/openerp-server.conf.template has been made in case this happens
# Note that the copy does not have any first boot changes
#-----------------------------------------------------------------------------
# Odoo Server Config File - TurnKey Linux
@litnimax
litnimax / add-minion.sh
Created January 11, 2020 12:13 — forked from Silvenga/add-minion.sh
Remotely Authorize and Provision a Salt Minion
#!/bin/bash
# apt-get install sshpass
# http://docs.saltstack.com/en/latest/topics/tutorials/preseed_key.html
BOOTSTRAP=/srv/minion-bootstrap.sh
LOG_LOCATION=/tmp/minion-bootstrap.log
TMP=/tmp/salt
if [[ -z "$1" ]] || [[ -z "$2" ]] ; then
@litnimax
litnimax / psqlfix.txt
Last active November 7, 2019 04:27
Change postgres default template0 to UTF8 encoding
update pg_database set datallowconn = TRUE where datname = 'template0';
\c template0
update pg_database set datistemplate = FALSE where datname = 'template1';
drop database template1;
create database template1 with template = template0 encoding = 'UTF8';
update pg_database set datistemplate = TRUE where datname = 'template1';
template1
update pg_database set datallowconn = FALSE where datname = 'template0';
@litnimax
litnimax / 1.py
Created May 26, 2018 13:54
Odoo many2many groupby example
@api.model
def read_group(self, domain, fields, groupby, offset=0, limit=None, orderby=False, lazy=True):
if not '_context_' in groupby:
return super(Task, self).read_group(domain, fields, groupby,
offset, limit, orderby, lazy)
else:
# Get the list of contexts
res = []
for c in self.env['nibbana.context'].search(
[('create_uid','=', self.env.user.id)]):
@litnimax
litnimax / gist:5c03ef02da86f350107a8efe938c4e7e
Created May 6, 2018 07:47
Color convert int to css for odoo
@api.multi
def _get_kanban_color(self):
for self in self:
if not self.area_color:
continue
css = self.area_color[1:]
r,g,b = int(css[:2], 16), int(css[2:4], 16), int(css[4:], 16)
RGBint = (r<<16) + (g<<8) + b
self.kanban_color = RGBint
@litnimax
litnimax / totals.py
Created April 11, 2018 14:27
TKS all operations parser
import xlrd
import sys
res = {}
rb = xlrd.open_workbook(sys.argv[1])
sheet = rb.sheet_by_index(0)
for rownum in range(sheet.nrows):
row = sheet.row(rownum)
@litnimax
litnimax / mqttrpc_test.py
Created March 6, 2018 11:02
MQTT RPC test
import asyncio
import logging
from mqttrpc import MQTTRPCServer, dispatcher
logging.basicConfig(level=logging.INFO)
class TestMQTTRPCServer(MQTTRPCServer):
@dispatcher.public
def test(a):
return a