Skip to content

Instantly share code, notes, and snippets.

@amigrave
amigrave / belly.py
Created July 27, 2018 18:25
Borken ?
while belly.drinks[0].strenght < 3.5:
belly.fill(pub.get_beer())
@amigrave
amigrave / what_i_dont_like_in_django.md
Last active November 23, 2017 16:10
What I don't like in Django

What I don't like in Django

Note: this was written for Django 1.6

ORM

  • South <-> Django troubles with oracle 30char limit (truncate hash not computed the same way due to upper/lower case mismatch)
  • The ORM prefetching on relations is not usefull in many cases because prefetch_related() do not support custom filters. It seems there's a Prefetch class in django 1.7 that finally support the feature but I must say this is quite late to the party compared to the other ORMs considering Django 1.6 is an 8 years old project.
  • When you have a model instance, there's no way to update it using a dict except by iterating the keys and setattr on the object. Can't think of another ORM lacking this feature.
  • Reverse relations should always be explicit. Those automatic/implicit foobar_set makes it hard to follow. AND I MEAN IT !
  • Tuple matrix for choices instead of an OrderedDict !!!
@amigrave
amigrave / gist:6882ef9a924029894648
Last active August 29, 2015 14:08
date_js_to_moment_js.diff
diff --git addons/web/static/src/js/formats.js addons/web/static/src/js/formats.js
index f98e7ca..34eb185 100644
--- addons/web/static/src/js/formats.js
+++ addons/web/static/src/js/formats.js
@@ -114,7 +114,7 @@ instance.web.human_size = function(size) {
instance.web.format_value = function (value, descriptor, value_if_empty) {
var l10n = _t.database.parameters;
var date_format = instance.web.normalize_format(l10n.date_format);
- var time_format = instance.web.normalize_format(l10n.time_format)
+ var time_format = instance.web.normalize_format(l10n.time_format);
@amigrave
amigrave / odoo_keycdn.md
Last active June 3, 2021 23:39
Configure Odoo with Keycdn

Support for CDN has been added to Odoo in master branch.

Just tested with KeyCDN and the setup was straightforward.

##Step 1: Create a pull zone in the KeyCDN dashboard

create a pull zone

While creating the zone, enable the CORS option in the advanced features submenu. (more on that later)

@amigrave
amigrave / snippet_showcase.md
Last active August 3, 2019 10:48
Example of snippet showcase with qweb

A snippets showcase can be added to any page of your theme but it's intended to be used in the demo pages.

In order to make a snippet showcase, you need a div with the class js_snippets_showcase. The content of this div will be parsed as a QWeb (client side) document using the prefix ts. Once parsed, the snippet showcase widget will render the template named main.

Eg:

<div id="js_snippets_showcase">