From cf91e73c54db777f9d6ba3754e2c81f589d9b463 Mon Sep 17 00:00:00 2001 From: "pso (OpenERP)" Date: Tue, 12 Apr 2011 14:51:15 +0530 Subject: [PATCH] [FIX] hr_timesheet_invoice: Fixed bug of recreating invoice if invoice already exists lp bug: https://launchpad.net/bugs/751269 fixed bzr revid: pso@tinyerp.com-20110412092115-nz5zelrazbk3og7y --- .../wizard/hr_timesheet_invoice_create.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/addons/hr_timesheet_invoice/wizard/hr_timesheet_invoice_create.py b/addons/hr_timesheet_invoice/wizard/hr_timesheet_invoice_create.py index 33c23140358..ee66cc045b0 100644 --- a/addons/hr_timesheet_invoice/wizard/hr_timesheet_invoice_create.py +++ b/addons/hr_timesheet_invoice/wizard/hr_timesheet_invoice_create.py @@ -47,6 +47,21 @@ class hr_timesheet_invoice_create(osv.osv_memory): 'name': lambda *args: 1 } + 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 + """ + analytic_obj = self.pool.get('account.analytic.line') + data = context and context.get('active_ids', []) + for analytic in analytic_obj.browse(cr, uid, data, context=context): + if analytic.invoice_id: + raise osv.except_osv(_('Warning !'), _("Invoice is already linked to some of the analytic line(s)!")) + def do_create(self, cr, uid, ids, context=None): mod_obj = self.pool.get('ir.model.data') analytic_account_obj = self.pool.get('account.analytic.account')