Skip to content

Instantly share code, notes, and snippets.

View gdgellatly's full-sized avatar

Graeme Gellatly gdgellatly

View GitHub Profile
@gdgellatly
gdgellatly / dynamic_labels.xml
Last active October 16, 2023 23:34
Dynamic Field Labels
<group name="custom_questions" >
<label
for=""
attrs="{'invisible': [('internal_question_count', '&lt;', 1)]}"
>
<field name="internal_question_1_label" nolabel="1" attrs="{'invisible': [('internal_question_count', '&lt;', 1)]}" class="o_form_label" readonly="1"/>
</label>
<field
name="internal_question_1_answer"
attrs="{'invisible': [('internal_question_count', '&lt;', 1)]}"
@gdgellatly
gdgellatly / stock_quant.py
Last active June 23, 2022 08:50
Unreserve during update_reserved_quantity
# Copyright 2022 Graeme Gellatly
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import api, models
from odoo.tools.float_utils import float_compare
class StockQuant(models.Model):
_inherit = "stock.quant"
@gdgellatly
gdgellatly / TestPurchase.py
Created December 20, 2016 20:40
Sample Hypothesis Test File for Openerp v7
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP / Odoo, Open Source Management Solution - module extension
# Copyright (C) 2014- O4SB (<http://openforsmallbusiness.co.nz>).
# Author Graeme Gellatly <g@o4sb.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
@gdgellatly
gdgellatly / regexes
Created March 9, 2015 23:51
Useful Odoo Regexes
Pycharm Find and Replace
self.pool.get\(('[\w\.]+')\)
self.pool[$1]
class StockMove(orm.Model):
_inherit = 'stock.move'
_order = 'date desc'
def _get_reference_accounting_values_for_valuation(self, cr, uid, move,
context=None):
"""
Return the reference amount and reference currency
representing the inventory valuation for this move.
These reference values should possibly be converted
before being posted in Journals to adapt to the primary