Merge from trunk
[odoo/odoo.git] / addons / hr_timesheet / hr_timesheet.py
index 9950a1d..1f4f8d2 100644 (file)
@@ -1,22 +1,21 @@
 # -*- coding: utf-8 -*-
 ##############################################################################
-#
-#    OpenERP, Open Source Management Solution  
-#    Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
-#    $Id$
+#    
+#    OpenERP, Open Source Management Solution
+#    Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
 #
 #    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
-#    the Free Software Foundation, either version 3 of the License, or
-#    (at your option) any later version.
+#    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.
 #
 #    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
-#    GNU General Public License for more details.
+#    GNU Affero General Public License for more details.
 #
-#    You should have received a copy of the GNU General Public License
-#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.     
 #
 ##############################################################################
 
@@ -30,7 +29,7 @@ class hr_employee(osv.osv):
     _name = "hr.employee"
     _inherit = "hr.employee"
     _columns = {
-        'product_id': fields.many2one('product.product', 'Product'),
+        'product_id': fields.many2one('product.product', 'Product', help="Specifies employee's designation as a product with type 'service'."),
         'journal_id': fields.many2one('account.analytic.journal', 'Analytic Journal')
     }
 hr_employee()
@@ -54,11 +53,13 @@ class hr_analytic_timesheet(osv.osv):
         return super(hr_analytic_timesheet, self).unlink(cr, uid, ids, context)
 
 
-    def on_change_unit_amount(self, cr, uid, id, prod_id, unit_amount, unit, context={}):
+    def on_change_unit_amount(self, cr, uid, id, prod_id, unit_amount, date, unit, context={}):
         res = {}
 #        if prod_id and unit_amount:
-        if prod_id:
-            res = self.pool.get('account.analytic.line').on_change_unit_amount(cr, uid, id, prod_id, unit_amount,unit, context)
+        if prod_id and date:
+            # find company
+            company_id=self.pool.get('res.company')._company_default_get(cr, uid, 'account.analytic.line', context)
+            res = self.pool.get('account.analytic.line').on_change_unit_amount(cr, uid, id, prod_id, unit_amount,company_id,date,unit, context)
         return res
 
     def _getEmployeeProduct(self, cr, uid, context):