openerp-community-reviewer team mailing list archive
-
openerp-community-reviewer team
-
Mailing list archive
-
Message #06633
[Merge] lp:~camptocamp/department-mgmt/analytic_department_vre into lp:department-mgmt
Vincent Renaville@camptocamp has proposed merging lp:~camptocamp/department-mgmt/analytic_department_vre into lp:department-mgmt.
Requested reviews:
Department Core Editors (department-core-editors)
For more details, see:
https://code.launchpad.net/~camptocamp/department-mgmt/analytic_department_vre/+merge/218976
Hello,
This merge proposal, add the feature that the department of the current user is automatically set on analytic account and analytic line
--
https://code.launchpad.net/~camptocamp/department-mgmt/analytic_department_vre/+merge/218976
Your team Department Core Editors is requested to review the proposed merge of lp:~camptocamp/department-mgmt/analytic_department_vre into lp:department-mgmt.
=== modified file 'analytic_department/analytic.py'
--- analytic_department/analytic.py 2013-03-04 16:36:08 +0000
+++ analytic_department/analytic.py 2014-05-09 12:36:31 +0000
@@ -8,9 +8,34 @@
'department_id': fields.many2one('hr.department', 'Department'),
}
+ def _get_department(self, cr, uid, ids, context=None):
+ employee_obj = self.pool.get('hr.employee')
+ department_id = False
+ employee_ids = employee_obj.search(cr, uid, [('user_id','=', uid)])
+ if employee_ids:
+ department_id = employee_obj.browse(cr, uid, employee_ids[0], context=context).department_id.id
+ return department_id
+
+ _defaults = {
+ 'department_id': _get_department,
+ }
+
class AnalyticLine(orm.Model):
_inherit = "account.analytic.line"
_columns = {
'department_id': fields.many2one('hr.department', 'Department'),
}
+
+ def _get_department(self, cr, uid, ids, context=None):
+ employee_obj = self.pool.get('hr.employee')
+ department_id = False
+ employee_ids = employee_obj.search(cr, uid, [('user_id','=', uid)])
+ if employee_ids:
+ department_id = employee_obj.browse(cr, uid, employee_ids[0], context=context).department_id.id
+ return department_id
+
+ _defaults = {
+ 'department_id': _get_department,
+ }
+
Follow ups