[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
This commit is contained in:
parent
5527de5e0f
commit
19f772dcff
|
@ -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'),
|
||||
}
|
||||
|
||||
|
|
|
@ -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]}
|
||||
|
|
Loading…
Reference in New Issue