X-Git-Url: http://git.cyclocoop.org/?p=burette%2Flhc.git;a=blobdiff_plain;f=lhc.py;fp=lhc.py;h=27e14621780de9b2387312ea05258dfe0d629e4b;hp=aefa162d64fbd80382a37d1580bd8a9149f8a652;hb=b55b07d787bf0c2540334c6702cfc9d57f9e6e24;hpb=eb3a3af1f8eab04010a5c94862ca9fb7101690d2 diff --git a/lhc.py b/lhc.py index aefa162..27e1462 100644 --- a/lhc.py +++ b/lhc.py @@ -2,7 +2,7 @@ ############################################################################## # # lhc module for OpenERP, Customize OpenERP for L'Heureux Cyclage Copyright -# (C) 2013-2022 L'Heureux Cyclage () +# (C) 2013-2023 L'Heureux Cyclage () # # This file is a part of lhc_custom_oe # @@ -200,4 +200,26 @@ class event_registration(orm.Model): vals['value']['phone'] = mobile return vals + +class hr_expense_line(orm.Model): + _inherit = 'hr.expense.line' + + def onchange_product_id(self, cr, uid, ids, product_id, context=None): + """Override to manage default name and ref value based on product + properties""" + + vals = super(hr_expense_line, self).onchange_product_id(cr, uid, ids, product_id, context) + res = vals['value'] + if product_id: + product = self.pool.get('product.product').browse(cr, uid, product_id, context=context) + res['ref'] = '' + if product.description: + description = product.description.split('|') + if len(description) == 1: + res['name'] = description[0] + elif len(description) >= 2: + res['name'] = description[0] + res['ref'] = description[1] + return {'value': res} + # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: