Skip to content

Instantly share code, notes, and snippets.

View sharoonthomas's full-sized avatar

Sharoon Thomas sharoonthomas

View GitHub Profile
@sharoonthomas
sharoonthomas / gist:5794541
Created June 17, 2013 03:45
A WTForms many2one field which works with nereid and Tryton
class Many2OneField(SelectField):
"""
A select field that works like a many2one field in tryton
Additional arguments
:param model: The name of the model
:param domain: Tryton search domain
"""
def __init__(self, label=None, validators=None,
@sharoonthomas
sharoonthomas / gist:5857450
Created June 25, 2013 10:20
How to install tryton on debian/ubuntu
# Step 1: Adding the ppa where tryton is release
sudo add-apt-repository ppa:rayanayar/tryton-2.8
# Step 2: Update the packages
sudo apt-get update
# Step 3: Install all the packages and modules at once
@sharoonthomas
sharoonthomas / gist:5868273
Created June 26, 2013 15:13
PyUPS setting the transaction refernce
from ups import ShipmentConfirm
from lxml.builder import E
shipment_confirm_api = ShipmentConfirm('a', 'b', 'c', 'd')
# Print the value of the TransactionReference
print etree.tostring(shipment_confirm_api.TransactionReference, pretty_print=True)
"""
@sharoonthomas
sharoonthomas / gist:5894813
Last active December 19, 2015 04:09
Flake8 issues from OpenERP
This file has been truncated, but you can view the full file.
openerp-7.0-20130623-231037/setup.py:22:12: E401 multiple imports on one line
openerp-7.0-20130623-231037/setup.py:26:1: E302 expected 2 blank lines, found 1
openerp-7.0-20130623-231037/setup.py:41:80: E501 line too long (107 > 79 characters)
openerp-7.0-20130623-231037/setup.py:43:80: E501 line too long (92 > 79 characters)
openerp-7.0-20130623-231037/setup.py:45:80: E501 line too long (113 > 79 characters)
openerp-7.0-20130623-231037/setup.py:57:80: E501 line too long (107 > 79 characters)
openerp-7.0-20130623-231037/setup.py:61:1: E302 expected 2 blank lines, found 1
openerp-7.0-20130623-231037/setup.py:62:14: E225 missing whitespace around operator
openerp-7.0-20130623-231037/setup.py:63:20: E231 missing whitespace after ','
openerp-7.0-20130623-231037/setup.py:68:1: E302 expected 2 blank lines, found 1
Hola {{ nereid_user.display_name }},
<br/>
Thank you for registering for an Openlabs account.
<br/><br/>
To activate your account, please click the link <a href="{{ url_for('nereid.user.activate', user_id=nereid_user.id, activation_code=nereid_user.activation_code, _external=True) }}">here</a>
<br/>
Kind regards <br/>
<br/>
<br/>
Customer Support<br/>
@sharoonthomas
sharoonthomas / gist:5925036
Created July 4, 2013 05:04
Nereid address edit example
{% extends 'address.jinja' %}
{% from '_helpers.jinja' import render_field %}
{% block breadcrumb %}
{{ super() }}
{% if address %}
<li class="active"><span class="divider">/</span><a>Edit Address</a></li>
{% else %}
<li class="active"><span class="divider">/</span>New Address</li>
def get_bins(self, cr, uid, bin_selection, storage_type, list_exclusions, qty_dict, context=None):
""" Find a list of locations based on user-defined criteria
:param :bin_selection Selection field, Bins with no assignment, bins with assignment only, or all
:param :storage_type Filter based on a specified storage type, i.e, overstock, backstock
:param :list_exclusions List of bin_ids to exclude from the search
:param :qty_dict Quantity in bin GT/LT threshold
@return list of bin_ids with travel sequence
"""
@sharoonthomas
sharoonthomas / gist:7003571
Created October 16, 2013 06:45
Script to find configuration suitable for sysctl configuration based on total amount of RAM on the system.
#!/bin/bash
# Output lines suitable for sysctl configuration based
# on total amount of RAM on the system. The output
# will allow up to 50% of physical memory to be allocated
# into shared memory.
# On Linux, you can use it as follows (as root):
#
# ./shmsetup >> /etc/sysctl.conf
"""
SQL Alchemy example
"""
from sqlalchemy import create_engine
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import Column, Integer, String, ForeignKey
from sqlalchemy.orm import relationship, backref
from sqlalchemy.orm import sessionmaker
engine = create_engine('sqlite:///:memory:', echo=True)
LoadModule python_module /usr/lib/apache2/modules/mod_python.so
<Location "/">
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE mysite.settings
PythonDebug Off
</Location>