[MERGE] trunk-coverage-event-ron (improve tests in module event)

bzr revid: rco@openerp.com-20111213100805-37t86ubkou5tal0s
This commit is contained in:
Raphael Collet 2011-12-13 11:08:05 +01:00
commit 2be64b26b7
9 changed files with 176 additions and 177 deletions

View File

@ -54,7 +54,11 @@ Note that:
'res_partner_view.xml',
],
'demo_xml': ['event_demo.xml'],
'test': ['test/test_event.yml'],
'test': ['test/process/event_confirm2done.yml',
'test/process/event_draft2cancel.yml',
'test/process/partner_register2invoice.yml',
'test/ui/duplicate_event.yml',
'test/ui/demo_data.yml'],
'installable': True,
'active': False,
'certificate': '0083059161581',

View File

@ -61,6 +61,8 @@
<field eval="time.strftime('%Y-%m-01 23:05:15')" name="date_end"/>
<field name="product_id" ref="event_product_0"/>
<field name="unit_price">68.00</field>
<field name="mail_auto_registr">True</field>
<field name="mail_auto_confirm">True</field>
<field name="user_id" ref="base.user_root"/>
<field name="register_max">500</field>
<field name="type" ref="event_type_1"/>
@ -74,9 +76,9 @@
<field name="unit_price">24.00</field>
<field name="type" ref="event_type_1"/>
<field name="user_id" ref="base.user_root"/>
<field name="register_min">50</field>
<field name="register_max">350</field>
</record>
<function model="event.event" name="button_confirm" eval="[ref('event_1')]"/>
<record id="event_2" model="event.event">
<field name="name">Conference on ERP Buisness</field>
<field eval="time.strftime('%Y-%m-05 14:00:00')" name="date_begin"/>
@ -92,7 +94,7 @@
<field name="mail_confirm">Thanks for registration. The conference will begin at 2 PM and will be given by Mr. Pinckaers.</field>
</record>
<function model="event.event" name="button_confirm" eval="[ref('event_2')]"/>
<function model="event.event" name="button_done" eval="[ref('event_2')]"/>
<function model="event.event" name="button_confirm" eval="[ref('event_2')]"/>
<!-- Demo data for Event Registration-->
<record id="reg_1_1" model="event.registration">
@ -126,5 +128,16 @@
<function model="event.registration" name="check_confirm" eval="[ref('reg_0_1')]"/>
<record id="reg_0_2" model="event.registration">
<field name="event_id" ref="event_2"/>
<field name="partner_id" ref="base.res_partner_c2c"/>
<field name="partner_invoice_id" ref="base.res_partner_c2c"/>
<field name="nb_register">5</field>
<field name="event_product">Ticket for Conference</field>
<field name="unit_price">20</field>
</record>
<function model="event.registration" name="check_confirm" eval="[ref('reg_0_2')]"/>
</data>
</openerp>

View File

@ -0,0 +1,22 @@
-
I want to organize one conference event on "OpenERP Business", Customer subscribe/join
into "Conference on OpenERP Business" with 6 tickets, first I confim this event.
-
!python {model: event.event}: |
self.button_confirm(cr, uid, [ref("event_0")])
-
I Check that Event is "confirmed", and Its automatically sending mail to registered
partner which joined to this event.
-
!assert {model: event.event, id: event_0}:
- state == 'confirm', "Event should be confirmed."
-
After completed event, I close this event.
-
!python {model: event.event}: |
self.button_done(cr, uid, [ref("event_0")])
-
Check that conference is in "close" state.
-
!assert {model: event.event, id: event_0}:
- state == 'done', "Event should be Closed."

View File

@ -0,0 +1,22 @@
-
I want to organize event and its need Minimum 50 Registrations to confirm/start
this Event, but Only 10 registration confirm for this event, I confirm this event.
-
!python {model: event.event}: |
self.button_confirm(cr, uid, [ref("event_1")])
-
Now I cheked for event and It should not be confirm because registrations for
this event is below limit.
-
!assert {model: event.event, id: event_1}:
- state == 'confirm', "Event should be confirm."
-
So I cancel this Event
-
!python {model: event.event}: |
self.button_cancel(cr, uid, [ref("event_1")])
-
I check event should be cancel.
-
!assert {model: event.event, id: event_1}:
- state == 'cancel', "Event should be cancel"

View File

@ -0,0 +1,62 @@
-
I want to organize one conference event, First I registered partner for event
with 5 tickets.
-
!python {model: partner.event.registration}: |
context.update({'active_model': 'res.partner', 'active_ids': [ref("base.res_partner_ericdubois0")], 'active_id': ref("base.res_partner_ericdubois0")})
register = self.create(cr, uid, {'event_id': ref('event_1'),'nb_register': 5}, context=context)
self.open_registration(cr, uid, [register], context=context)
-
Now I check for registration created base on partner.
-
!python {model: event.registration}: |
ids = self.search(cr, uid, [('partner_id','=',ref("base.res_partner_ericdubois0")), ('event_id', '=', ref('event_1'))])
assert ids, "Registration should be create here."
-
I confirm registration process.
-
!python {model: event.registration}: |
self.check_confirm(cr, uid, [ref("reg_1_1")])
-
I Check that Registration is confirm.
-
!assert {model: event.registration, id: reg_1_1}:
- state == 'open', "Registration should be open here."
-
After confirmation of partner, I create invoice base on costing of event.
-
!python {model: event.registration}: |
self.action_invoice_create(cr, uid, [ref("reg_1_1")])
-
Now I Check for Invoice is created and Registration should be closed after invoice generated.
-
!python {model: event.registration}: |
record = self.browse(cr, uid, [ref("reg_1_1")])[0]
assert record.invoice_id, "Invoice should be generated"
assert record.invoice_id.state == "draft", "Invoice state should be draft"
assert record.invoice_id.partner_id == record.partner_id, "Customer is not correspond with registration"
assert record.invoice_id.type == 'out_invoice', "Invoice type is not correct"
assert record.invoice_id.origin == record.event_product, "Invoice origin is not correct"
assert record.invoice_id.amount_total == record.price_subtotal, "Invoice amount is not correct"
assert record.state == "done", "Registration should be closed after invoice generated"
-
Now I check for same partner registration for two diffrent event and I create group invoices for same partner.
-
!python {model: event.make.invoice}: |
context.update({'active_model': 'event.make.invoice', 'active_ids': [ref("reg_0_1"), ref("reg_0_2")], 'active_id': ref("reg_0_1")})
invoice = self.create(cr, uid, {'grouped': True}, context=context)
self.make_invoice(cr, uid, [invoice], context=context)
-
Now I Check for group Invoice is created with total amount of both registration
and Registration should be closed after invoice generated.
-
!python {model: event.registration}: |
reg_data_1 = self.browse(cr, uid, [ref("reg_0_1")])[0]
reg_data_2 = self.browse(cr, uid, [ref("reg_0_2")])[0]
assert reg_data_1.invoice_id, "Invoice should be generated"
assert reg_data_1.invoice_id.state == "draft", "Invoice state should be draft"
assert reg_data_1.invoice_id.partner_id == reg_data_1.partner_id, "Customer is not correspond with registration"
assert reg_data_1.invoice_id.type == 'out_invoice', "Invoice type is not correct"
assert reg_data_1.invoice_id.origin == reg_data_1.event_product, "Invoice origin is not correct"
assert reg_data_1.invoice_id.amount_total == (reg_data_1.price_subtotal + reg_data_2.price_subtotal), "Invoice total amount is not correct"
assert reg_data_1.state == "done", "Registration should be closed after invoice generated"

View File

@ -1,172 +0,0 @@
- |
In order to test the "Event Organisation" in Association system.
- |
I want to organize one conference event on "OpenERP Business".
- |
I'm creating new product "Conference Ticket" to specify registration Cost of conference.
-
!record {model: product.product, id: product_product_ticketforconcert0}:
categ_id: product.cat1
list_price: 68.0
name: Conference Ticket
- |
I'm creating Event type "Conference".
-
!record {model: event.type, id: event_type_conference0}:
name: Conferences
- |
I'm creating one Event "Conference on OpenERP Business" which will last from 1st of this month to 10th of this month.
-
!record {model: event.event, id: event_event_conference0}:
date_begin: !eval time.strftime('%Y-%m-01')
date_end: !eval time.strftime('%Y-%m-10')
name: Conference on OpenERP Business.
product_id: 'product_product_ticketforconcert0'
type: 'event_type_conference0'
reply_to: 'info@customer.com'
- |
Check that the new conference event is "Draft" or not.
-
!assert {model: event.event, id: event_event_conference0}:
- state == 'draft', "Event should be in draft by default when first time created"
- |
Need Minimum 10 Registrations to confirm/start this Conference Event and does not allowed more than 100 Registrations.
- |
So I set Minimum and Maximum Registrations limit.
-
!python {model: event.event}: |
self.write(cr, uid, [ref('event_event_conference0')], {'register_max': 100, 'register_min': 10})
- |
I'm doing to confirm that conference event.
-
!python {model: event.event}: |
self.button_confirm(cr, uid, [ref("event_event_conference0")])
- |
But this conference event need minimum 10 Confirmed Registrations. so Check that Event is not "confirmed".
-
!assert {model: event.event, id: event_event_conference0}:
- state != 'confirm', "Event should not confirmed if minimum registrations does not reached"
- |
"Mark Johnson" want to subscribe/join into "Conference on OpenERP Business" with 10 tickets.
- |
I'm creating new partner "Mark Johnson" with his email "info@mycustomer.com".
-
!record {model: res.partner, id: res_partner_markjohnson0}:
address:
- city: Bruxelles
country_id: base.be
job_ids:
- contact_id: base_contact.res_partner_contact_jacot0
function: CTO
name: base.res_partner_maxtor
sequence_partner: 0.0
state: current
street: Rue des Palais 51, bte 33
type: default
zip: '1000'
email: 'info@mycustomer.com'
name: Mark Johnson
- |
I'm creating Registration for "Mark Johnson" on "Conference on OpenERP Business" with 10 tickets.
-
!record {model: event.registration, id: event_registration_registrationjacot0}:
contact_id: base_contact.res_partner_contact_jacot0
event_id: event.event_event_conference0
partner_id: event.res_partner_markjohnson0
partner_invoice_id: event.res_partner_markjohnson0
event_product: Conference Ticket
unit_price: 68.0
nb_register: 10
- |
I'm going to Open that Registration.
-
!python {model: event.registration}: |
self.check_confirm(cr, uid, [ref("event_registration_registrationjacot0")])
- |
Check that Registration is in "Open" state or not.
-
!assert {model: event.registration, id: event_registration_registrationjacot0}:
- state == 'open', "Registration should be open here."
- |
I'm again trying to confirm that conference event.
-
!python {model: event.event}: |
self.button_confirm(cr, uid, [ref("event_event_conference0")])
- |
Now Minimum requirement of Registration is fulfil. so Check that Event is "confirmed" or not.
-
!assert {model: event.event, id: event_event_conference0}:
- state == 'confirm', "Event should be confirmed here."
- |
I'm creating invoice of Registration of "Mark Johnson" on "Conference on OpenERP Business".
-
!python {model: event.registration}: |
self.action_invoice_create(cr, uid, [ref("event_registration_registrationjacot0")])
- |
Check Invoice of Registration of "Mark Johnson" is created or not.
-
!assert {model: event.registration, id: event_registration_registrationjacot0}:
- invoice_id != False, "Invoice should be generated"
- |
Check Registration of "Mark Johnson" is closed or not after invoice generated.
-
!assert {model: event.registration, id: event_registration_registrationjacot0}:
- state != 'done', "Registration should be closed after invoice generated"
- |
Now "Mark Johnson" want to another registration on "Conference on OpenERP Business" with 120 tickets.
- |
I'm creating new registration for "Mark Johnson" with 100 tickets.
-
!record {model: event.registration, id: event_registration_registrationzen0}:
event_id: event.event_event_conference0
partner_id: event.res_partner_markjohnson0
partner_invoice_id: event.res_partner_markjohnson0
event_product: Conference Ticket
unit_price: 68.0
nb_register: 100
- |
I'm going to open "Mark Johnson" registration.
-
!python {model: event.registration}: |
self.check_confirm(cr, uid, [ref("event_registration_registrationzen0")])
- |
But conference event does not allow more than 100 Registrations. so Check that registration is not in "open" state.
-
!assert {model: event.registration, id: event_registration_registrationzen0}:
- state == 'draft', "Registration should be in draft by default."
- |
Now I'm modifying number of tickets of "Mark Johnson"'s registration with 90 tickets.
-
!python {model: event.registration}: |
self.write(cr, uid, [ref("event_registration_registrationzen0")], {'nb_register': 90})
- |
I'm again try to open "Mark Johnson" registration.
-
!python {model: event.registration}: |
self.check_confirm(cr, uid, [ref("event_registration_registrationzen0")])
- |
Check that registration "open" or not.
-
!assert {model: event.registration, id: event_registration_registrationzen0}:
- state == 'open', "Registration should be open here."
- |
I'm closing "Conference on OpenERP Business" Conference event
-
!python {model: event.event}: |
self.button_done(cr, uid, [ref("event_event_conference0")])
- |
Check that conference is in "close" state or not.
-
!assert {model: event.event, id: event_event_conference0}:
- state == 'done', "Registration should be Closed here."

View File

@ -0,0 +1,32 @@
-
I create event registation record to call event onchange and partner onchange.
-
!record {model: event.registration, id: reg_0_1}:
event_id: event_0
partner_id: base.res_partner_asus
name: 'Ticket for Concert'
-
I create event record to call product onchange and team onchange.
-
!record {model: event.event, id: event_2}:
product_id: event_product_2
section_id: crm.section_sales_department
name: 'Conference on ERP Buisness'
-
I call onchange event from event registration wizard.
-
!python {model: partner.event.registration}: |
context.update({'active_id': ref("base.res_partner_ericdubois0")})
self.onchange_event_id(cr, uid, 1, ref("event_1"), context=context)
-
I confirm event from wizard.
-
!python {model: event.confirm}: |
context.update({'event_ids': [ref("event_2")]})
id = self.create(cr, uid , {})
self.confirm(cr, uid, [id], context=context)
-
I call close registration process.
-
!python {model: event.registration}: |
self.button_reg_close(cr, uid, [ref("reg_0_2")])

View File

@ -0,0 +1,16 @@
-
Copy of event.
-
!python {model: event.event}: |
try:
self.copy(cr, uid, ref("event_2"))
except:
pass
-
Copy of event registarion.
-
!python {model: event.registration}: |
try:
self.copy(cr, uid, ref("reg_1_1"))
except:
pass

View File

@ -34,8 +34,8 @@ class partner_event_registration(osv.osv_memory):
'event_id': fields.many2one('event.event', 'Event'),
'event_type': fields.many2one('event.type', 'Type', readonly=True),
'unit_price': fields.float('Registration Cost', digits_compute=dp.get_precision('Sale Price')),
'start_date': fields.datetime('Start date', required=True, help="Beginning Date of Event", readonly=True),
'end_date': fields.datetime('Closing date', required=True, help="Closing Date of Event", readonly=True),
'start_date': fields.datetime('Start date', help="Beginning Date of Event", readonly=True),
'end_date': fields.datetime('Closing date', help="Closing Date of Event", readonly=True),
'nb_register': fields.integer('Number of Registration'),
}
_defaults = {