Skip to content

Instantly share code, notes, and snippets.

View ecarreras's full-sized avatar
💡
IT for utilities

Eduard Carreras ecarreras

💡
IT for utilities
View GitHub Profile
import os
from ast import literal_eval
import tempfile
import subprocess
from flask import Flask, abort, request, Response
from flask.ext.mako import MakoTemplates, render_template
from destral.openerp import OpenERPService
from destral.transaction import Transaction
@ecarreras
ecarreras / README.md
Last active August 7, 2023 07:39
PostgreSQL replication

Checklist

  • Create user replication in the master
sudo -u postgres psql -c "CREATE USER rep REPLICATION \
LOGIN ENCRYPTED PASSWORD 'thepassword';"
  • Modify postgresql.conf in the master
listen_address = # make sure we're listening as appropriate
wal_level = hot_standby
"""
Use ERPPeek or OOOP interface compatible insed OpenERP.
Ex.
client = PoolWrapper(pool, cursor, uid)
client.ResPartner.search([])
partner_obj = client.ResPartner
partner_obj.write([1], {'name': 'Fooo!'})
"""
@ecarreras
ecarreras / install.py
Last active December 28, 2015 10:01
Instal·la mòdul remotament
import logging
import os
import click
from erppeek import Client
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger('installer')
def setup_peek(**peek_config):
import os
print "Descarregant PDF comers..."
os.system('curl "http://simel.simel.ree.es/sep/PubServlet2?operacion=AccInfor&fichero=117_Comercializadores.pdf" > comers.pdf')
print "Transformant a TXT..."
os.system('pdftotext comers.pdf')
print "Creant diccionari..."
c = open('comers.txt', 'r').read()
@ecarreras
ecarreras / HookHandler.py
Last active August 29, 2015 14:04
Gitbucket - HipChat
#!/usr/bin/env python
#-*- coding:utf-8 -*-
"""Credits to: https://gist.github.com/FiloSottile/7634541
"""
import os
import BaseHTTPServer
import sys
import time
#!/usr/bin/env python
#-*- coding:utf-8 -*-
import BaseHTTPServer
import sys
import time
import urlparse
import json
@app.route('/_check_bank/<acc_number>')
def _check_bank(acc_number):
"""Funció AJAX per comprovar el número de compte bancari."""
O = app.config['OOOP']
spain = O.ResCountry.search([('code', '=', 'ES')])[0]
lang = '%s_ES' % get_locale()
vals = O.ResPartnerBank.onchange_banco([], acc_number, spain,
{'lang': lang})
res = {'message': '', 'status': False}
if 'warning' in vals:
@ecarreras
ecarreras / README.md
Last active August 29, 2015 13:58
Sitecustomize

Sitecustomize

Fix for unicode can't decode ascii...

@ecarreras
ecarreras / README.md
Last active August 29, 2015 13:56
OpenERP base setup.py file