Skip to content

Instantly share code, notes, and snippets.

View aek's full-sized avatar

Axel Mendoza aek

View GitHub Profile
@aek
aek / purchase_order_discount.py
Last active October 16, 2018 23:09
Purchase Order Global Discount
from openerp import models, api
from openerp.osv import fields, osv
import openerp.addons.decimal_precision as dp
class PurchaseOrder(models.Model):
_inherit = "purchase.order"
def _get_order(self, cr, uid, ids, context=None):
result = {}
@aek
aek / template-rare-inheritance.xml
Last active June 5, 2020 04:25
Example of an Odoo Template XML rewrite using rare and non-documented inheritance extension
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<template id="recommended_products_ext" inherit_id="website_sale.recommended_products">
<xpath expr="." position="replace">
<t name="Product" t-name="website_sale.recommended_products">
<xpath expr="//div[@id='product_small_description']" position="before">
<div class="container mt32" t-if="product.alternative_product_ids">
<h3>Alternative Products:</h3>
<div class="row mt16" style="">
@aek
aek / stream_download_controller.py
Last active March 27, 2018 18:38
attachment controller to stream the download of attachment files
import base64
import logging
import werkzeug.utils
import werkzeug.wrappers
import hashlib
import mimetypes
import os
import re
import werkzeug
@aek
aek / aek.toml
Created January 29, 2018 16:20
debug traefik redirect config
[backends]
[backends.aek]
[backends.aek.servers.instance]
url = "http://127.0.0.1:8079"
[frontends]
[frontends.aek-redirect]
entrypoints = ["http"]
[frontends.aek-redirect.Redirect]
Regex = "(http://mio.aek/|http://www.mio.aek/|https://mio.aek/)"
proj_vals = []
for elem in field_ids:
if elem[0] == 6:
project_ids = elem[2]
for project in self.pool.get('project.project').browse(cr, uid, project_ids):
proj_vals.append(project.name)
elif elem[0] == 0:
proj_vals.append(elem[2]['project'])
elif elem[0] == 1:
if elem[2].get('project', False):
from openerp.osv import fields, osv
import openerp.addons.decimal_precision as dp
class product_dim_price(osv.osv):
_inherit = "product.product"
def _get_dim_price(self, cr, uid, ids, field_name=None, arg=False, context=None):
res = {}
for prod in self.browse(cr, uid, ids, context=context):
res[prod.id] = prod.length * prod.width
class RedisSessionStore(SessionStore):
def __init__(self, expire = 1800, key_prefix=''):
SessionStore.__init__(self)
self.redis = redis.Redis(tools.config.get('redis_host', 'localhost'),
int(tools.config.get('redis_port', 6379)),
int(tools.config.get('redis_dbindex', 1)),
password=tools.config.get('redis_pass', None))
self.path = session_path()
self.expire = expire
self.key_prefix = key_prefix
@aek
aek / Jx.Store.Parser.XML.js
Created January 31, 2012 20:27
Parser for reading and writting XML formatted data
/*
---
name: Jx.Store.Parser.XML
description: Parser for reading and writting XML formatted data.
license: MIT-style license.
requires:
@aek
aek / index.htm
Created November 21, 2011 22:31
example of jxlib-b2
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>ArcheType</title>
<!-- include the jx delicious skin -->
<link rel="stylesheet" href="../js/mootools/jxlib/themes/delicious/jxtheme.css" type="text/css" media="screen" charset="utf-8">
<!-- IE specific style sheets -->
@aek
aek / Locale.Spanish.js
Created November 18, 2011 21:01
jxlib spanish locale
/*
---
name: Locale.Spanish.ES
description: Default translations of text strings used in JX for Spanish (Spain) (es-ES)
license: MIT-style license.
requires: