Skip to content

Instantly share code, notes, and snippets.

View simahawk's full-sized avatar

Simone Orsi simahawk

View GitHub Profile
@simahawk
simahawk / address_example.xml
Last active February 16, 2017 09:17
create/update Prestashop manufacturer - webservice requests
<!-- http://ps.url/api/addresses -->
<?xml version="1.0" encoding="UTF-8"?>
<prestashop>
<address>
<city>Lausanne Ouchy</city>
<id_manufacturer>13</id_manufacturer>
<firstname>Test</firstname>
<id_country>19</id_country>
<phone>123321321</phone>
<address1>Street 1</address1>
@simahawk
simahawk / README.md
Created February 11, 2017 13:31 — forked from magnetikonline/README.md
Minimum Open Graph tags required for a webpage - for use with Facebook.

Open Graph tags for page <head>.

<meta property="og:title" content="title" />
<meta property="og:description" content="desc" />
<meta property="og:type" content="website" />
<meta property="og:url" content="http://url.com/" />
<meta property="og:image" content="http://url.com/image.jpg" />
@simahawk
simahawk / README.md
Created February 11, 2017 13:31 — forked from magnetikonline/README.md
Minimum Open Graph tags required for a webpage - for use with Facebook.

Open Graph tags for page <head>.

<meta property="og:title" content="title" />
<meta property="og:description" content="desc" />
<meta property="og:type" content="website" />
<meta property="og:url" content="http://url.com/" />
<meta property="og:image" content="http://url.com/image.jpg" />
@simahawk
simahawk / timeit.py
Created October 4, 2016 14:09
time your python functions
import time
def timeit(method):
"""Decorate methods to measure time."""
def timed(*args, **kw):
print 'START', method.__name__
ts = time.time()
result = method(*args, **kw)
te = time.time()
@simahawk
simahawk / res_config.py
Created October 3, 2016 14:56
Odoo - add website configuration
class WebsiteConfigSettings(models.TransientModel):
"""Override website config model."""
_inherit = "website.config.settings"
my_new_field = fields.Char(
string='My field',
related='website_id.my_new_field'
@simahawk
simahawk / example.xml
Created September 28, 2016 06:53
Odoo binary field: keep uploaded filename
<!--
you must have 2 fields on your model:
* the binary field `my_file`
* a char field for filename `my_file_fname`
-->
<field name="my_file" filename="my_file_fname" />
<field name="my_file_fname" invisible="1" />
@simahawk
simahawk / docker_commands.sh
Created September 19, 2016 07:41
docker commands cheatsheet
# remove all images "months" old
docker images -a | grep 'months ago' | awk '{print $3}' | xargs --no-run-if-empty docker rmi
# remove all dangling images
docker rmi $(docker images -f "dangling=true" -q)
# remove all containers "months" old
docker ps -a | grep 'months ago' | awk '{print $1}' | xargs --no-run-if-empty docker rm
# remove all containers exited
@simahawk
simahawk / odoo_openchatter_custom.py
Created September 19, 2016 06:49
Odoo - custom openchatter message on fields update
def _message_order_formatter(subj, line, changed, old):
"""Format mail msg for update order lines log.
@param subj: subject of the message
@param line: order line
@param changed: mapping of changed field values
@param old: mapping of old field values
"""
mess = subj + "<ul>"
for fname, value in changed.iteritems():
@simahawk
simahawk / reset.sql
Created September 16, 2016 09:23
odoo - reset installed module version
mydb=# select id, name, latest_version, published_version from ir_module_module where name = 'mymodule';
id | name | latest_version | published_version
-----+-------------+----------------+-------------------
310 | mymodule | 9.0.2.0.1 |
(1 row)
mydb=# update ir_module_module set latest_version='9.0.1.0.1' where id = 310;
@simahawk
simahawk / openerp nosetests
Last active June 16, 2017 13:15
Odoo nosetests how to configure and run
[openerp]
eggs += nose
openerp_scripts = nosetests command-line-options=-d openerp-log-level=WARN