Skip to content

Instantly share code, notes, and snippets.

View gurneyalex's full-sized avatar
💭
Don't ping me on github. Send me an email.

Alexandre Fayolle gurneyalex

💭
Don't ping me on github. Send me an email.
View GitHub Profile
@gurneyalex
gurneyalex / filter_creation.feature
Created November 14, 2013 09:00
How to create a global ir.filter in OpenERP with OERPScenario
Feature: create filter example
Scenario: create a global sale.order filter
Given I need a "ir.filters" with oid: scen.delivered_sale_orders
And having:
| name | value |
| name | Delivered |
| domain | [('shipped_check', '=', True)] |
| model_id | sale.order |
| context | {} |
| user_id | False |
@gurneyalex
gurneyalex / fix_sudo.sh
Created May 14, 2015 20:01
OCA sudo commit script
#/bin/bash
set -x
for repo in */
do
pushd $repo
reponame=$(basename $repo)
echo $reponame
git fetch origin
for version in 6.1 7.0 8.0
do
2947854-7-0-5b1147-base=# select name, author from ir_module_module where state='installed';
name | author
-----------------------------+------------------------------------------------------------------------
web_calendar |
web |
web_m2x_options | Tuxservices,Odoo Community Association (OCA)
auth_signup | OpenERP SA
web_list_html_widget | initOS GmbH & Co. KG,Odoo Community Association (OCA)
web_recipients_uncheck | initOS GmbH & Co. KG,Odoo Community Association (OCA)
web_search_alphabetic | Serpent Consulting Services Pvt. Ltd.,Odoo Community Association (OCA)
class A(Model):
def _compute_B_count(self):
query = 'select a.id, count(b.id) from a right outer join b on (a.id=b.a_id) where a.id = ANY(%s)'
self.env.cr.execute(query, self.ids)
counts = dict(self.env.cr.fetchall())
for rec in self:
rec.count = counts[rec.id]
SELECT
t.tablename,
indexname,
c.reltuples AS num_rows,
pg_size_pretty(pg_relation_size(quote_ident(t.tablename)::text)) AS table_size,
pg_size_pretty(pg_relation_size(quote_ident(indexrelname)::text)) AS index_size,
CASE WHEN indisunique THEN 'Y'
ELSE 'N'
END AS UNIQUE,
idx_scan AS number_of_scans,
import numpy.table
from unittest.mock import MagickMock
numpy.table.even = MagickMock(return_value=True)
@gurneyalex
gurneyalex / odooclient.py
Created January 16, 2017 16:25
interacting with web page auth='user'
import requests
import random
server = 'http://localhost:8069'
session = requests.Session()
session.headers.update({'Content-Type': 'application/json'})
data = {"jsonrpc": "2.0",
"id": random.randint(0, 1000000000),
"method": "call",
diff --git a/addons/auth_crypt/models/res_users.py b/addons/auth_crypt/models/res_users.py
index 708998a..2c7d9b8 100644
--- a/addons/auth_crypt/models/res_users.py
+++ b/addons/auth_crypt/models/res_users.py
@@ -28,11 +28,11 @@ class ResUsers(models.Model):
def init(self):
_logger.info("Hashing passwords, may be slow for databases with many users...")
- self.env.cr.execute("SELECT id, password FROM res_users"
- " WHERE password IS NOT NULL"
session.open()
cr, uid = session.cr, 1
Move = session.registry('stock.move')
Loc = session.registry('stock.location')
PackOp = session.registry('stock.pack.operation')
Pick = session.registry('stock.picking')
m1_ids = Move.search(cr, uid, [('picking_id.picking_type_id', '=', 11), ('state', '=', 'done'), ('move_dest_id.state', '=', 'assigned')])
m1 = Move.browse(cr, uid, m1_ids)
m2_ids = [m.move_dest_id.id for m in m1]
-- in restored dump
COPY (
SELECT t.id, e.identification_id
FROM transport_order t JOIN hr_employee e ON (t.driver_id = e.id)
) TO '/tmp/transport.dat'
WITH (FORMAT binary);
-- in production database
CREATE TABLE tmp_transport (id INTEGER, driver VARCHAR);
COPY tmp_transport FROM '/tmp/transport.dat' WITH (FORMAT binary);