X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=lhc.py;h=2dbc18b8a5c54ddd83db7a8618fc712e580515b3;hb=e06d92397ba302c665ee9fc4e5c298282624178e;hp=2ff4ee13a469febcc1778a6d536e43b61e74fe26;hpb=aa51e58ee88a4e09e4448dc68d2e6e18deb45d3f;p=burette%2Flhc.git diff --git a/lhc.py b/lhc.py index 2ff4ee1..2dbc18b 100644 --- a/lhc.py +++ b/lhc.py @@ -2,7 +2,7 @@ ############################################################################## # # lhc module for OpenERP, Customize OpenERP for L'Heureux Cyclage Copyright -# (C) 2013-2017 L'Heureux Cyclage () +# (C) 2013-2020 L'Heureux Cyclage () # # This file is a part of lhc_custom_oe # @@ -24,13 +24,123 @@ from openerp.osv import osv from openerp.osv import orm from openerp.osv import fields +import openerp.addons.decimal_precision as dp class res_partner(orm.Model): _inherit = 'res.partner' _columns = { - 'usual_contact': fields.boolean('Usual contact', help='This contact is a usual contact for L\'Heureux Cyclage employees. This field can be used to discriminated contacts for differents usages.'), + 'usual_contact': fields.boolean( + 'Usual contact', + help="""This contact is a usual contact for L\'Heureux Cyclage + employees. This field can be used to discriminated contacts for + differents usages.""" + ), + 'kit_sent': fields.boolean('Welcome kit sent'), } + _defaults = { + 'kit_sent': lambda *a: False, + } + + +class product_template(orm.Model): + _inherit = 'product.template' + + _columns = { + 'standard_price': fields.float( + 'Cost', + digits_compute=dp.get_precision('Product Price'), + help="""Cost price of the product used for standard stock valuation + in accounting and used as a base price on purchase orders.", + groups="base.group_user,lhc.group_volunteer""" + ), + } + + +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) + import pdb + pdb.set_trace() + 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): + """Concat 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 + import pdb + pdb.set_trace() + if mobile: + if phone: + vals['value']['phone'] = '%s - %s' % (phone, mobile) + else: + vals['value']['phone'] = mobile + return vals + + # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: