Skip to content

Instantly share code, notes, and snippets.

View repodevs's full-sized avatar

Edi Santoso repodevs

View GitHub Profile
@repodevs
repodevs / orm.md
Last active December 10, 2018 04:48
Odoo ORM one2many or many2many domain

(0, 0, { values }) link to a new record that needs to be created with the given values dictionary
(1, ID, { values }) update the linked record with id = ID (write values on it)
(2, ID) remove and delete the linked record with id = ID (calls unlink on ID, that will delete the object completely, and the link to it as well)
(3, ID) cut the link to the linked record with id = ID (delete the relationship between the two objects but does not delete the target object itself)
(4, ID) link to existing record with id = ID (adds a relationship)
(5) unlink all (like using (3,ID) for all linked records)
(6, 0, [IDs]) replace the list of linked IDs (like using (5) then (4,ID) for each ID in the list of IDs)

@repodevs
repodevs / gist:881697c59ca4665eed393230daebffe6
Created December 5, 2018 05:48
Docker macOS host cannot access to container.
For my issue. adding alias is solved
$ docker inspect YOUR-CONTAINER
get the IP and add to alias
$ sudo ifconfig lo0 alias IP
$ sudo ifconfig lo0 alias 172.17.0.1
@repodevs
repodevs / odoo-cli.py
Created June 10, 2018 09:23
Odoo CLI Helpers
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
"""Install, Uninstall, Upgrade a module"""
import xmlrpclib
import argparse
import getpass
import time
parser = argparse.ArgumentParser()
@repodevs
repodevs / snippet.py
Created April 13, 2018 07:36
Odoo snippet fields.Selection get text name
def get_selection_name(models, fields, value):
""" Get text value of Selection fields
:param models: models of fields
:param fields: fields name to get
:param value: fields value
:return text: Text value of the fields or ''
"""
res = dict(models.fields_get(allfields=[fields])[fields]['selection'])[value] if value else ''
@repodevs
repodevs / hosts
Created February 11, 2018 16:32
Open Reddit and Vimeo
# place this ini /etc/hosts
# Reddit
151.101.129.140 reddit.com
151.101.49.140 www.reddit.com
151.101.49.140 i.redditmedia.com
151.101.49.140 m.reddit.com
151.101.49.140 g.redditmedia.com
151.101.49.140 a.thumbs.redditmedia.com
151.101.193.140 redditgifts.com
@repodevs
repodevs / docker-compose.yml
Created February 7, 2018 22:51
Odoo Runbot using Docker
version: '2'
volumes:
odoo-web-data:
driver: local
odoo-db-data:
driver: local
runbot-builds:
driver: local
runbot-ssh:
driver: local
@repodevs
repodevs / odoo-wsgi.py
Created February 3, 2018 10:09 — forked from danidee10/odoo-wsgi.py
Odoo wsgi file for running odoo10 as a wsgi application
# WSGI Handler sample configuration file.
#
# Change the appropriate settings below, in order to provide the parameters
# that would normally be passed in the command-line.
# (at least conf['addons_path'])
#
# For generic wsgi handlers a global application is defined.
# For uwsgi this should work:
# $ uwsgi_python --http :9090 --pythonpath . --wsgi-file openerp-wsgi.py
#
@repodevs
repodevs / odoo_install.sh
Last active December 25, 2020 09:09
odoo v9 installation
#!/bin/bash
sudo adduser --system --quiet --shell=/bin/bash --home=/opt/odoo --gecos 'odoo' --group odoo
sudo mkdir /etc/odoo && mkdir /var/log/odoo/
sudo apt-get update
sudo apt-get install postgresql postgresql-server-dev-9.3 -y
sudo apt-get install build-essential python-imaging python-lxml python-ldap python-dev libldap2-dev libsasl2-dev npm nodejs git python-setuptools libxml2-dev libxslt1-dev libjpeg-dev python-pip gdebi -y
git clone --depth=1 --branch=9.0 https://github.com/odoo/odoo.git /opt/odoo/odoo
sudo chown odoo:odoo /opt/odoo/ -R && sudo chown odoo:odoo /var/log/odoo/ -R && cd /opt/odoo/odoo && sudo pip install -r requirements.txt
sudo npm install -g less@3.0.4 less-plugin-clean-css -y && sudo ln -s /usr/bin/nodejs /usr/bin/node
cd /tmp && wget -c https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox_0.12.5-1.bionic_amd64.deb && sudo gdebi -n wkhtmltox_0.12.5-1.bionic_amd64.deb && rm wkhtmltox_0.12.5-1.bionic_amd64.deb
@repodevs
repodevs / filter
Created December 20, 2017 10:25 — forked from hofrob/filter
Odoo Logstash Filter
filter {
if [type] == "odoo" {
grok {
match => { "message" => "%{ODOOLOG}" }
}
date {
match => [ "timestamp", "yyyy-MM-dd HH:mm:ss,SSS" ]
}
}
}
@repodevs
repodevs / autoaway.py
Created December 20, 2017 08:42 — forked from charliewolf/autoaway.py
Email notifications for chats received in Fonality HUD when away
#!/usr/bin/python
# Quick and (very) dirty script to send emails when a user gets a message and is away from HUD
from base64 import b64decode
from hashlib import sha256
import sqlite3
import datetime
import itertools
import os