Skip to content

Instantly share code, notes, and snippets.

View yasmanycastillo's full-sized avatar

Yasmany Castillo yasmanycastillo

View GitHub Profile
#!/usr/bin/env python
#
# Very basic example of using Python and IMAP to iterate over emails in a
# gmail folder/label. This code is released into the public domain.
#
# RKI July 2013
# http://www.voidynullness.net/blog/2013/07/25/gmail-email-with-python-via-imap/
#
import sys
import imaplib
@yasmanycastillo
yasmanycastillo / csv_splitter.py
Created August 8, 2017 14:29 — forked from jrivero/csv_splitter.py
A Python CSV splitter
import os
def split(filehandler, delimiter=',', row_limit=10000,
output_name_template='output_%s.csv', output_path='.', keep_headers=True):
"""
Splits a CSV file into multiple pieces.
A quick bastardization of the Python CSV library.
Arguments:
@yasmanycastillo
yasmanycastillo / bootstrap-db.py
Created January 10, 2018 16:42 — forked from sebalix/bootstrap-db.py
Bootstraping Odoo database (8.0)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Script to bootstrap an Odoo database (8.0)."""
import odoorpc
# Odoo connection
SUPER_PWD = 'admin'
HOST = 'localhost'
PORT = 8069
DB = 'my_db'
@yasmanycastillo
yasmanycastillo / odoo_download_file.py
Last active August 30, 2023 14:46
Odoo: How to download a file immediately from wizard
# -*- coding: utf-8 -*-
from odoo import http
from odoo.http import request
from odoo.addons.web.controllers.main import serialize_exception,content_disposition
import base64
class Binary(http.Controller):
@http.route('/web/binary/download_document', type='http', auth="public")
# This came up with a huge problem for days, but i resolve it.
# The main problem is the limitation in form in odoo. Mostly of this are not in the official documentation,
# so maybe you will feel a bit blind sometimes, but I feel you bro.
# Basically works for partner_id relation for many2one
# PART ONE
# Create a class res_partner.py
class ResPartner(models.Model):
"""This part is the easy part, @api.model overrides to name_get (optional) and name_search."""
_inherit = 'res.partner'
@yasmanycastillo
yasmanycastillo / external_api.py
Created August 17, 2018 17:52
Odoo external api
import xmlrpc.server as Server
import ssl
class Utils(object):
def __init__(self, host, db_name, user, password):
ssl.match_hostname = lambda cert, hostname: True
self._host = host
self._db = db_name
quants = env['stock.quant'].search([])
move_line_ids = []
warning = ''
for quant in quants:
move_lines = env["stock.move.line"].search([
('product_id', '=', quant.product_id.id),
('location_id', '=', quant.location_id.id),
('lot_id', '=', quant.lot_id.id),
('package_id', '=', quant.package_id.id),
('owner_id', '=', quant.owner_id.id),
@yasmanycastillo
yasmanycastillo / skip_test_from_super_class.py
Created January 22, 2019 18:52 — forked from moylop260/skip_test_from_super_class.py
How to skip a method test from a inherited test class for python
class TestCustom(Test):
def __init__(self, methodName='runTest'):
super(TestCustom, self).__init__(methodName)
# Skip original test from inherited class
custom_attributes = set(dir(TestCustom)) - set(dir(Test))
custom_test_methods = [
name for name in custom_attributes
if name.startswith('test_') and callable(getattr(self, name))]
if methodName not in custom_test_methods:
method = getattr(self, methodName)
@yasmanycastillo
yasmanycastillo / Odoo-install.md
Created February 12, 2019 02:19 — forked from erickgnavar/Odoo-install.md
Instalación Odoo

Despliegue de aplicación Odoo

Se usará Ubuntu 16.04 como sistema base

Preparación del sistema

sudo apt-get update

sudo apt-get install git python-dev libpq-dev python-pip python-virtualenv libsasl2-dev libldap2-dev libssl-dev \
OE_USER="odoo"
OE_PORT="8069"
WEBSITE_NAME="_"
LONGPOLLING_PORT="8072"
ADMIN_EMAIL="test@example.com"
OE_CONFIG="${OE_USER}-server"
#--------------------------------------------------
# Install Nginx if needed
#--------------------------------------------------