Skip to content

Commit

Permalink
[IMP] do not import analytic accounts that have the 'use_timesheets' …
Browse files Browse the repository at this point in the history
…unflagged
  • Loading branch information
JordiBForgeFlow committed Feb 23, 2016
1 parent 113ff55 commit 536089f
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions hr_timesheet_sheet_import_accounts/model/hr_timesheet_sheet.py
Expand Up @@ -25,7 +25,7 @@
from openerp import SUPERUSER_ID


class hr_timesheet_sheet(orm.Model):
class HrTimesheetSheet(orm.Model):
_inherit = "hr_timesheet_sheet.sheet"

def set_previous_timesheet_ids(self, cr, uid, ids, context=None):
Expand Down Expand Up @@ -66,20 +66,23 @@ def set_previous_timesheet_ids(self, cr, uid, ids, context=None):
if timesheet_id.line_id:
a_line_ids.append(timesheet_id.line_id.id)
if a_line_ids:
cr.execute('SELECT DISTINCT account_id '
'FROM account_analytic_line AS L '
'WHERE L.id IN %s '
'GROUP BY account_id', (tuple(a_line_ids),))
cr.execute("""SELECT DISTINCT account_id
FROM account_analytic_line AS L
INNER JOIN account_analytic_account as A
ON A.id = L.account_id
WHERE L.id IN %s
AND A.use_timesheets = True
GROUP BY account_id""", (tuple(a_line_ids),))
res = cr.dictfetchall()
timesheet_ids = []
for res_vals in res:
same_account_id = False
for timesheet_id in sheet.timesheet_ids:
if (
timesheet_id.line_id
and timesheet_id.line_id.account_id
and timesheet_id.line_id.account_id.id
== res_vals['account_id']
timesheet_id.line_id and
timesheet_id.line_id.account_id and
timesheet_id.line_id.account_id.id ==
res_vals['account_id']
):
same_account_id = True
if same_account_id is True:
Expand Down

0 comments on commit 536089f

Please sign in to comment.