+class res_users(orm.Model):
+ _inherit = 'res.users'
+
+ def onchange_partner_id(self, cr, uid, ids, partner_id, login):
+ """Define user email address from partner email address"""
+ v = {}
+ partners = self.pool.get('res.partner')
+ partner = partners.browse(cr, uid, partner_id)
+ if partner.email:
+ v['email'] = partner.email
+ else:
+ v = {}
+ return {'value': v}
+
+
+class event_event(orm.Model):
+ _inherit = 'event.event'
+
+ _columns = {
+ 'duration': fields.float(
+ 'Duration',
+ digits_compute=dp.get_precision('Product Unit of Measure'),
+ help='Duration in hours'
+ ),
+ }
+
+
+class event_registration(orm.Model):
+ _inherit = 'event.registration'
+
+ _columns = {
+ 'gender': fields.selection([
+ ('female', 'Female'),
+ ('male', 'Male'),
+ ('other', 'Other')],
+ 'Gender'),
+ 'position': fields.selection([
+ ('employee', 'Employee'),
+ ('individual', 'Invividual'),
+ ('volunteer', 'Volunteer')],
+ 'Position'),
+ 'funding_main': fields.selection([
+ ('individual', 'Individual'),
+ ('opco', 'OPCO'),
+ ('company', 'Company'),
+ ('pole_emploi', 'Pole Emploi')],
+ 'Main funding', help='Main funding origin'),
+ 'fundings_others': fields.char('Others fundings origins', size=128),
+ 'sale_order_ids': fields.many2many(
+ 'sale.order',
+ 'event_registration_sale_order_rel',
+ 'event_registration_id',
+ 'sale_order_id',
+ 'Related sale order(s)'
+ ),
+ 'invoice_ids': fields.many2many(
+ 'account.invoice',
+ 'event_registration_invoice_id_rel',
+ 'event_registration_id',
+ 'invoice_id',
+ 'Related invoice(s)'
+ ),
+ }
+
+ def onchange_contact_id(self, cr, uid, ids, contact, partner, context=None):
+ """Contcat phone with mobile phone if exist. If mobile exist and not
+ phone, add mobile number"""
+ vals = super(event_registration, self).onchange_contact_id(cr, uid, ids, contact, partner, context)
+ addr_obj = self.pool.get('res.partner')
+ contact_id = addr_obj.browse(cr, uid, contact, context=context)
+ phone = vals['value']['phone']
+ mobile = contact_id.mobile
+ if mobile:
+ if phone:
+ vals['value']['phone'] = '%s - %s' % (phone, mobile)
+ else:
+ 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}
+