2009-10-13 05:58:37 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
2008-11-03 19:18:56 +00:00
|
|
|
##############################################################################
|
2010-03-16 05:53:22 +00:00
|
|
|
#
|
2009-10-14 11:15:34 +00:00
|
|
|
# OpenERP, Open Source Management Solution
|
2010-01-12 09:18:39 +00:00
|
|
|
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
2008-11-03 19:18:56 +00:00
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
2009-10-14 11:15:34 +00:00
|
|
|
# it under the terms of the GNU Affero General Public License as
|
|
|
|
# published by the Free Software Foundation, either version 3 of the
|
|
|
|
# License, or (at your option) any later version.
|
2008-11-03 19:18:56 +00:00
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2009-10-14 11:15:34 +00:00
|
|
|
# GNU Affero General Public License for more details.
|
2008-11-03 19:18:56 +00:00
|
|
|
#
|
2009-10-14 11:15:34 +00:00
|
|
|
# You should have received a copy of the GNU Affero General Public License
|
2010-03-16 05:53:22 +00:00
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2008-11-03 19:18:56 +00:00
|
|
|
#
|
|
|
|
##############################################################################
|
2008-08-24 14:45:43 +00:00
|
|
|
import time
|
|
|
|
import datetime
|
2010-04-08 08:58:42 +00:00
|
|
|
|
2012-12-06 14:56:32 +00:00
|
|
|
from openerp.osv import fields, osv
|
|
|
|
from openerp import pooler
|
|
|
|
from openerp import tools
|
|
|
|
from openerp.tools.translate import _
|
2008-08-24 14:45:43 +00:00
|
|
|
|
2010-10-17 16:42:26 +00:00
|
|
|
class project_project(osv.osv):
|
|
|
|
_inherit = 'project.project'
|
2012-10-03 12:16:39 +00:00
|
|
|
|
2011-07-21 08:58:53 +00:00
|
|
|
def onchange_partner_id(self, cr, uid, ids, part=False, context=None):
|
2011-07-26 06:51:24 +00:00
|
|
|
res = super(project_project, self).onchange_partner_id(cr, uid, ids, part, context)
|
2011-07-28 05:27:47 +00:00
|
|
|
if part and res and ('value' in res):
|
2011-08-04 12:52:52 +00:00
|
|
|
# set Invoice Task Work to 100%
|
|
|
|
data_obj = self.pool.get('ir.model.data')
|
2011-07-28 05:27:47 +00:00
|
|
|
data_id = data_obj._get_id(cr, uid, 'hr_timesheet_invoice', 'timesheet_invoice_factor1')
|
|
|
|
if data_id:
|
|
|
|
factor_id = data_obj.browse(cr, uid, data_id).res_id
|
|
|
|
res['value'].update({'to_invoice': factor_id})
|
2011-07-26 06:51:24 +00:00
|
|
|
return res
|
2012-03-28 07:33:49 +00:00
|
|
|
|
2012-08-30 07:49:03 +00:00
|
|
|
_defaults = {
|
|
|
|
'use_timesheets': True,
|
|
|
|
}
|
|
|
|
|
|
|
|
def open_timesheets(self, cr, uid, ids, context=None):
|
|
|
|
""" open Timesheets view """
|
2012-10-04 11:40:21 +00:00
|
|
|
mod_obj = self.pool.get('ir.model.data')
|
|
|
|
act_obj = self.pool.get('ir.actions.act_window')
|
|
|
|
|
2012-08-30 07:49:03 +00:00
|
|
|
project = self.browse(cr, uid, ids[0], context)
|
|
|
|
view_context = {
|
|
|
|
'search_default_account_id': [project.analytic_account_id.id],
|
|
|
|
'default_account_id': project.analytic_account_id.id,
|
|
|
|
}
|
2012-10-03 11:23:19 +00:00
|
|
|
help = _("""<p class="oe_view_nocontent_create">Record your timesheets for the project '%s'.</p>""") % (project.name,)
|
2012-09-29 20:13:26 +00:00
|
|
|
try:
|
|
|
|
if project.to_invoice and project.partner_id:
|
|
|
|
help+= _("""<p>Timesheets on this project may be invoiced to %s, according to the terms defined in the contract.</p>""" ) % (project.partner_id.name,)
|
|
|
|
except:
|
|
|
|
# if the user do not have access rights on the partner
|
|
|
|
pass
|
|
|
|
|
2012-10-09 11:11:24 +00:00
|
|
|
res = mod_obj.get_object_reference(cr, uid, 'hr_timesheet', 'act_hr_timesheet_line_evry1_all_form')
|
|
|
|
id = res and res[1] or False
|
2012-10-04 11:40:21 +00:00
|
|
|
result = act_obj.read(cr, uid, [id], context=context)[0]
|
|
|
|
result['name'] = _('Timesheets')
|
|
|
|
result['context'] = view_context
|
|
|
|
result['help'] = help
|
|
|
|
return result
|
2012-10-03 12:16:39 +00:00
|
|
|
|
2010-10-17 16:42:26 +00:00
|
|
|
project_project()
|
|
|
|
|
2008-08-24 14:45:43 +00:00
|
|
|
class project_work(osv.osv):
|
|
|
|
_inherit = "project.task.work"
|
|
|
|
|
2009-10-21 10:13:24 +00:00
|
|
|
def get_user_related_details(self, cr, uid, user_id):
|
|
|
|
res = {}
|
2008-12-16 20:47:32 +00:00
|
|
|
emp_obj = self.pool.get('hr.employee')
|
2009-10-21 10:13:24 +00:00
|
|
|
emp_id = emp_obj.search(cr, uid, [('user_id', '=', user_id)])
|
2008-12-16 20:47:32 +00:00
|
|
|
if not emp_id:
|
2009-10-21 10:13:24 +00:00
|
|
|
user_name = self.pool.get('res.users').read(cr, uid, [user_id], ['name'])[0]['name']
|
2013-06-07 11:38:29 +00:00
|
|
|
raise osv.except_osv(_('Bad Configuration!'),
|
2012-07-25 12:16:05 +00:00
|
|
|
_('Please define employee for user "%s". You must create one.')% (user_name,))
|
2012-10-03 13:08:40 +00:00
|
|
|
emp = emp_obj.browse(cr, uid, emp_id[0])
|
2008-12-16 20:47:32 +00:00
|
|
|
if not emp.product_id:
|
2013-06-07 11:38:29 +00:00
|
|
|
raise osv.except_osv(_('Bad Configuration!'),
|
2012-10-19 10:48:26 +00:00
|
|
|
_('Please define product and product category property account on the related employee.\nFill in the HR Settings tab of the employee form.'))
|
2008-12-16 20:47:32 +00:00
|
|
|
|
|
|
|
if not emp.journal_id:
|
2013-06-07 11:38:29 +00:00
|
|
|
raise osv.except_osv(_('Bad Configuration!'),
|
2012-07-25 12:16:05 +00:00
|
|
|
_('Please define journal on the related employee.\nFill in the timesheet tab of the employee form.'))
|
2008-12-16 20:47:32 +00:00
|
|
|
|
2012-12-18 22:50:15 +00:00
|
|
|
acc_id = emp.product_id.property_account_expense.id
|
2012-10-03 13:08:40 +00:00
|
|
|
if not acc_id:
|
|
|
|
acc_id = emp.product_id.categ_id.property_account_expense_categ.id
|
|
|
|
if not acc_id:
|
2013-06-07 11:38:29 +00:00
|
|
|
raise osv.except_osv(_('Bad Configuration!'),
|
2012-07-25 12:16:05 +00:00
|
|
|
_('Please define product and product category property account on the related employee.\nFill in the timesheet tab of the employee form.'))
|
2012-10-03 14:28:59 +00:00
|
|
|
|
2009-10-21 10:13:24 +00:00
|
|
|
res['product_id'] = emp.product_id.id
|
|
|
|
res['journal_id'] = emp.journal_id.id
|
2012-10-03 13:08:40 +00:00
|
|
|
res['general_account_id'] = acc_id
|
2010-02-08 08:41:23 +00:00
|
|
|
res['product_uom_id'] = emp.product_id.uom_id.id
|
2009-10-21 10:13:24 +00:00
|
|
|
return res
|
2010-03-16 05:53:22 +00:00
|
|
|
|
2009-10-21 10:13:24 +00:00
|
|
|
def create(self, cr, uid, vals, *args, **kwargs):
|
2012-10-03 13:01:55 +00:00
|
|
|
timesheet_obj = self.pool.get('hr.analytic.timesheet')
|
2010-03-16 05:53:22 +00:00
|
|
|
task_obj = self.pool.get('project.task')
|
2010-08-04 12:11:24 +00:00
|
|
|
uom_obj = self.pool.get('product.uom')
|
2012-06-25 09:54:48 +00:00
|
|
|
|
2009-10-21 10:13:24 +00:00
|
|
|
vals_line = {}
|
2010-08-02 12:18:38 +00:00
|
|
|
context = kwargs.get('context', {})
|
2010-10-27 11:37:15 +00:00
|
|
|
if not context.get('no_analytic_entry',False):
|
2012-10-03 13:36:39 +00:00
|
|
|
task_obj = task_obj.browse(cr, uid, vals['task_id'])
|
2010-10-27 11:37:15 +00:00
|
|
|
result = self.get_user_related_details(cr, uid, vals.get('user_id', uid))
|
2012-10-23 06:50:37 +00:00
|
|
|
vals_line['name'] = '%s: %s' % (tools.ustr(task_obj.name), tools.ustr(vals['name'] or '/'))
|
2010-10-27 11:37:15 +00:00
|
|
|
vals_line['user_id'] = vals['user_id']
|
|
|
|
vals_line['product_id'] = result['product_id']
|
|
|
|
vals_line['date'] = vals['date'][:10]
|
2012-06-25 09:54:48 +00:00
|
|
|
|
2012-10-03 12:16:39 +00:00
|
|
|
# Calculate quantity based on employee's product's uom
|
2010-10-27 11:37:15 +00:00
|
|
|
vals_line['unit_amount'] = vals['hours']
|
2010-10-17 22:45:35 +00:00
|
|
|
|
2010-10-27 11:37:15 +00:00
|
|
|
default_uom = self.pool.get('res.users').browse(cr, uid, uid).company_id.project_time_mode_id.id
|
|
|
|
if result['product_uom_id'] != default_uom:
|
|
|
|
vals_line['unit_amount'] = uom_obj._compute_qty(cr, uid, default_uom, vals['hours'], result['product_uom_id'])
|
2012-10-03 13:36:39 +00:00
|
|
|
acc_id = task_obj.project_id and task_obj.project_id.analytic_account_id.id or False
|
2010-10-27 11:37:15 +00:00
|
|
|
if acc_id:
|
|
|
|
vals_line['account_id'] = acc_id
|
2012-10-03 13:01:55 +00:00
|
|
|
res = timesheet_obj.on_change_account_id(cr, uid, False, acc_id)
|
2010-10-27 11:37:15 +00:00
|
|
|
if res.get('value'):
|
|
|
|
vals_line.update(res['value'])
|
|
|
|
vals_line['general_account_id'] = result['general_account_id']
|
|
|
|
vals_line['journal_id'] = result['journal_id']
|
|
|
|
vals_line['amount'] = 0.0
|
|
|
|
vals_line['product_uom_id'] = result['product_uom_id']
|
|
|
|
amount = vals_line['unit_amount']
|
|
|
|
prod_id = vals_line['product_id']
|
|
|
|
unit = False
|
2012-10-03 13:01:55 +00:00
|
|
|
timeline_id = timesheet_obj.create(cr, uid, vals=vals_line, context=context)
|
2010-10-12 12:08:50 +00:00
|
|
|
|
2010-10-27 11:37:15 +00:00
|
|
|
# Compute based on pricetype
|
2012-10-03 13:01:55 +00:00
|
|
|
amount_unit = timesheet_obj.on_change_unit_amount(cr, uid, timeline_id,
|
2011-01-03 11:06:05 +00:00
|
|
|
prod_id, amount, False, unit, vals_line['journal_id'], context=context)
|
2010-10-27 11:37:15 +00:00
|
|
|
if amount_unit and 'amount' in amount_unit.get('value',{}):
|
|
|
|
updv = { 'amount': amount_unit['value']['amount'] }
|
2012-10-03 13:01:55 +00:00
|
|
|
timesheet_obj.write(cr, uid, [timeline_id], updv, context=context)
|
2010-10-27 11:37:15 +00:00
|
|
|
vals['hr_analytic_timesheet_id'] = timeline_id
|
2008-08-24 14:45:43 +00:00
|
|
|
return super(project_work,self).create(cr, uid, vals, *args, **kwargs)
|
|
|
|
|
2009-01-06 13:02:10 +00:00
|
|
|
def write(self, cr, uid, ids, vals, context=None):
|
2012-10-03 14:38:09 +00:00
|
|
|
"""
|
|
|
|
When a project task work gets updated, handle its hr analytic timesheet.
|
|
|
|
"""
|
2010-07-02 14:15:50 +00:00
|
|
|
if context is None:
|
|
|
|
context = {}
|
2010-03-16 05:53:22 +00:00
|
|
|
timesheet_obj = self.pool.get('hr.analytic.timesheet')
|
2010-08-04 12:11:24 +00:00
|
|
|
uom_obj = self.pool.get('product.uom')
|
2010-10-04 13:06:05 +00:00
|
|
|
result = {}
|
2012-06-25 09:54:48 +00:00
|
|
|
|
2010-08-02 12:18:38 +00:00
|
|
|
if isinstance(ids, (long, int)):
|
2012-10-03 14:28:59 +00:00
|
|
|
ids = [ids]
|
2010-08-02 12:18:38 +00:00
|
|
|
|
|
|
|
for task in self.browse(cr, uid, ids, context=context):
|
|
|
|
line_id = task.hr_analytic_timesheet_id
|
|
|
|
if not line_id:
|
|
|
|
# if a record is deleted from timesheet, the line_id will become
|
|
|
|
# null because of the foreign key on-delete=set null
|
|
|
|
continue
|
2012-10-03 12:16:39 +00:00
|
|
|
|
2010-08-02 12:18:38 +00:00
|
|
|
vals_line = {}
|
2008-09-24 08:46:41 +00:00
|
|
|
if 'name' in vals:
|
2012-10-23 06:50:37 +00:00
|
|
|
vals_line['name'] = '%s: %s' % (tools.ustr(task.task_id.name), tools.ustr(vals['name'] or '/'))
|
2008-09-24 08:46:41 +00:00
|
|
|
if 'user_id' in vals:
|
2009-01-06 13:02:10 +00:00
|
|
|
vals_line['user_id'] = vals['user_id']
|
2008-09-24 08:46:41 +00:00
|
|
|
if 'date' in vals:
|
2009-01-06 13:02:10 +00:00
|
|
|
vals_line['date'] = vals['date'][:10]
|
2008-09-24 08:46:41 +00:00
|
|
|
if 'hours' in vals:
|
2009-01-06 13:02:10 +00:00
|
|
|
vals_line['unit_amount'] = vals['hours']
|
2010-08-02 12:18:38 +00:00
|
|
|
prod_id = vals_line.get('product_id', line_id.product_id.id) # False may be set
|
2012-10-03 12:16:39 +00:00
|
|
|
|
2012-10-03 14:38:09 +00:00
|
|
|
# Put user related details in analytic timesheet values
|
2012-10-03 14:28:59 +00:00
|
|
|
details = self.get_user_related_details(cr, uid, vals.get('user_id', task.user_id.id))
|
2012-10-03 12:16:39 +00:00
|
|
|
for field in ('product_id', 'general_account_id', 'journal_id', 'product_uom_id'):
|
2012-10-03 14:28:59 +00:00
|
|
|
if details.get(field, False):
|
|
|
|
vals_line[field] = details[field]
|
2012-10-03 12:16:39 +00:00
|
|
|
|
2012-10-03 14:28:59 +00:00
|
|
|
# Check if user's default UOM differs from product's UOM
|
|
|
|
user_default_uom_id = self.pool.get('res.users').browse(cr, uid, uid).company_id.project_time_mode_id.id
|
|
|
|
if details.get('product_uom_id', False) and details['product_uom_id'] != user_default_uom_id:
|
|
|
|
vals_line['unit_amount'] = uom_obj._compute_qty(cr, uid, user_default_uom_id, vals['hours'], details['product_uom_id'])
|
2012-06-25 09:54:48 +00:00
|
|
|
|
2009-12-23 16:34:53 +00:00
|
|
|
# Compute based on pricetype
|
2010-10-08 21:19:53 +00:00
|
|
|
amount_unit = timesheet_obj.on_change_unit_amount(cr, uid, line_id.id,
|
2010-10-17 16:42:26 +00:00
|
|
|
prod_id=prod_id, company_id=False,
|
2011-01-03 11:06:05 +00:00
|
|
|
unit_amount=vals_line['unit_amount'], unit=False, journal_id=vals_line['journal_id'], context=context)
|
2008-08-24 14:45:43 +00:00
|
|
|
|
2010-08-02 12:18:38 +00:00
|
|
|
if amount_unit and 'amount' in amount_unit.get('value',{}):
|
2010-08-04 12:11:24 +00:00
|
|
|
vals_line['amount'] = amount_unit['value']['amount']
|
2010-08-02 12:18:38 +00:00
|
|
|
|
2014-06-05 13:44:18 +00:00
|
|
|
if vals_line:
|
|
|
|
self.pool.get('hr.analytic.timesheet').write(cr, uid, [line_id.id], vals_line, context=context)
|
2012-06-25 09:54:48 +00:00
|
|
|
|
2009-01-06 13:02:10 +00:00
|
|
|
return super(project_work,self).write(cr, uid, ids, vals, context)
|
2008-08-24 14:45:43 +00:00
|
|
|
|
|
|
|
def unlink(self, cr, uid, ids, *args, **kwargs):
|
2010-08-02 12:18:38 +00:00
|
|
|
hat_obj = self.pool.get('hr.analytic.timesheet')
|
|
|
|
hat_ids = []
|
|
|
|
for task in self.browse(cr, uid, ids):
|
|
|
|
if task.hr_analytic_timesheet_id:
|
2010-08-04 12:11:24 +00:00
|
|
|
hat_ids.append(task.hr_analytic_timesheet_id.id)
|
2012-10-03 12:16:39 +00:00
|
|
|
# Delete entry from timesheet too while deleting entry to task.
|
2010-08-02 12:18:38 +00:00
|
|
|
if hat_ids:
|
|
|
|
hat_obj.unlink(cr, uid, hat_ids, *args, **kwargs)
|
2009-01-06 13:02:10 +00:00
|
|
|
return super(project_work,self).unlink(cr, uid, ids, *args, **kwargs)
|
2008-08-24 14:45:43 +00:00
|
|
|
|
|
|
|
_columns={
|
2010-08-02 12:18:38 +00:00
|
|
|
'hr_analytic_timesheet_id':fields.many2one('hr.analytic.timesheet','Related Timeline Id', ondelete='set null'),
|
2008-08-24 14:45:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
project_work()
|
2008-09-24 09:18:06 +00:00
|
|
|
|
2009-12-08 06:52:31 +00:00
|
|
|
class task(osv.osv):
|
|
|
|
_inherit = "project.task"
|
|
|
|
|
2009-12-10 07:31:30 +00:00
|
|
|
def unlink(self, cr, uid, ids, *args, **kwargs):
|
|
|
|
for task_obj in self.browse(cr, uid, ids, *args, **kwargs):
|
|
|
|
if task_obj.work_ids:
|
|
|
|
work_ids = [x.id for x in task_obj.work_ids]
|
|
|
|
self.pool.get('project.task.work').unlink(cr, uid, work_ids, *args, **kwargs)
|
2010-03-16 05:53:22 +00:00
|
|
|
|
2009-12-10 07:31:30 +00:00
|
|
|
return super(task,self).unlink(cr, uid, ids, *args, **kwargs)
|
2010-03-16 05:53:22 +00:00
|
|
|
|
2012-03-05 18:40:03 +00:00
|
|
|
def write(self, cr, uid, ids, vals, context=None):
|
2010-07-02 14:15:50 +00:00
|
|
|
if context is None:
|
|
|
|
context = {}
|
2010-08-03 14:53:21 +00:00
|
|
|
if vals.get('project_id',False) or vals.get('name',False):
|
2009-12-08 06:52:31 +00:00
|
|
|
vals_line = {}
|
|
|
|
hr_anlytic_timesheet = self.pool.get('hr.analytic.timesheet')
|
2010-08-03 14:53:21 +00:00
|
|
|
if vals.get('project_id',False):
|
2010-11-22 10:37:53 +00:00
|
|
|
project_obj = self.pool.get('project.project').browse(cr, uid, vals['project_id'], context=context)
|
2010-07-15 07:35:17 +00:00
|
|
|
acc_id = project_obj.analytic_account_id.id
|
2009-12-08 06:52:31 +00:00
|
|
|
|
2012-10-03 13:36:39 +00:00
|
|
|
for task_obj in self.browse(cr, uid, ids, context=context):
|
2009-12-10 07:31:30 +00:00
|
|
|
if len(task_obj.work_ids):
|
|
|
|
for task_work in task_obj.work_ids:
|
2010-10-12 12:08:50 +00:00
|
|
|
if not task_work.hr_analytic_timesheet_id:
|
|
|
|
continue
|
2010-08-03 14:53:21 +00:00
|
|
|
line_id = task_work.hr_analytic_timesheet_id.id
|
|
|
|
if vals.get('project_id',False):
|
2009-12-08 06:52:31 +00:00
|
|
|
vals_line['account_id'] = acc_id
|
2010-08-03 14:53:21 +00:00
|
|
|
if vals.get('name',False):
|
2009-12-08 06:52:31 +00:00
|
|
|
vals_line['name'] = '%s: %s' % (tools.ustr(vals['name']), tools.ustr(task_work.name) or '/')
|
|
|
|
hr_anlytic_timesheet.write(cr, uid, [line_id], vals_line, {})
|
2009-12-10 07:31:30 +00:00
|
|
|
return super(task,self).write(cr, uid, ids, vals, context)
|
2009-12-08 06:52:31 +00:00
|
|
|
|
|
|
|
task()
|
2010-12-20 08:23:41 +00:00
|
|
|
|
|
|
|
class res_partner(osv.osv):
|
|
|
|
_inherit = 'res.partner'
|
2012-10-03 12:16:39 +00:00
|
|
|
|
2010-12-20 08:23:41 +00:00
|
|
|
def unlink(self, cursor, user, ids, context=None):
|
|
|
|
parnter_id=self.pool.get('project.project').search(cursor, user, [('partner_id', 'in', ids)])
|
|
|
|
if parnter_id:
|
2012-08-07 11:06:16 +00:00
|
|
|
raise osv.except_osv(_('Invalid Action!'), _('You cannot delete a partner which is assigned to project, but you can uncheck the active box.'))
|
2010-12-20 08:23:41 +00:00
|
|
|
return super(res_partner,self).unlink(cursor, user, ids,
|
|
|
|
context=context)
|
2012-10-03 13:01:55 +00:00
|
|
|
|
2010-12-20 08:23:41 +00:00
|
|
|
res_partner()
|
|
|
|
|
2011-01-04 07:20:18 +00:00
|
|
|
class account_analytic_line(osv.osv):
|
|
|
|
_inherit = "account.analytic.line"
|
2012-10-03 12:16:39 +00:00
|
|
|
|
2012-10-15 10:44:02 +00:00
|
|
|
def get_product(self, cr, uid, context=None):
|
|
|
|
emp_obj = self.pool.get('hr.employee')
|
|
|
|
emp_ids = emp_obj.search(cr, uid, [('user_id', '=', uid)], context=context)
|
|
|
|
if emp_ids:
|
|
|
|
employee = emp_obj.browse(cr, uid, emp_ids, context=context)[0]
|
|
|
|
if employee.product_id:return employee.product_id.id
|
2012-10-12 09:05:27 +00:00
|
|
|
return False
|
2012-10-15 10:44:02 +00:00
|
|
|
|
|
|
|
_defaults = {'product_id': get_product,}
|
|
|
|
|
2011-01-04 07:20:18 +00:00
|
|
|
def on_change_account_id(self, cr, uid, ids, account_id):
|
|
|
|
res = {}
|
|
|
|
if not account_id:
|
|
|
|
return res
|
|
|
|
res.setdefault('value',{})
|
|
|
|
acc = self.pool.get('account.analytic.account').browse(cr, uid, account_id)
|
|
|
|
st = acc.to_invoice.id
|
|
|
|
res['value']['to_invoice'] = st or False
|
2012-01-02 13:11:37 +00:00
|
|
|
if acc.state == 'close' or acc.state == 'cancelled':
|
2013-06-07 11:38:29 +00:00
|
|
|
raise osv.except_osv(_('Invalid Analytic Account!'), _('You cannot select a Analytic Account which is in Close or Cancelled state.'))
|
2012-08-07 11:06:16 +00:00
|
|
|
return res
|
2012-10-03 12:16:39 +00:00
|
|
|
|
2011-01-04 07:20:18 +00:00
|
|
|
account_analytic_line()
|
2012-10-03 12:16:39 +00:00
|
|
|
|
2009-01-06 13:02:10 +00:00
|
|
|
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|