From 19f772dcff78b15a6acfaee5a25c3ae0553d4ba9 Mon Sep 17 00:00:00 2001 From: "VRA,JVO" <> Date: Thu, 10 Dec 2009 15:10:49 +0530 Subject: [PATCH] [FIX] Hr_timesheet_invoice : Line once invoiced,should not be invoiced again lp bug: https://launchpad.net/bugs/440248 fixed bzr revid: jvo@tinyerp.com-20091210094049-2w1lkfac1b6kykdr --- addons/hr_timesheet_invoice/hr_timesheet_invoice.py | 2 +- .../wizard/hr_timesheet_invoice_create.py | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/addons/hr_timesheet_invoice/hr_timesheet_invoice.py b/addons/hr_timesheet_invoice/hr_timesheet_invoice.py index 0c16fb4ffd4..1f795b6e97f 100644 --- a/addons/hr_timesheet_invoice/hr_timesheet_invoice.py +++ b/addons/hr_timesheet_invoice/hr_timesheet_invoice.py @@ -73,7 +73,7 @@ account_analytic_account() class account_analytic_line(osv.osv): _inherit = 'account.analytic.line' _columns = { - 'invoice_id': fields.many2one('account.invoice', 'Invoice'), + 'invoice_id': fields.many2one('account.invoice', 'Invoice', ondelete="set null"), 'to_invoice': fields.many2one('hr_timesheet_invoice.factor', 'Invoicing'), } 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 65ca5c31a07..7bc8583f676 100644 --- a/addons/hr_timesheet_invoice/wizard/hr_timesheet_invoice_create.py +++ b/addons/hr_timesheet_invoice/wizard/hr_timesheet_invoice_create.py @@ -36,6 +36,13 @@ class invoice_create(wizard.interface): def _get_accounts(self, cr, uid, data, context): if not len(data['ids']): return {} + #Checking whether the analytic line is invoiced or not + pool = pooler.get_pool(cr.dbname) + analytic_line_obj = pool.get('account.analytic.line').browse(cr, uid, data['ids'], context) + for obj_acc in analytic_line_obj: + if obj_acc.invoice_id and obj_acc.invoice_id.state !='cancel': + raise wizard.except_wizard(_('Warning'),_('The analytic entry "%s" is already invoiced!')%(obj_acc.name,)) + cr.execute("SELECT distinct(account_id) from account_analytic_line where id IN (%s)"% (','.join(map(str,data['ids'])),)) account_ids = cr.fetchall() return {'accounts': [x[0] for x in account_ids]}