Skip to content

Instantly share code, notes, and snippets.

@nbessi
nbessi / template_org.el
Created April 7, 2016 11:58
org-mode latex syling
(require 'ox-latex)
(unless (boundp 'org-latex-classes)
(setq org-latex-classes nil))
(add-to-list 'org-latex-classes
'("doc_vaud"
"\\documentclass[french,fleqn,10pt,hidelinks]{article}
\\usepackage[utf8]{inputenc}
\\usepackage{titling}
\\usepackage{babel}
@nbessi
nbessi / toggle_menu.js
Created June 30, 2015 12:43
Toggle left panel in Odoo 8 and add a widget button in menubar
openerp.web.Menu.include({
/**
* Enable left menu to be toggled
*/
show_nav_bar: function() {
@nbessi
nbessi / gist:5643542
Created May 24, 2013 13:34
You can use ir.values in OpenERP to force an action on a hierarchical tree view when you click on a row
<!-- Opening task when double clicking on project -->
<record id="dblc_proj" model="ir.actions.act_window">
<field name="res_model">project.task</field>
<field name="name">Project's tasks</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form,calendar,graph,gantt,kanban</field>
<field name="domain">[('project_id', 'child_of', [active_id])]</field>
<field name="context">{'project_id':active_id, 'active_test':False}</field>
</record>
(ns repl.xml_to_csv
(:use [hiccup.core]
[clojure-csv.core :as csv]))
(defn csv-data [] (csv/parse-csv (slurp "/Users/nbessi/Downloads/doc/zip.csv")))
(defn render-line [line]
(html [:record {:id (line 0), :model "res.better.zip"}
[:field {:name "name"} (line 1)]
[:field {:name "city"} (line 2)]
[:field {:name "state_id", :ref (str "state_" (line 3))}]
@nbessi
nbessi / gist:1944505
Created February 29, 2012 21:23
Tough on OERPScenario DSL
using https://github.com/rvalyi/ooor/pull/81 in background
Given I find or create by login a ResUsers "admin" with
| key | val |
| partner_id | find by xml_id blabla |
#or
| partner_id | find by name and login! Pinky, daBoss |
and why not
@nbessi
nbessi / gist:1931739
Created February 28, 2012 10:17
PGSQL OpenERP traceback 6.1
#Removed some output related to extra-addons
STATEMENT: ALTER TABLE "res_partner_address" ALTER COLUMN "country_id" SET NOT NULL
ERROR: column "smtp_host" contains null values
STATEMENT: ALTER TABLE "ir_mail_server" ALTER COLUMN "smtp_host" SET NOT NULL
@nbessi
nbessi / gist:1351717
Created November 9, 2011 15:11
Decorator with boilerplate for OSV methods.
#Thanks to Florent for the function.
#Really useful.
def osv_method(f):
"""Decorator with boilerplate for OSV methods."""
args, varargs, kwargs, defaults = getargspec(f)
len_argspec = len(args) - 4
# Sanity check: no *args or **kwargs parameters
MYCONST = ('new_val', 'New Label')
class Partner(osv.osv):
"""My Stuff"""
_inherit = 'res.partner'
def __init__(self, pool, cursor):
"""Hack due to the lack of selection fields inheritance mechanism."""
super(Partner, self).__init__(pool, cursor)
@nbessi
nbessi / gist:1270572
Created October 7, 2011 15:42
GeoEngine Relational ORM support
print self.geo_search(cursor, uid, domain=[('name', 'ilike', 'Lausanne')], geo_domain=[('the_geom', 'geo_greater', Polygon([(3, 0), (4, 1), (4, 0)]))])
print self.geo_search(cursor, uid, domain=[('name', 'ilike', 'Lausanne')], geo_domain=[('the_geom', 'geo_greater', 0)])
print self.geo_search(cursor, uid, domain=[('name', 'ilike', 'Lausanne')], geo_domain=[('the_geom', 'geo_intersect', {'geoengine.demo.automatic.retailing.machine.the_point': []})])
print self.geo_search(cursor, uid, domain=[('name', 'ilike', 'Lausanne')], geo_domain=[('the_geom', 'geo_intersect', {'geoengine.demo.automatic.retailing.machine.the_point': [('name','!=','Vallorbe')]})])
#will generate
"""
SELECT "res_better_zip".id FROM "res_better_zip" WHERE (res_better_zip."name" ilike E'%Lausanne%') AND ST_Area(res_better_zip.the_geom) > ST_Area(ST_GeomFromText('POLYGON ((3.0000000000000000 0.0000000000000000, 4.0000000000000000 1.0000000000000000, 4.0000000000000000 0.0000000000000000, 3.0000000000000000 0.0000000000000000))')) ORDER BY pr
@nbessi
nbessi / gist:1200785
Created September 7, 2011 14:54
GeoEngine CRUD support phase 1
from shapely.wkt import dumps as wktdumps, loads as wktloads
from shapely.geometry import Polygon, MultiPolygon
import geojson
from base_geoengine import geo_model
class NPA(geo_model.GeoModel):
_inherit = "res.better.zip"
_columns = {
'the_geom' : fields.geo_multi_polygon('NPA Shape', required=False),