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 / odoo-issue-62139_stock_quant.py
Created October 18, 2021 10:02
odoo issue #62139: addon code to fix the issue on the fly
# Copyright 2020 ForgeFlow, S.L. (https://www.forgeflow.com)
# Copyright 2020 Camptocamp
import logging
from odoo import _, models
from odoo.exceptions import UserError
from odoo.tools import float_compare
_logger = logging.getLogger(__name__)
@gurneyalex
gurneyalex / odoo-issue-62139_fix_quant_quantities.py
Created October 18, 2021 09:55
odoo issue #62139 - scheduled action to fix the quants in stock
log('Start fixing stock level')
query = """
WITH product AS
(
select distinct product_id from stock_move where state='done' and create_date > '2020-11-14 00:00:00'
),
location AS (SELECT id AS location_id, usage FROM stock_location),
error_move_lines AS (SELECT * FROM (
SELECT sml.id,
ROW_NUMBER() OVER (PARTITION BY move_id) as row,
@gurneyalex
gurneyalex / odoo-issue-62139_fix_inventory.py
Created October 18, 2021 09:54
odoo issue #62139 - server action to fix inventory theoretical quantities
"""
set model to Inventory, add contextual action
"""
record.line_ids._compute_theoretical_qty()
@gurneyalex
gurneyalex / odoo-issue-62139_create_inventory.py
Last active October 18, 2021 09:53
odoo issue #62139 - scheduled action to create inventory
"""
scheduled action 1
"""
log('Cron: started fix stock level')
query = """
WITH product AS
(
select distinct product_id from stock_move where state='done' and create_date > '2020-11-14 00:00:00'
),
from unittest import TestCase
def some_method(msg):
raise ValueError(msg)
class MyTest(TestCase):
def test_assert_raises_regex(self):
======== Testing test_server.py ========
('command: ', '/entrypoint_image')
* Starting PostgreSQL 9.6 database server 
[ OK ]
Waiting to start psql service.....psql service started.
Working in /home/odoo/build/OCA/server-tools
Using repo odoo/odoo and addons path /home/odoo/build/OCA/server-tools,/home/odoo/odoo-10.0/addons
Modules to test: ['attachment_base_synchronize', 'auditlog', 'auth_admin_passkey', 'auth_ip_access', 'auth_oauth_multi_token', 'auth_signup_verify_email', 'auth_supplier', 'auth_totp', 'auth_totp_password_security', 'auth_user_case_insensitive', 'auto_backup', 'base_cron_exclusion', 'base_custom_info', 'base_directory_file_download', 'base_exception', 'base_export_manager', 'base_export_security', 'base_external_dbsource', 'base_external_dbsource_firebird', 'base_external_dbsource_mssql', 'base_external_dbsource_mysql', 'base_external_dbsource_odbc', 'base_external_dbsource_oracle', 'base_external_dbsource_sqlite', 'base_external_system', 'base_fontawesome', 'base_import_
@gurneyalex
gurneyalex / test_logistics_load.py
Created September 5, 2019 08:15
Odoo logistics load script
# -*- coding: utf-8 -*-
# Copyright 2017 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
import datetime
import random
from freezegun import freeze_time
import time
def create_products(ctx, nb_products=15000):
vals = []
@gurneyalex
gurneyalex / odoo-bin
Created August 1, 2019 08:20
odoo-bin wrapper which computes addons path and creates the config file
#!/bin/sh
ROOT=$(dirname $0)/..
CONF=${ROOT}/odoo.conf
ODOODIR=${ROOT}/src
ODOOBIN="${ODOODIR}/odoo-bin --config=${CONF}"
ADDONS_PATH=${ROOT}/local-src,${ROOT}/external-src/enterprise,${ODOODIR}/odoo/addons,${ODOODIR}/addons
for d in ${ROOT}/external-src/*
do
if [ $d != enterprise ]
@gurneyalex
gurneyalex / testiconv.c
Created June 18, 2019 20:45
Test C program for iconv with translit
#include <iconv.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <locale.h>
int main(){
iconv_t cd;
cd = iconv_open("ascii//TRANSLIT", "utf-8");
-- 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);