From 6e3a357e8be49e342ddf556c26505daf3290dbdb Mon Sep 17 00:00:00 2001 From: Stephane Wirtel Date: Mon, 28 Feb 2011 12:10:36 +0100 Subject: [PATCH 1/2] [IMP] document: Replace the existing file with the new content bzr revid: stephane@openerp.com-20110228111036-hfzxq0e9ez8gudfk --- addons/document/document.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/addons/document/document.py b/addons/document/document.py index 79fb83b5b1f..bd354d67d22 100644 --- a/addons/document/document.py +++ b/addons/document/document.py @@ -257,10 +257,22 @@ class document_file(osv.osv): else: if vals.get('file_size'): del vals['file_size'] - if not self._check_duplication(cr, uid, vals): - raise osv.except_osv(_('ValidateError'), _('File name must be unique!')) - result = super(document_file, self).create(cr, uid, vals, context) - cr.commit() # ? + result = self._check_duplication(cr, uid, vals) + if not result: + domain = [ + ('res_id', '=', vals['res_id']), + ('res_model', '=', vals['res_model']), + ('datas_fname', '=', vals['datas_fname']), + ] + attach_ids = self.search(cr, uid, domain, context=context) + super(document_file, self).write(cr, uid, attach_ids, + {'datas' : vals['datas']}, + context=context) + result = attach_ids[0] + else: + #raise osv.except_osv(_('ValidateError'), _('File name must be unique!')) + result = super(document_file, self).create(cr, uid, vals, context) + cr.commit() # ? return result def __get_partner_id(self, cr, uid, res_model, res_id, context=None): From fb544b4212d552739ed318be8f68db91e1f9e315 Mon Sep 17 00:00:00 2001 From: Stephane Wirtel Date: Mon, 28 Feb 2011 13:38:17 +0100 Subject: [PATCH 2/2] [FIX] Remove the readonly attribute on the Manager of the department bzr revid: stephane@openerp.com-20110228123817-e9xstt1ugcduoqmy --- addons/hr/hr.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/hr/hr.py b/addons/hr/hr.py index e2b9a7089f3..917e5f77b7a 100644 --- a/addons/hr/hr.py +++ b/addons/hr/hr.py @@ -154,7 +154,7 @@ class hr_employee(osv.osv): 'work_email': fields.char('Work E-mail', size=240), 'work_location': fields.char('Office Location', size=32), 'notes': fields.text('Notes'), - 'parent_id': fields.related('department_id', 'manager_id', relation='hr.employee', string='Manager', type='many2one', store=True, select=True, readonly=True, help="It is linked with manager of Department"), + 'parent_id': fields.related('department_id', 'manager_id', relation='hr.employee', string='Manager', type='many2one', store=True, select=True, help="It is linked with manager of Department"), 'category_ids': fields.many2many('hr.employee.category', 'employee_category_rel','category_id','emp_id','Category'), 'child_ids': fields.one2many('hr.employee', 'parent_id', 'Subordinates'), 'resource_id': fields.many2one('resource.resource', 'Resource', ondelete='cascade', required=True),