[REF] event_sale: code cleaning

bzr revid: qdp-launchpad@openerp.com-20120227171043-q79pyhcea1fkibed
This commit is contained in:
Quentin (OpenERP) 2012-02-27 18:10:43 +01:00
parent 08be795ef0
commit 10bf3af65a
2 changed files with 34 additions and 33 deletions

View File

@ -48,8 +48,6 @@ class event_moodle(osv.osv):
self.write(cr, uid, ids, {'url': url})
return {'type': 'ir.actions.act_window_close'}
def find(self, cr, uid, context=None):
"""
Find the config wizard containing the configuration and raise and error if none is available.

View File

@ -19,8 +19,9 @@
#
##############################################################################
from osv import fields, osv
from tools.translate import _
class product(osv.osv):
_inherit = 'product.product'
_columns = {
@ -54,7 +55,7 @@ class sale_order_line(osv.osv):
"""
check product if event type
"""
res = super(sale_order_line,self).product_id_change(cr,uid,ids,pricelist, product, qty,uom, qty_uos, uos, name, partner_id,lang, update_tax, date_order, packaging, fiscal_position, flag,context)
res = super(sale_order_line,self).product_id_change(cr, uid, ids, pricelist, product, qty=qty, uom=uom, qty_uos=qty_uos, uos=uos, name=name, partner_id=partner_id, lang=lang, update_tax=update_tax, date_order=date_order, packaging=packaging, fiscal_position=fiscal_position, flag=flag, context=context)
if product:
product_res = self.pool.get('product.product').browse(cr, uid, product, context=context)
if product_res.event_type_id:
@ -66,22 +67,24 @@ class sale_order_line(osv.osv):
create registration with sale order
'''
for registration in self.browse(cr,uid,ids,context=context):
if registration.event.id:
registration_obj = self.pool.get('event.registration')
sale_obj = self.pool.get('sale.order')
for order_line in self.browse(cr, uid, ids, context=context):
if order_line.event.id:
dic = {
'name':registration.order_id.partner_invoice_id.name,
'partner_id':registration.order_id.partner_id.id,
'contact_id':registration.order_id.partner_invoice_id.id,
'nb_register':int(registration.product_uom_qty),
'email':registration.order_id.partner_id.email,
'phone':registration.order_id.partner_id.phone,
'street':registration.order_id.partner_invoice_id.street,
'city':registration.order_id.partner_invoice_id.city,
'origin':registration.order_id.name,
'event_id':registration.event.id,
'name': order_line.order_id.partner_invoice_id.name,
'partner_id': order_line.order_id.partner_id.id,
'contact_id': order_line.order_id.partner_invoice_id.id,
'nb_register': int(order_line.product_uom_qty),
'email': order_line.order_id.partner_id.email,
'phone': order_line.order_id.partner_id.phone,
'street': order_line.order_id.partner_invoice_id.street,
'city': order_line.order_id.partner_invoice_id.city,
'origin': order_line.order_id.name,
'event_id': order_line.event.id,
}
self.pool.get('event.registration').create(cr,uid,dic,context=context)
message = ("A registration is create from the %s sale order.") % (registration.order_id.name,)
self.pool.get('event.registration').log(cr, uid, registration.event.id, message)
return super(sale_order_line, self).button_confirm(cr, uid, ids, context)
registration_id = registration_obj.create(cr, uid, dic, context=context)
message = _("The registration %s has been created from the Sale Order %s.") % (registration_id, order_line.order_id.name)
registration_obj.log(cr, uid, registration_id, message)
return super(sale_order_line, self).button_confirm(cr, uid, ids, context=context)