[clean] cleaning event screen and yaml test

bzr revid: mva@openerp.com-20120117091702-4120z3bhcgac3aak
This commit is contained in:
MVA 2012-01-17 10:17:02 +01:00
parent 30eeff00ee
commit bc07343f40
7 changed files with 15 additions and 164 deletions

View File

@ -456,7 +456,7 @@ class event_registration(osv.osv):
# event uses add_note wizard from crm, which expects case_* methods
def case_close(self, cr, uid, ids, context=None):
self.do_close(cr, uid, ids, context)
return self.write(cr, uid, ids, {'state': 'done'})
# event uses add_note wizard from crm, which expects case_* methods
def case_cancel(self, cr, uid, ids, context=None):
""" Cancel Registration
@ -511,30 +511,7 @@ class event_registration(osv.osv):
def button_reg_close(self, cr, uid, ids, context=None):
"""This Function Close Event Registration.
"""
data_pool = self.pool.get('ir.model.data')
unclosed_ids = []
for registration in self.browse(cr, uid, ids, context=context):
if registration.tobe_invoiced and not registration.invoice_id:
unclosed_ids.append(registration.id)
else:
self.do_close(cr, uid, [registration.id], context=context)
if unclosed_ids:
view_id = data_pool.get_object_reference(cr, uid, 'event', 'view_event_make_invoice')
view_id = view_id and view_id[1] or False
context['active_ids'] = unclosed_ids
return {
'name': _('Close Registration'),
'context': context,
'view_type': 'form',
'view_mode': 'tree,form',
'res_model': 'event.make.invoice',
'views': [(view_id, 'form')],
'type': 'ir.actions.act_window',
'target': 'new',
'context': context,
'nodestroy': True
}
return True
return self.case_close(cr, uid, ids)
def button_reg_cancel(self, cr, uid, ids, context=None, *args):
return self.case_cancel(cr, uid, ids)

View File

@ -58,7 +58,9 @@
<field name="date_end"/>
<field name="type" widget="selection"/>
<field name="language"/>
<field name="parent_id"/>
<field name="user_id"/>
<field name="country_id" />
<field name="address_id" domain="[('country_id','=',country_id)]"/>
</group>
<notebook colspan="4">
<page string="Event">
@ -66,19 +68,6 @@
<separator string="Invoice Information" colspan="4"/>
<field name="product_id" on_change="onchange_product(product_id)" colspan="4"/>
<field name="unit_price"/>
<field name="pricelist_id" widget="selection" domain="[('type','=','sale')]" groups="base.group_extended"/>
</group>
<group colspan="2" col="2">
<separator string="Contact" colspan="4"/>
<field name="user_id"/>
<field name="section_id" widget="selection" on_change="do_team_change(section_id)"/>
<field name="company_id" groups="base.group_multi_company" widget="selection"/>
</group>
<group colspan="2" col="2">
<separator string="Location" colspan="4"/>
<field name="country_id" />
<field name="address_id" domain="[('country_id','=',country_id)]"/>
</group>
<separator string="Description" colspan="4"/>
<field name="note" colspan="4" nolabel="1"/>

View File

@ -22,41 +22,11 @@
-
!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.
I Check that Registration is close.
-
!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"
!assert {model: event.registration, id: reg_1_1}:
- state == 'done', "Registration should be done here."

View File

@ -36,35 +36,11 @@ class event_confirm_registration(osv.osv_memory):
'msg': 'The event limit is reached. What do you want to do?'
}
def default_get(self, cr, uid, fields, context=None):
"""
This function gets default values
"""
if context is None:
context = {}
registration_pool = self.pool.get('event.registration')
registration_ids = context.get('registration_ids', [])
res = super(event_confirm_registration, self).default_get(cr, uid, fields, context=context)
msg = ""
overlimit_event_ids = []
for registration in registration_pool.browse(cr, uid, registration_ids, context=context):
register_max = registration.event_id.register_max
if registration.event_id.id not in overlimit_event_ids:
overlimit_event_ids.append(registration.event_id.id)
msg += _("Warning: The Event '%s' has reached its Maximum Limit (%s).") \
%(registration.event_id.name, register_max)
if 'msg' in fields:
res.update({'msg': msg})
return res
def confirm(self, cr, uid, ids, context=None):
if context is None:
context = {}
registration_pool = self.pool.get('event.registration')
registration_ids = context.get('registration_ids', [])
registration_pool.do_open(cr, uid, registration_ids, context=context)
return {'type': 'ir.actions.act_window_close'}
event_confirm_registration()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -28,67 +28,10 @@ class event_make_invoice(osv.osv_memory):
"""
_name = "event.make.invoice"
_description = "Event Make Invoice"
_columns = {
'grouped': fields.boolean('Group the invoices'),
'invoice_date': fields.date('Invoice Date'),
}
def view_init(self, cr, uid, fields, context=None):
"""
This function checks for precondition before wizard executes
@param self: The object pointer
@param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks,
@param fields: List of fields for default value
@param context: A standard dictionary for contextual values
"""
obj_event_reg = self.pool.get('event.registration')
data = context and context.get('active_ids', [])
for event_reg in obj_event_reg.browse(cr, uid, data, context=context):
if event_reg.state in ('draft', 'done', 'cancel'):
raise osv.except_osv(_('Warning !'),
_("Invoice cannot be created if the registration is in %s state.") % (event_reg.state))
if (not event_reg.tobe_invoiced):
raise osv.except_osv(_('Warning !'),
_("Registration is set as Cannot be invoiced"))
if not event_reg.event_id.product_id:
raise osv.except_osv(_('Warning !'),
_("Event related doesn't have any product defined"))
if not event_reg.partner_invoice_id:
raise osv.except_osv(_('Warning !'),
_("Registration doesn't have any partner to invoice."))
def default_get(self, cr, uid, fields_list, context=None):
return super(event_make_invoice, self).default_get(cr, uid, fields_list, context=context)
def make_invoice(self, cr, uid, ids, context=None):
reg_obj = self.pool.get('event.registration')
mod_obj = self.pool.get('ir.model.data')
if context is None:
context = {}
for data in self.browse(cr, uid, ids, context=context):
res = reg_obj.action_invoice_create(cr, uid, context.get(('active_ids'),[]), data.grouped, date_inv = data.invoice_date)
form_id = mod_obj.get_object_reference(cr, uid, 'account', 'invoice_form')
form_res = form_id and form_id[1] or False
tree_id = mod_obj.get_object_reference(cr, uid, 'account', 'invoice_tree')
tree_res = tree_id and tree_id[1] or False
return {
'domain': "[('id', 'in', %s)]" % res,
'name': _('Customer Invoices'),
'view_type': 'form',
'view_mode': 'tree,form',
'res_model': 'account.invoice',
'view_id': False,
'views': [(tree_res, 'tree'), (form_res, 'form')],
'context': "{'type':'out_refund'}",
'type': 'ir.actions.act_window',
}
print ids
event_make_invoice()

View File

@ -8,9 +8,6 @@
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Create invoices">
<separator colspan="4" string="Do you really want to create the invoice(s) ?" />
<field name="grouped" />
<field name="invoice_date"/>
<group colspan="4">
<separator string="" colspan="4" />
<label string="" colspan="2"/>

View File

@ -76,7 +76,6 @@ class partner_event_registration(osv.osv_memory):
'event_id': current.event_id and current.event_id.id or False,
'unit_price': current.unit_price,
'partner_id': partner.id,
'partner_invoice_id': partner.id,
'event_product': current.event_id.product_id.name,
'contact_id': contact_id,
'email_from': email,