Skip to content

Instantly share code, notes, and snippets.

View sharoonthomas's full-sized avatar

Sharoon Thomas sharoonthomas

View GitHub Profile
@sharoonthomas
sharoonthomas / date_time_tz_mess.py
Created August 19, 2016 13:22
Difference between using pytz.localize and datetime.replace
from datetime import date, time, datetime
import pytz
pacific = pytz.timezone('US/Pacific')
eastern = pytz.timezone('US/Eastern')
def get_naive_date_time():
date_start = date(2016, 9, 16)
time_start = time(10, 0)
@sharoonthomas
sharoonthomas / FULFIL_CLA
Last active March 20, 2019 10:29
Contributor License Agreement (CLA)
# Fulfil.IO Open Source Projects Individual Contributor License Agreement
Thank you for your interest in contributing to Fulfil.IO Open Source Projects ("We" or "Us").
This contributor agreement ("Agreement") documents the rights granted by contributors to Us. To make this document effective, please sign it and send it to Us by electronic submission, following the instructions at . This is a legally binding document, so please read it carefully before agreeing to it. The Agreement may cover more than one software project managed by Us.
## 1. Definitions
"You" means the individual who Submits a Contribution to Us.
@sharoonthomas
sharoonthomas / pull_fulfil_activity_stream.py
Created November 20, 2018 19:22
Utilize Fulfil API to download complete Activity Stream Data history
import requests
import pandas as pd
from pandas.io.json import json_normalize
import numpy as np
import os
import json
from google.cloud import storage, bigquery
import datetime
import time
from multiprocessing.pool import ThreadPool
@sharoonthomas
sharoonthomas / update_supplier_prices.py
Last active September 26, 2018 20:54
Update the supplier prices over API by reading a CSV file with sku, supplier_name and price
import os
import csv
import sys
from decimal import Decimal
from fulfil_client import Client
client = Client(
os.environ.get('FULFIL_SUBDOMAIN'),
os.environ.get('FULFIL_API_KEY'),
@sharoonthomas
sharoonthomas / read_report.py
Created August 29, 2018 15:18
Reading Fulfil interactive reports from API
from datetime import date
from fulfil_client import Client
fulfil = Client('<subdomain>', '<apikey>')
# Fetch the report instance
# The name can be obtained from the URL
report = fulfil.interactive_report('account.invoice.revenue_by_month.ireport')
# Trigger execution with the fields
@sharoonthomas
sharoonthomas / PO-CSV.jinja
Created January 1, 2018 16:59
Jinja2 template for rendering PO lines as a CSV file on fulfil.io
"Po number","Ship to Name","Ship to address","Ship to phone number","Product name","Our SKU","Your SKU","Quantity","Amount"
{% for record in records -%}
{% for line in record.lines %}"{{ [
line.purchase.number,
line.purchase.customer and line.purchase.customer.name,
line.purchase.customer and line.purchase.delivery_address.full_address.replace('\r\n', ','),
line.purchase.customer and line.purchase.customer.phone,
line.supplier_product_name or line.description,
line.product and line.product.code,
line.supplier_product_code or '',
@sharoonthomas
sharoonthomas / fulfil-inventory-planner.py
Created November 27, 2017 17:51
This example shows how to fetch data for inventory-planner.com from Fulfil. The code is written to be compatible with any kitchensinks.
import unicodecsv as csv
from kitchensink.extensions import fulfil
Product = fulfil.model('product.product')
SaleLine = fulfil.model('sale.line')
PurchaseLine = fulfil.model('purchase.line')
def format_product(product):
@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 / get_inventory.py
Created September 21, 2016 16:13
Finding products and their inventory using Fulfil REST API (python example)
import os
from pprint import pprint
from fulfil_client import Client
client = Client(os.environ['FULFIL_SUBDOMAIN'], os.environ['FULFIL_API_KEY'])
Product = client.model('product.product')
@sharoonthomas
sharoonthomas / sse.html
Created June 5, 2013 08:07
Example of SSE using flask. The html template should be in the templates folder
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="//code.jquery.com/jquery-1.8.0.min.js"></script>
<script type="text/javascript">
$(document).ready(
function() {
sse = new EventSource('/my_event_source');
sse.onmessage = function(message) {