diff --git a/addons/event/event.py b/addons/event/event.py index a15e8b52e5f..cc6f9f462b9 100644 --- a/addons/event/event.py +++ b/addons/event/event.py @@ -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) diff --git a/addons/event/event_view.xml b/addons/event/event_view.xml index 1185f935afe..3d0eb4e3074 100644 --- a/addons/event/event_view.xml +++ b/addons/event/event_view.xml @@ -58,7 +58,9 @@ - + + + @@ -66,19 +68,6 @@ - - - - - - - - - - - - - diff --git a/addons/event/test/process/partner_register2invoice.yml b/addons/event/test/process/partner_register2invoice.yml index f8748afee2f..022276f0a7c 100644 --- a/addons/event/test/process/partner_register2invoice.yml +++ b/addons/event/test/process/partner_register2invoice.yml @@ -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." + + diff --git a/addons/event/wizard/event_confirm_registration.py b/addons/event/wizard/event_confirm_registration.py index b122cde02a0..fe1664affa2 100644 --- a/addons/event/wizard/event_confirm_registration.py +++ b/addons/event/wizard/event_confirm_registration.py @@ -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: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/event/wizard/event_make_invoice.py b/addons/event/wizard/event_make_invoice.py index 73a0acff104..f5a9f37e88e 100644 --- a/addons/event/wizard/event_make_invoice.py +++ b/addons/event/wizard/event_make_invoice.py @@ -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 user’s 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() diff --git a/addons/event/wizard/event_make_invoice_view.xml b/addons/event/wizard/event_make_invoice_view.xml index 9d0d96352c0..dd87e7dec4b 100644 --- a/addons/event/wizard/event_make_invoice_view.xml +++ b/addons/event/wizard/event_make_invoice_view.xml @@ -8,9 +8,6 @@ form
- - -