Skip to content

Instantly share code, notes, and snippets.

View bealdav's full-sized avatar

David Beal bealdav

  • Akretion
  • Lyon
View GitHub Profile
@bealdav
bealdav / http.py
Created August 19, 2020 14:58 — forked from rvalyi/http.py
import logging
import odoo
from odoo import http
from odoo.tools import config
_logger = logging.getLogger(__name__)
# similar to odoo.http.db_monodb but forcing the PRODUCTION_DB database
# in case there are several databases and request (like portal/website)
@bealdav
bealdav / odoo_untranslate_fields.py
Last active April 21, 2023 13:35
Generate Odoo class code to make fields untranslatable
""" You may want some translatable fields in your project becomes untranslatable
Here is how to produce code
Note: to be executed with odoo shell
"""
print('\n'.join(
["\n\nclass %s(models.Model):\n\t_inherit = '%s'\n\t%s = fields.%s(translate=False)" % (
x.model.replace('.', ' ').title().replace(' ', ''), x.model, x['name'], x.ttype.capitalize())
@bealdav
bealdav / csv2xml4odoo.py
Last active April 18, 2024 05:46
Odoo csv / xml converter
# -*- coding: utf-8 -*-
# based on this code
# http://code.activestate.com/recipes/577423-convert-csv-to-xml/
# convert Odoo csv files in xml files
# csv is easy to maintain but xml data have noupdate feature
# Limitations:
# - relation field One2many is NOT supported
# - csv should have 'id' as first column
@bealdav
bealdav / product.py
Created September 21, 2014 11:04
dess
# -*- coding: utf-8 -*-
##############################################################################
#
# licence AGPL version 3 or later
# see licence in __openerp__.py or http://www.gnu.org/licenses/agpl-3.0.txt
# Copyright (C) 2014 Akretion (http://www.akretion.com).
# @author David BEAL <[email protected]>
#
##############################################################################
@bealdav
bealdav / countries_iso3166
Created July 10, 2014 08:13
Query api.geonames.org site to get flat country informations
# -*- coding: utf-8 -*-
"""
Script to update 'countries.py' if needed
"""
from lxml import objectify
import requests
@bealdav
bealdav / vim2komodo_snippets.py
Created March 20, 2014 17:41
Allows to get usable snippets for komodo edit based on vim snippet syntax
#!/usr/bin/env python
""" Convert vim snippets into komdo Edit/IDE snippets
http://www.activestate.com/komodo-edit
"""
"""
snippet browse
self.browse(cr, uid, ${1:ids}, context=context)${2}
=======================================================
@bealdav
bealdav / bash_aliases2fish.py
Created March 16, 2014 15:18
This script allows to convert .bash_aliases file in config.fish used by fish shell command line see http://fishshell.com/
#!/usr/bin python
# -*- coding: utf-8 -*-
"""
This script allows to convert .bash_aliases file
in config.fish used by fish shell command line
see http://fishshell.com/
"""