Skip to content

Instantly share code, notes, and snippets.

Avatar

Sharoon Thomas sharoonthomas

View GitHub Profile
@sharoonthomas
sharoonthomas / conftest.py
Created Jun 3, 2015
Example code using pytest with tryton tests
View conftest.py
# -*- coding: utf-8 -*-
"""
tests/conftest.py
:copyright: (C) 2015 by Openlabs Technologies & Consulting (P) Limited
:license: BSD, see LICENSE for more details.
"""
import os
import time
import calendar
@sharoonthomas
sharoonthomas / migrate_ups_module.py
Last active Aug 29, 2015
For the sake of consistency, the module ups was renamed to shipping_ups. Tryton's migration API does not provide a straightforward way to rename modules as its an exceptional case. This file gives you the code you need to make the migration
View migrate_ups_module.py
# -*- coding: utf-8 -*-
import os
import psycopg2
# Connect to tryton database with database uri.
#
# Example: postgres://tryton:tryton@localhost/production
conn = psycopg2.connect(os.environ.get('TRYTOND_DATABASE_URI'))
conn.set_client_encoding('UTF8')
View gist:6e54065bafd57e6a4c51
# Given a date find the monday and friday of the week
# This assumes that the week starts on sunday
import datetime
import calendar
from dateutil.relativedelta import relativedelta
def get_monday_in_week(date):
# Find the current week
current_week = date.isocalendar()[1]
delta = relativedelta(weeks=current_week-1, weekday=calendar.MONDAY)
View designer.html
<link rel="import" href="../core-scaffold/core-scaffold.html">
<link rel="import" href="../core-header-panel/core-header-panel.html">
<link rel="import" href="../core-menu/core-menu.html">
<link rel="import" href="../core-item/core-item.html">
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<link rel="import" href="../core-menu/core-submenu.html">
<polymer-element name="my-element">
@sharoonthomas
sharoonthomas / gist:19ed690b46f6162cc300
Created Jan 23, 2015
Python Unicode Dict CSV Reader
View gist:19ed690b46f6162cc300
# -*- coding: utf-8 -*-
"""
unicode_dict_reader
:copyright: (C) 2013-2015 by Openlabs Technologies & Consulting (P) Limited
:license: BSD, see LICENSE for more details.
"""
import csv
class UnicodeDictReader(csv.DictReader):
def __init__(self, csvfile, *args, **kwargs):
View gist:b65094a1b5f3aa87bd63
diff --git a/emails/sale-confirmation-html.html b/emails/sale-confirmation-html.html
index 4a0ba5c..dfac4cb 100644
--- a/emails/sale-confirmation-html.html
+++ b/emails/sale-confirmation-html.html
@@ -8,6 +8,94 @@
{% endblock %}
</head>
<body>
+ {% block json_ld %}
+ <script type="application/ld+json">
@sharoonthomas
sharoonthomas / gist:0b425318b47b3dc999e1
Last active Mar 16, 2016
Tryton 3.4 config file (based on debian package)
View gist:0b425318b47b3dc999e1
# /etc/tryton/trytond.conf - Configuration file for Tryton Server (trytond)
#
# This file contains the most common settings for trytond (Defaults
# are commented).
# For more information install the tryton-server-doc package and read
# /usr/share/doc/tryton-server-doc/html/index.html
# and accordingly
# /usr/share/doc/tryton-server-doc/html/topics/configuration.html
[database]
View gist:e8930945a01098f2af84
sh-3.2$ cd /tmp
sh-3.2$ virtualenv test-nereid-cms-install
New python executable in test-nereid-cms-install/bin/python2.7
Also creating executable in test-nereid-cms-install/bin/python
Installing setuptools, pip...done.
sh-3.2$ cd test-nereid-cms-install/
sh-3.2$ source bin/activate
sh-3.2$ which pip
/private/tmp/test-nereid-cms-install/bin/pip
sh-3.2$ pip install trytond-nereid-cms
@sharoonthomas
sharoonthomas / angular-tryton-party-service.js
Created Nov 21, 2014
Example of using angular tryton to fetch parties and addresses
View angular-tryton-party-service.js
'use strict';
angular.module('trytonCrmApp')
.factory('party', [
'session',
function (session) {
var getAll = function (domain, offset, limit) {
return session.rpc('model.party.party.search_read', [
domain || [], offset || null, limit || 20
]);
View keybase.md

Keybase proof

I hereby claim:

  • I am sharoonthomas on github.
  • I am sharoonthomas (https://keybase.io/sharoonthomas) on keybase.
  • I have a public key whose fingerprint is E275 1DEF 5862 5069 F66D 6ED4 F87C 6A2D F9BB 6DF8

To claim this, I am signing this object:

You can’t perform that action at this time.