Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am foxcarlos on github.
  • I am foxcarlos (https://keybase.io/foxcarlos) on keybase.
  • I have a public key ASCUXXAAyYsS6Nr3NPS93NC8nv28J2lm-sW7xXo5V6Z6fgo

To claim this, I am signing this object:

import pymssql
import pymysql
class CursorMixin(object):
def __init__(self, dbname, dsn):
"""If you have implemented this method you will need define
self._cnx with the connection to database
self._obj with the cursor
"""
@foxcarlos
foxcarlos / one2many_transientModel_Exa.py
Created September 3, 2019 16:17
one2many (transientModel) on button click
from odoo import models, fields
class DbconnectorMessageBox(models.TransientModel):
_name = 'dbconnector.messagebox'
_description = 'MessageBox Popup'
_rec_name = 'text'
def _default_engine(self):
@foxcarlos
foxcarlos / passlib_ejemplo.py
Created September 30, 2019 00:35
Passlib ejemplo
>>> # import the hash algorithm
>>> from passlib.hash import pbkdf2_sha256
>>> # generate new salt, and hash a password
>>> hash = pbkdf2_sha256.hash("toomanysecrets")
>>> hash
'$pbkdf2-sha256$29000$N2YMIWQsBWBMae09x1jrPQ$1t8iyB2A.WF/Z5JZv.lfCIhXXN33N23OSgQYThBYRfk'
>>> # verifying the password
>>> pbkdf2_sha256.verify("toomanysecrets", hash)
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js"></script>
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<!------ Include the above in your HEAD tag ---------->
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.4.0/css/font-awesome.min.css" rel='stylesheet' type='text/css'>
<div class="container">
<div class="row">
@foxcarlos
foxcarlos / DesarolloDockerOdoo.txt
Created October 30, 2019 19:40
Preparar entorno de desarrollo para Odoo con Docker
# Instalar Docker
https://docs.docker.com/install/linux/docker-ce/debian/
#Descargar la imagen de Vauxoo
https://hub.docker.com/r/vauxoo/odoo-80-image-shippable-auto
# Ejecutar lo siguiente en consola
docker pull vauxoo/odoo-80-image-shippable-auto
@foxcarlos
foxcarlos / pagination.html
Created November 14, 2019 18:26
html pagination to directory telephone template
<div class="container">
<ul class="pagination justify-content-center" style="margin:20px 0">
<li class="page-item"><a class="page-link" href="#">Prev</a></li>
<li class="page-item"><a class="page-link" href="#">1</a></li>
<li class="page-item active"><a class="page-link" href="#">2</a></li>
<li class="page-item"><a class="page-link" href="#">3</a></li>
<li class="page-item"><a class="page-link" href="#">Next</a></li>
</ul>
</div>
@foxcarlos
foxcarlos / paginacion_odoo.py
Last active November 19, 2019 12:46
Paginacion en plantilla odoo
# page es lo que viene del template, el numero que se presiono
model_ids = request.env[model_name].search([], offset=(page - 1) * 10, limit=10)
total = model_ids.search_count([])
pager = request.website.pager(
url='url path',
total=total,
page=page,
step=10,
)
@foxcarlos
foxcarlos / alarmas.py
Last active November 21, 2019 19:26
Bot Alarmas
from odoo.addons.decimemijobot.tools.tools import CACHE, get_dolartoday_values
from odoo.addons.decimemijobot.tools.tools import get_bitcoin, get_ethereum
from odoo.addons.decimemijobot.tools.tools import get_litecoin, get_dolartoday
def clear_and_update_cache():
CACHE.clear()
get_dolartoday_values()
def obtener_precio(self, comando):
if comando == 'bitcoin':
@foxcarlos
foxcarlos / form_csrf_token.html
Created December 6, 2019 17:11
Uso de csrf_token en un form odoo template
<form action="/guia" method="get" >
<!--<input type="hidden" name="csrf_token" t-att-value="request.csrf_token()"/>-->
<input type="hidden"/>
<div class="input-group">
<input type="text" name="search" class="search form-control" placeholder="Enter name to search" />
<div class="input-group-btn input-group-lg input-group-md">
<button type="submit" style="background-color:#9CB96A;" class="btn">
Search
</button>