Skip to content

Instantly share code, notes, and snippets.

View sharoonthomas's full-sized avatar

Sharoon Thomas sharoonthomas

View GitHub Profile
@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 / freshplug.html
Created October 10, 2016 11:37
Fulfil.IO Freshdesk Plugin
<div id="fulfil_widget" class="widget" title="Fulfil.IO">
<div>
<h4>Fulfil.IO</h4>
<img src="https://www.fulfil.io/static/images/favicon@128.png" height="40px" class="img img-responsive pull-right"/>
</div>
<div class="content" id="fulfil-content">Loading..</div>
<div class="error" id="fulfil-error"></div>
</div>
<script type="text/template" id="contact-template">
<h6>Found <%= _.keys(contacts).length %> contact(s)</h6>
@sharoonthomas
sharoonthomas / README.md
Last active September 29, 2016 19:51
Get addresses with contact information over fulfil.io api

Set the environment variables:

export FULFIL_SUBDOMAIN=your_subdomain
export FULFIL_API_KEY=a-long-api-key-which-is-secret

Install the dependencies

@sharoonthomas
sharoonthomas / move_inventory.py
Created September 23, 2016 18:47
An example script to move all the inventory from one location to another. Usually used when you are merging location for example.
import os
from fulfil_client import Client
client = Client(
os.environ['FULFIL_SUBDOMAIN'],
os.environ['FULFIL_API_KEY']
)
@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 / README.md
Created September 8, 2016 20:39
Fulfil.IO Javascript/Node API

API Overview

Get a Fulfil client instance to .

var fulfil = require('fulfil');
var fulfilClient = require('fulfil').client('<subdomain>', '<api-key>');

Get a specific resource

@sharoonthomas
sharoonthomas / get_shipments.py
Created September 2, 2016 19:40
Get shipments from fulfil using API
import os
from datetime import date
from pprint import pprint
from fulfil_client import Client
client = Client('<subdomain>', os.environ['FULFIL_API_KEY'])
@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 / account_balance_test.diff
Created August 16, 2016 20:22
Party payable and receivable seems to be incorrect if the balances are checked after closing fiscal year
diff --git a/tests/test_account.py b/tests/test_account.py
index b0aef15..6651b9b 100644
--- a/tests/test_account.py
+++ b/tests/test_account.py
@@ -735,6 +735,11 @@ class AccountTestCase(ModuleTestCase):
Journal = pool.get('account.journal')
Account = pool.get('account.account')
Move = pool.get('account.move')
+ Period = pool.get('account.period')
+ AccountType = pool.get('account.account.type')