[IMP]: event: Add currency field.Improve registration view.

bzr revid: atp@tinyerp.co.in-20100630142159-7vxbjdhqa5doya13
This commit is contained in:
atp (Open ERP) 2010-06-30 19:51:59 +05:30
parent d36d14ffbf
commit ab3047a80a
5 changed files with 174 additions and 97 deletions

View File

@ -51,6 +51,7 @@
'security/event_security.xml',
'security/ir.model.access.csv',
'wizard/event_make_invoice_view.xml',
'wizard/partner_event_registration_view.xml',
'board_association_view.xml',
],
'demo_xml': ['event_demo.xml', 'board_association_demo.xml'],

View File

@ -35,7 +35,6 @@ class event_type(osv.osv):
_columns = {
'name': fields.char('Event type', size=64, required=True),
}
event_type()
class event_event(osv.osv):
@ -44,7 +43,14 @@ class event_event(osv.osv):
_description = __doc__
_inherit = 'crm.case.section'
_order = 'date_begin'
def _get_currency(self, cr, uid, context):
user = self.pool.get('res.users').browse(cr, uid, [uid])[0]
if user.company_id:
return user.company_id.currency_id.id
else:
return self.pool.get('res.currency').search(cr, uid, [('rate','=',1.0)])[0]
def copy(self, cr, uid, id, default=None, context=None):
""" Copy record of Given id
@param id: Id of Event Registration type record.
@ -57,6 +63,14 @@ class event_event(osv.osv):
'state': 'draft'
})
return super(event_event, self).copy(cr, uid, id, default=default, context=context)
def onchange_product(self, cr, uid, ids, product_id):
if not product_id:
return {'value': {'unit_price': False}}
else:
unit_price=self.pool.get('product.product').price_get(cr, uid, [product_id])[product_id]
return {'value': {'unit_price': unit_price}}
def button_draft(self, cr, uid, ids, context=None):
return self.write(cr, uid, ids, {'state': 'draft'}, context=context)
@ -88,6 +102,7 @@ class event_event(osv.osv):
@param context: A standard dictionary for contextual values
@return: Dictionary of function fields value.
"""
register_pool = self.pool.get('event.registration')
res = {}
for event in self.browse(cr, uid, ids, context):
@ -103,11 +118,11 @@ class event_event(osv.osv):
reg_ids = register_pool.search(cr, uid, [
('event_id', '=', event.id),
('state', 'in', state)])
if 'register_current' in fields:
res[event.id]['register_current'] = len(reg_ids)
if 'register_prospect' in fields:
res[event.id]['register_prospect'] = len(reg_ids)
return res
@ -142,6 +157,7 @@ class event_event(osv.osv):
register_pool.write(cr, uid, reg_ids, register_values)
return res
_columns = {
'type': fields.many2one('event.type', 'Type', help="Type of Event like Seminar, Exhibition, Conference, Training."),
'register_max': fields.integer('Maximum Registrations', help="Provide Maximun Number of Registrations"),
@ -157,15 +173,20 @@ class event_event(osv.osv):
'mail_registr': fields.text('Registration Email', help='This email will be sent when someone subscribes to the event.'),
'mail_confirm': fields.text('Confirmation Email', help="This email will be sent when the event gets confimed or when someone subscribes to a confirmed event. This is also the email sent to remind someone about the event."),
'product_id': fields.many2one('product.product', 'Product', required=True, help="Product which is provided cost of event. Invoice of event will be created with this Product."),
'note': fields.text('Notes', help="Description or Summary of Event")
'note': fields.text('Notes', help="Description or Summary of Event"),
'currency_id': fields.many2one('res.currency', 'Currency', required=True, readonly=True, states={'draft':[('readonly',False)]}),
"unit_price": fields.float('Cost'),
}
_defaults = {
'state': 'draft',
'code': lambda obj, cr, uid, context: obj.pool.get('ir.sequence').get(cr, uid, 'event.event'),
# 'code': lambda obj, cr, uid, context: obj.pool.get('ir.sequence').get(cr, uid, 'event.event'),
'user_id': lambda obj, cr, uid, context: uid,
'currency_id': _get_currency,
}
event_event()
class event_registration(osv.osv):
@ -192,13 +213,16 @@ and users by email"),
"invoice_id": fields.many2one("account.invoice", "Invoice"),
'date_closed': fields.datetime('Closed', readonly=True),
'ref': fields.reference('Reference', selection=crm._links_get, size=128),
'ref2': fields.reference('Reference 2', selection=crm._links_get, size=128),
'ref2': fields.reference('Reference 2', selection=crm._links_get, size=128),
'message_ids': fields.one2many('mailgate.message', 'res_id', 'Messages', domain=[('history', '=', True),('model','=',_name)]),
'log_ids': fields.one2many('mailgate.message', 'res_id', 'Logs', domain=[('history', '=', False),('model','=',_name)]),
'currency_id': fields.many2one('res.currency', 'Currency', readonly=True),
}
_defaults = {
'nb_register': 1,
'tobe_invoiced': True,
'name': 'Registration',
# 'currency_id': _get_currency,
}
def _make_invoice(self, cr, uid, reg, lines, context=None):
@ -302,7 +326,7 @@ and users by email"),
if total_confirmed <= registration.event_id.register_max or registration.event_id.register_max == 0:
self.write(cr, uid, [registration.id], {'state': 'open'}, context=context)
self.mail_user(cr, uid, [registration.id])
self._history(cr, uid, [registration.id], _('Open'))
self._history(cr, uid, [registration], _('Open'))
else:
unconfirmed_ids.append(registration.id)
if unconfirmed_ids:
@ -343,6 +367,7 @@ and users by email"),
values['date_deadline']= event.date_begin
values['description']= event.mail_confirm
values['currency_id'] = event.currency_id.id
res = super(event_registration, self).create(cr, uid, values, context=context)
registrations = self.browse(cr, uid, [res], context=context)
self._history(cr, uid, registrations, _('Created'))
@ -354,7 +379,6 @@ and users by email"),
values['date_deadline']= event.date_begin
values['description']= event.mail_confirm
return super(event_registration, self).write(cr, uid, ids, values, context=context)
def mail_user(self, cr, uid, ids, confirm=False, context=None):
"""
@ -434,14 +458,16 @@ and users by email"),
return {'value': {'unit_price': False, 'event_product': False}}
data_event = self.pool.get('event.event').browse(cr, uid, event_id)
context['currency_id'] = data_event.currency_id.id
if data_event.product_id:
if not partner_invoice_id:
unit_price=self.pool.get('product.product').price_get(cr, uid, [data_event.product_id.id], context=context)[data_event.product_id.id]
return {'value': {'unit_price': unit_price, 'event_product': data_event.product_id.name}}
return {'value': {'unit_price': unit_price, 'event_product': data_event.product_id.name, 'currency_id': data_event.currency_id.id}}
data_partner = self.pool.get('res.partner').browse(cr, uid, partner_invoice_id)
context.update({'partner_id': data_partner})
unit_price = self.pool.get('product.product')._product_price(cr, uid, [data_event.product_id.id], False, False, {'pricelist': data_partner.property_product_pricelist.id})[data_event.product_id.id]
return {'value': {'unit_price': unit_price, 'event_product': data_event.product_id.name}}
return {'value': {'unit_price': unit_price, 'event_product': data_event.product_id.name, 'currency_id': data_event.currency_id.id}}
return {'value': {'unit_price': False, 'event_product': False}}
@ -489,6 +515,5 @@ and users by email"),
event_registration()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -51,10 +51,12 @@
<field name="user_id" select="1"/>
<field name="date_begin" select="1"/>
<field name="date_end"/>
<field name="product_id"/>
<field name="product_id" on_change="onchange_product(product_id)"/>
</group>
<notebook colspan="4">
<page string="General">
<field name="unit_price"/>
<field name="currency_id"/>
<separator string="Event description" colspan="4"/>
<field name="parent_id" domain="[('parent_id','child_of','Event')]"/>
<field name="active"/>
@ -118,6 +120,33 @@
</tree>
</field>
</record>
<record id="view_event_calendar" model="ir.ui.view">
<field name="name">event.event.calendar</field>
<field name="model">event.event</field>
<field name="type">calendar</field>
<field eval="2" name="priority"/>
<field name="arch" type="xml">
<calendar color="user_id" date_start="date_begin" string="Event Organization">
<field name="name"/>
<field name="type"/>
</calendar>
</field>
</record>
<record model="ir.ui.view" id="view_event_graph">
<field name="name">Event Graph</field>
<field name="model">event.event</field>
<field name="type">graph</field>
<field name="arch" type="xml">
<graph string="Event by Registration" type="bar" orientation="horizontal">
<field name="name"/>
<field name="register_current" operator="+"/>
<field name="register_prospect" operator="+"/>
</graph>
</field>
</record>
<record model="ir.ui.view" id="view_event_search">
<field name="name">Events</field>
@ -160,7 +189,7 @@
<field name="type">ir.actions.act_window</field>
<field name="res_model">event.event</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_mode">tree,form,calendar,graph</field>
<field name="context">{"search_default_draft": "1"}</field>
<field name="search_view_id" ref="view_event_search"/>
</record>
@ -170,9 +199,18 @@
name="Registration"
res_model="event.registration"
src_model="event.event"
view_mode="tree,form"
view_mode="tree,form,calendar,graph"
domain="[('event_id', '=', active_id)]"
view_type="form"/>
<act_window
id="act_register_event_partner"
name="Subscribe"
res_model="event.registration"
src_model="res.partner"
view_mode="tree,form,calendar,graph"
domain="[('partner_id', '=', active_id)]"
view_type="form"/>
<menuitem name="Events" id="menu_event_event" action="action_event_view" parent="menu_event_main" />
@ -203,29 +241,32 @@
<field name="arch" type="xml">
<form string="Registration">
<group col="6" colspan="4">
<field name="name" select="1" colspan="2"/>
<field name="event_id" select="1" on_change="onchange_event(event_id, partner_invoice_id)" domain="[('state','in',('draft','confirm'))]"/>
<field name="nb_register"/>
<group colspan="2">
<field name="user_id" select="1"/>
<button name="remind_user" string="Send Reminder" states="open,pending" type="object" colspan="2" icon="gtk-go-forward"/>
</group>
<field name="user_id" select="1"/>
<newline/>
<field name="partner_id" required="1" select="1" on_change="onchange_partner_id(partner_id,event_id)" />
<field name="partner_invoice_id" on_change="onchange_partner_invoice_id(event_id, partner_invoice_id)"/>
<field name="unit_price"/>
</group>
<notebook colspan="4">
<page string="General">
<field name="contact_id" on_change="onchange_contact_id(contact_id, partner_id)" /><newline/>
<group colspan="4" col="6">
<field name="nb_register"/>
<field name="unit_price"/>
<field name="currency_id"/>
</group>
<separator string="Communication Information" colspan="4"/>
<field name="contact_id" on_change="onchange_contact_id(contact_id, partner_id)" />
<field name="email_from"/>
<button name="remind_partner" string="Send Reminder" states="open,pending" type="object" colspan="2" icon="gtk-go-forward"/>
<newline/>
<separator string="Badge" colspan="4"/>
<field name="badge_title"/>
<field name="badge_name" on_change="onchange_badge_name(badge_name)"/>
<field name="badge_partner"/>
<newline/>
<separator string="Status" colspan="4"/>
<group col="8" colspan="4">
<separator string="Status" colspan="4"/>
<newline/>
<field name="state" select="1" colspan="2"/>
<button name="button_reg_close" string="Close Registration" states="open" type="object" icon="gtk-close"/>
<button name="check_confirm" string="Confirm Registration" states="draft" type="object" icon="gtk-apply"/>
@ -241,77 +282,97 @@
<group colspan="4">
<field colspan="4" name="email_cc" string="CC"/>
</group>
<field name="message_ids" colspan="4" nolabel="1" mode="form,tree">
<form string="Communication history">
<group col="6" colspan="4">
<field name="date"/>
<field name="email_to"/>
<field name="email_from"/>
</group>
<notebook colspan="4">
<page string="Details">
<field name="description" colspan="4" nolabel="1"/>
</page>
<page string="Attachments">
<field name="attachment_ids" colspan="4" readonly="1" nolabel="1"/>
</page>
</notebook>
<button colspan="4"
string="Reply to Last Email"
name="%(crm.action_crm_send_mail)d"
context="{'mail':'reply', 'model': 'crm.lead', 'include_original' : True}"
icon="gtk-undo" type="action" />
</form>
<tree string="Communication history">
<field name="date"/>
<field name="email_from" />
<field name="email_to"/>
<field name="description"/>
</tree>
</field>
<button colspan="4" string="Send New Email"
<field name="message_ids" colspan="4" nolabel="1" mode="form,tree">
<form string="Communication history">
<group col="6" colspan="4">
<field name="date"/>
<field name="email_to"/>
<field name="email_from"/>
</group>
<notebook colspan="4">
<page string="Details">
<field name="description" colspan="4" nolabel="1"/>
</page>
<page string="Attachments">
<field name="attachment_ids" colspan="4" readonly="1" nolabel="1"/>
</page>
</notebook>
<button colspan="4"
string="Reply to Last Email"
name="%(crm.action_crm_send_mail)d"
context="{'mail':'reply', 'model': 'event.registration', 'include_original' : True}"
icon="gtk-undo" type="action" />
</form>
<tree string="Communication history">
<field name="date"/>
<field name="email_from" />
<field name="email_to"/>
<field name="description"/>
</tree>
</field>
<button colspan="4" string="Send New Email"
name="%(crm.action_crm_send_mail)d"
context="{'mail':'new', 'model': 'event.registration'}"
icon="gtk-go-forward" type="action" />
</page>
<page string="History">
<group colspan="4">
<field name="name" select="1" colspan="4"/>
</group>
<group col="2" colspan="2">
<separator string="Dates" colspan="2"/>
<field name="create_date"/>
<field name="date_closed"/>
</group>
<group col="2" colspan="2">
</page>
<page string="History">
<group col="2" colspan="2">
<separator string="Dates" colspan="2"/>
<field name="create_date"/>
<field name="date_closed"/>
</group>
<group col="2" colspan="2">
<separator string="Misc" colspan="2"/>
<field name="id"/>
<field name="active"/>
</group>
<group col="3" colspan="4">
<separator colspan="4" string="References"/>
<field name="ref" />
<field name="ref2" />
</group>
<!-- TODO-->
<field name="log_ids" nolabel="1" colspan="4">
<tree string="Logs">
<field name="name" colspan="4"/>
<field name="date"/>
<field name="user_id"/>
</tree>
<form string="Logs">
<separator string="Action Information" colspan="4"/>
<field name="name" colspan="4"/>
<field name="date"/>
<field name="user_id"/>
</form>
</field>
</page>
<!-- TODO-->
<field name="log_ids" nolabel="1" colspan="4">
<tree string="Logs">
<field name="name" colspan="4"/>
<field name="date"/>
<field name="user_id"/>
</tree>
<form string="Logs">
<separator string="Action Information" colspan="4"/>
<field name="name" colspan="4"/>
<field name="date"/>
<field name="user_id"/>
</form>
</field>
</page>
</notebook>
</form>
</field>
</record>
<!-- Calendar view of event registration -->
<record id="view_event_registration_calendar" model="ir.ui.view">
<field name="name">event.registration.calendar</field>
<field name="model">event.registration</field>
<field name="type">calendar</field>
<field eval="2" name="priority"/>
<field name="arch" type="xml">
<calendar color="event_id" date_start="create_date" string="Event Registration">
<field name="event_id"/>
<field name="partner_invoice_id"/>
</calendar>
</field>
</record>
<record model="ir.ui.view" id="view_event_registration_graph">
<field name="name">Registration Graph</field>
<field name="model">event.registration</field>
<field name="type">graph</field>
<field name="arch" type="xml">
<graph string="Registration" type="bar" orientation="horizontal">
<field name="event_id"/>
<field name = "nb_register" operator="+"/>
</graph>
</field>
</record>
<!-- Search view of event registration form-->
@ -353,7 +414,7 @@
<field name="res_model">event.registration</field>
<field name="view_type">form</field>
<field name="domain"></field>
<field name="view_mode">tree,form</field>
<field name="view_mode">tree,form,calendar,graph</field>
<field name="context">{"search_default_draft": "1"}</field>
<field name="search_view_id" ref="view_registration_search"/>
</record>

View File

@ -63,6 +63,7 @@
register_min: 0.0
state: draft
type: 'event_type_conference0'
reply_to: 'info@customer.com'
- |
we set the limit of registrations to this event using "Minimum Registrations" 2 and "Maximum Registrations" 10
@ -172,18 +173,6 @@
obj_event = self.browse(cr, uid, [ref('event_event_conference0')])[0]
assert obj_event.register_current == '2'
assert obj_event.register_prospect == '1'
- |
We check all registered partners to this event using the wizard "List Register Partners".
-
!record {model: event.partners.list, id: event_partners_list_0}:
{}
-
I click on "Open Partners" button of "List Register Partners" wizard.
-
!python {model: event.partners.list}: |
self.list_partners(cr, uid, [ref("event_partners_list_0")], {"active_ids":
[ref("event.event_event_conference0")]})
- |
This event is finished by click on "Event Done" button of this event form.

View File

@ -21,4 +21,5 @@
import event_make_invoice
import event_confirm_registration
import partner_event_registration
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: