From 9f90bf5b85d56d55ed35481204f9d0cc4289097e Mon Sep 17 00:00:00 2001 From: "Jay (Open ERP)" Date: Fri, 2 Jan 2009 15:24:21 +0530 Subject: [PATCH] Corrections bzr revid: jvo@tinyerp.com-20090102095421-qp6tihp04evfbkfn --- addons/account/account_move_line.py | 2 +- addons/account/invoice.py | 2 +- addons/account_payment/payment_view.xml | 8 ++--- addons/hr/hr.py | 30 +++++++++++++++++++ .../report_analytic_planning_view.xml | 2 +- 5 files changed, 37 insertions(+), 7 deletions(-) diff --git a/addons/account/account_move_line.py b/addons/account/account_move_line.py index 4dbc8819893..0673fac94c6 100644 --- a/addons/account/account_move_line.py +++ b/addons/account/account_move_line.py @@ -782,7 +782,7 @@ class account_move_line(osv.osv): context['journal_id'] = vals['journal_id'] if 'period_id' in vals and 'period_id' not in context: context['period_id'] = vals['period_id'] - if 'journal_id' not in context and 'move_id' in vals: + if ('journal_id' not in context) and ('move_id' in vals) and vals['move_id']: m = self.pool.get('account.move').browse(cr, uid, vals['move_id']) context['journal_id'] = m.journal_id.id context['period_id'] = m.period_id.id diff --git a/addons/account/invoice.py b/addons/account/invoice.py index bb4fde85ad6..98e2f3775ea 100644 --- a/addons/account/invoice.py +++ b/addons/account/invoice.py @@ -837,7 +837,7 @@ class account_invoice(osv.osv): 'ref':invoice.number, } - name = invoice.invoice_line[0].name + name = invoice.invoice_line and invoice.invoice_line[0].name or invoice.number l1['name'] = name l2['name'] = name diff --git a/addons/account_payment/payment_view.xml b/addons/account_payment/payment_view.xml index 4202ca94b6c..4f476339b49 100644 --- a/addons/account_payment/payment_view.xml +++ b/addons/account_payment/payment_view.xml @@ -43,7 +43,7 @@ payment.type form -
+ @@ -57,7 +57,7 @@ payment.mode tree - + @@ -68,7 +68,7 @@ payment.mode form - + @@ -77,7 +77,7 @@ - Payment mode + Payment Mode payment.mode form tree,form diff --git a/addons/hr/hr.py b/addons/hr/hr.py index 4e46240f170..51eaf8b49ff 100644 --- a/addons/hr/hr.py +++ b/addons/hr/hr.py @@ -84,11 +84,27 @@ hr_timesheet_group() class hr_employee_category(osv.osv): _name = "hr.employee.category" _description = "Employee Category" + _columns = { 'name' : fields.char("Category", size=64, required=True), 'parent_id': fields.many2one('hr.employee.category', 'Parent category', select=True), 'child_ids': fields.one2many('hr.employee.category', 'parent_id', 'Childs Categories') } + + def _check_recursion(self, cr, uid, ids): + level = 100 + while len(ids): + cr.execute('select distinct parent_id from hr_employee_category where id in ('+','.join(map(str,ids))+')') + ids = filter(None, map(lambda x:x[0], cr.fetchall())) + if not level: + return False + level -= 1 + return True + + _constraints = [ + (_check_recursion, 'Error ! You cannot create recursive Categories.', ['parent_id']) + ] + hr_employee_category() class hr_employee(osv.osv): @@ -123,6 +139,20 @@ class hr_employee(osv.osv): 'active' : lambda *a: True, } + def _check_recursion(self, cr, uid, ids): + level = 100 + while len(ids): + cr.execute('select distinct parent_id from hr_employee where id in ('+','.join(map(str,ids))+')') + ids = filter(None, map(lambda x:x[0], cr.fetchall())) + if not level: + return False + level -= 1 + return True + + _constraints = [ + (_check_recursion, 'Error ! You cannot create recursive Hierarchy of Employees.', ['parent_id']) + ] + hr_employee() class hr_timesheet(osv.osv): diff --git a/addons/report_analytic_planning/report_analytic_planning_view.xml b/addons/report_analytic_planning/report_analytic_planning_view.xml index 933c022e682..0e57170e4c7 100644 --- a/addons/report_analytic_planning/report_analytic_planning_view.xml +++ b/addons/report_analytic_planning/report_analytic_planning_view.xml @@ -34,7 +34,7 @@ - +