From 44e02f756b0066f61e1bbea648f92ea23a0aac02 Mon Sep 17 00:00:00 2001 From: Florent Xicluna Date: Wed, 8 Feb 2012 16:33:04 +0100 Subject: [PATCH 001/118] =?UTF-8?q?[FIX]=C2=A0file=5Fopen=20should=20not?= =?UTF-8?q?=20search=20zip=20files=20outside=20its=20root=20directory.=20?= =?UTF-8?q?=20Fix=20the=20returned=20value=20with=20pathinfo=3DTrue.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit lp bug: https://launchpad.net/bugs/928507 fixed lp bug: https://launchpad.net/bugs/928376 fixed bzr revid: florent.xicluna@gmail.com-20120208153304-9443zx2z09bws10x --- openerp/tools/misc.py | 89 ++++++++++++++++++++++++------------------- 1 file changed, 49 insertions(+), 40 deletions(-) diff --git a/openerp/tools/misc.py b/openerp/tools/misc.py index a5c72900fc7..3c9210214b1 100644 --- a/openerp/tools/misc.py +++ b/openerp/tools/misc.py @@ -134,7 +134,7 @@ def file_open(name, mode="r", subdir='addons', pathinfo=False): @param name name of the file @param mode file open mode @param subdir subdirectory - @param pathinfo if True returns tupple (fileobject, filepath) + @param pathinfo if True returns tuple (fileobject, filepath) @return fileobject if pathinfo is False else (fileobject, filepath) """ @@ -142,44 +142,51 @@ def file_open(name, mode="r", subdir='addons', pathinfo=False): adps = addons.module.ad_paths rtp = os.path.normcase(os.path.abspath(config['root_path'])) - if name.replace(os.path.sep, '/').startswith('addons/'): + if os.path.isabs(name): + # It is an absolute path + # Is it below 'addons_path' or 'root_path'? + name = os.path.normcase(os.path.normpath(name)) + for root in adps + [rtp]: + if name.startswith(root): + base = root.rstrip(os.sep) + name = name[len(base) + 1:] + break + else: + # It is outside the OpenERP root: skip zipfile lookup. + base, name = os.path.split(name) + return _fileopen(name, mode=mode, basedir=base, pathinfo=pathinfo) + + if name.replace(os.sep, '/').startswith('addons/'): subdir = 'addons' - name = name[7:] + name2 = name[7:] + elif subdir: + name = os.path.join(subdir, name) + if name.replace(os.sep, '/').startswith('addons/'): + subdir = 'addons' + name2 = name[7:] + else: + name2 = name - # First try to locate in addons_path + # First, try to locate in addons_path if subdir: - subdir2 = subdir - if subdir2.replace(os.path.sep, '/').startswith('addons/'): - subdir2 = subdir2[7:] - - subdir2 = (subdir2 != 'addons' or None) and subdir2 - for adp in adps: try: - if subdir2: - fn = os.path.join(adp, subdir2, name) - else: - fn = os.path.join(adp, name) - fn = os.path.normpath(fn) - fo = file_open(fn, mode=mode, subdir=None, pathinfo=pathinfo) - if pathinfo: - return fo, fn - return fo + return _fileopen(name2, mode=mode, basedir=adp, + pathinfo=pathinfo) except IOError: pass - if subdir: - name = os.path.join(rtp, subdir, name) - else: - name = os.path.join(rtp, name) + # Second, try to locate in root_path + return _fileopen(name, mode=mode, basedir=rtp, pathinfo=pathinfo) - name = os.path.normpath(name) - # Check for a zipfile in the path - head = name - zipname = False +def _fileopen(path, mode, basedir, pathinfo): + head = os.path.normpath(path) + name = os.path.normpath(os.path.join(basedir, path)) name2 = False - while True: + zipname = False + # Check for a zipfile in the path, but stop at the 'basedir' level + while os.sep in head: head, tail = os.path.split(head) if not tail: break @@ -187,9 +194,10 @@ def file_open(name, mode="r", subdir='addons', pathinfo=False): zipname = os.path.join(tail, zipname) else: zipname = tail - if zipfile.is_zipfile(head+'.zip'): + zpath = os.path.join(basedir, head + '.zip') + if zipfile.is_zipfile(zpath): from cStringIO import StringIO - zfile = zipfile.ZipFile(head+'.zip') + zfile = zipfile.ZipFile(zpath) try: fo = StringIO() fo.write(zfile.read(os.path.join( @@ -197,20 +205,21 @@ def file_open(name, mode="r", subdir='addons', pathinfo=False): os.sep, '/'))) fo.seek(0) if pathinfo: - return fo, name + return (fo, name) return fo except Exception: - name2 = os.path.normpath(os.path.join(head + '.zip', zipname)) - pass - for i in (name2, name): - if i and os.path.isfile(i): - fo = file(i, mode) + name2 = os.path.normpath(os.path.join(zpath, zipname)) + # Look for a normal file + for fname in (name2, name): + if fname and os.path.isfile(fname): + fo = open(fname, mode) if pathinfo: - return fo, i + return (fo, fname) return fo - if os.path.splitext(name)[1] == '.rml': - raise IOError, 'Report %s doesn\'t exist or deleted : ' %str(name) - raise IOError, 'File not found : %s' % name + # Not found + if name.endswith('.rml'): + raise IOError('Report %r doesn\'t exist or deleted' % name) + raise IOError('File not found: %s' % name) #---------------------------------------------------------- From 69a5eca5b48740c44e35ac5b0285e22a17c5dd8d Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Wed, 8 Feb 2012 18:39:32 +0100 Subject: [PATCH 002/118] [IMP] Give precedence to module directories instead of zips while locating resources The previous behavior gave the precedence to zipped modules, without any apparent reason, and this is sub-optimal for several reasons: 1. The default is to have regular modules, not zipped modules, so looking first for a regular module is more efficient. 2. Keeping a zipped module next to a regular module with the same name is not a documented or supported feature. 3. Even if you were relying on this behavior having the extracted module take precedence is more practical: you could simply extract the zipped module to test a quick fix. We have another issue related to this feature because the code looking for zipped modules escapes the addons paths chroot and goes up to the filesystem root looking for a zip module at each step. This is described in bug 928376 and a fix for it should follow. lp bug: https://launchpad.net/bugs/928376 fixed bzr revid: odo@openerp.com-20120208173932-pwhz53vxxdzbo8ja --- openerp/modules/module.py | 25 ++++++++++++++----------- openerp/tools/misc.py | 24 +++++++++++++++--------- 2 files changed, 29 insertions(+), 20 deletions(-) diff --git a/openerp/modules/module.py b/openerp/modules/module.py index 58a4547ff07..3d3bc0d9adf 100644 --- a/openerp/modules/module.py +++ b/openerp/modules/module.py @@ -280,25 +280,28 @@ def get_module_as_zip(modulename, b64enc=True, src=True): def get_module_resource(module, *args): """Return the full path of a resource of the given module. - @param module: the module - @param args: the resource path components + :param module: module name + :param list(str) args: resource path components within module - @return: absolute path to the resource + :rtype: str + :return: absolute path to the resource TODO name it get_resource_path TODO make it available inside on osv object (self.get_resource_path) """ - a = get_module_path(module) - if not a: return False - resource_path = opj(a, *args) - if zipfile.is_zipfile( a +'.zip') : - zip = zipfile.ZipFile( a + ".zip") + mod_path = get_module_path(module) + if not mod_path: return False + resource_path = opj(mod_path, *args) + if os.path.isdir(mod_path): + # the module is a directory - ignore zip behavior + if os.path.exists(resource_path): + return resource_path + elif zipfile.is_zipfile(mod_path + '.zip'): + zip = zipfile.ZipFile( mod_path + ".zip") files = ['/'.join(f.split('/')[1:]) for f in zip.namelist()] resource_path = '/'.join(args) if resource_path in files: - return opj(a, resource_path) - elif os.path.exists(resource_path): - return resource_path + return opj(mod_path, resource_path) return False def get_module_icon(module): diff --git a/openerp/tools/misc.py b/openerp/tools/misc.py index a5c72900fc7..e0be5ffaef9 100644 --- a/openerp/tools/misc.py +++ b/openerp/tools/misc.py @@ -175,10 +175,22 @@ def file_open(name, mode="r", subdir='addons', pathinfo=False): name = os.path.normpath(name) - # Check for a zipfile in the path + # Give higher priority to module directories, which is + # a more common case than zipped modules. + if os.path.isfile(name): + fo = file(name, mode) + if pathinfo: + return fo, name + return fo + + # Support for loading modules in zipped form. + # This will not work for zipped modules that are sitting + # outside of known addons paths. head = name zipname = False - name2 = False + # FIXME: implement chrooting inside addons paths and fix + # for incorrect path_info behavior. Work in progress by + # Florent X linked to bug 928376 while True: head, tail = os.path.split(head) if not tail: @@ -200,14 +212,8 @@ def file_open(name, mode="r", subdir='addons', pathinfo=False): return fo, name return fo except Exception: - name2 = os.path.normpath(os.path.join(head + '.zip', zipname)) pass - for i in (name2, name): - if i and os.path.isfile(i): - fo = file(i, mode) - if pathinfo: - return fo, i - return fo + if os.path.splitext(name)[1] == '.rml': raise IOError, 'Report %s doesn\'t exist or deleted : ' %str(name) raise IOError, 'File not found : %s' % name From 9c03b140ce4444479d64130a6b75f3b44db79701 Mon Sep 17 00:00:00 2001 From: "Kuldeep Joshi (OpenERP)" Date: Tue, 10 Jul 2012 14:51:35 +0530 Subject: [PATCH 003/118] [FIX]event: add oe_google_map class bzr revid: kjo@tinyerp.com-20120710092135-wskq7ga5da8jqdrc --- addons/event/event_view.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/event/event_view.xml b/addons/event/event_view.xml index 142ba2bb2a4..a3a7bff8107 100644 --- a/addons/event/event_view.xml +++ b/addons/event/event_view.xml @@ -138,7 +138,7 @@ - +
From 3bd4660e92f57d1bd1a8b985f2590e13db31f710 Mon Sep 17 00:00:00 2001 From: "Divyesh Makwana (Open ERP)" Date: Wed, 8 Aug 2012 12:36:12 +0530 Subject: [PATCH 004/118] [IMP] account : Convert invoice line to editable list and call the onchange method to set all the information. bzr revid: mdi@tinyerp.com-20120808070612-20q3wyqkevgtjnx6 --- addons/account/account_invoice.py | 6 ++++++ addons/account/account_invoice_view.xml | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/addons/account/account_invoice.py b/addons/account/account_invoice.py index b1c5db23df6..7000ca189dc 100644 --- a/addons/account/account_invoice.py +++ b/addons/account/account_invoice.py @@ -1361,10 +1361,16 @@ class account_invoice_line(osv.osv): 'company_id': fields.related('invoice_id','company_id',type='many2one',relation='res.company',string='Company', store=True, readonly=True), 'partner_id': fields.related('invoice_id','partner_id',type='many2one',relation='res.partner',string='Partner',store=True) } + + def default_account_id(self, cr, uid, ids, context=None): + prop = self.pool.get('ir.property').get(cr, uid, 'property_account_income_categ', 'product.category', context=context) + return prop and prop.id or False + _defaults = { 'quantity': 1, 'discount': 0.0, 'price_unit': _price_unit_default, + 'account_id': default_account_id, } def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False): diff --git a/addons/account/account_invoice_view.xml b/addons/account/account_invoice_view.xml index 501a50b96c2..8fbd85f2599 100644 --- a/addons/account/account_invoice_view.xml +++ b/addons/account/account_invoice_view.xml @@ -347,7 +347,7 @@ - + Date: Thu, 9 Aug 2012 10:57:30 +0530 Subject: [PATCH 005/118] [FIX]purchase :set a po line editable bzr revid: mma@tinyerp.com-20120809052730-4c0ykb7k54v6ju44 --- addons/purchase/purchase_view.xml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/addons/purchase/purchase_view.xml b/addons/purchase/purchase_view.xml index 47216a11cac..9c8b508553d 100644 --- a/addons/purchase/purchase_view.xml +++ b/addons/purchase/purchase_view.xml @@ -218,11 +218,12 @@ - + + - - + + From 1a36733f5be49a3de6d45548cf5b4f41caad7ceb Mon Sep 17 00:00:00 2001 From: "Ajay Chauhan (OpenERP)" Date: Thu, 9 Aug 2012 14:14:30 +0530 Subject: [PATCH 006/118] [IMP]hr_expense : made expense line editable bzr revid: cha@tinyerp.com-20120809084430-fvhy9nfph9xiwwna --- addons/hr_expense/hr_expense.py | 29 ++++++++++++++++++++++----- addons/hr_expense/hr_expense_view.xml | 16 +++++++++++++-- 2 files changed, 38 insertions(+), 7 deletions(-) diff --git a/addons/hr_expense/hr_expense.py b/addons/hr_expense/hr_expense.py index b1192701dfb..74eac5d99c2 100644 --- a/addons/hr_expense/hr_expense.py +++ b/addons/hr_expense/hr_expense.py @@ -253,15 +253,23 @@ class hr_expense_line(osv.osv): res = dict(cr.fetchall()) return res + def _get_uom_id(self, cr, uid, context=None): + try: + proxy = self.pool.get('ir.model.data') + result = proxy.get_object_reference(cr, uid, 'product', 'product_uom_unit') + return result[1] + except Exception, ex: + return False + _columns = { 'name': fields.char('Expense Note', size=128, required=True), 'date_value': fields.date('Date', required=True), 'expense_id': fields.many2one('hr.expense.expense', 'Expense', ondelete='cascade', select=True), 'total_amount': fields.function(_amount, string='Total', digits_compute=dp.get_precision('Account')), 'unit_amount': fields.float('Unit Price', digits_compute=dp.get_precision('Account')), - 'unit_quantity': fields.float('Quantities' ), + 'unit_quantity': fields.float('Quantities'), 'product_id': fields.many2one('product.product', 'Product', domain=[('hr_expense_ok','=',True)]), - 'uom_id': fields.many2one('product.uom', 'Unit of Measure'), + 'uom_id': fields.many2one('product.uom', 'Unit of Measure', required=True), 'description': fields.text('Description'), 'analytic_account': fields.many2one('account.analytic.account','Analytic account'), 'ref': fields.char('Reference', size=32), @@ -270,20 +278,31 @@ class hr_expense_line(osv.osv): _defaults = { 'unit_quantity': 1, 'date_value': lambda *a: time.strftime('%Y-%m-%d'), + 'uom_id': _get_uom_id, } _order = "sequence, date_value desc" - def onchange_product_id(self, cr, uid, ids, product_id, uom_id, employee_id, context=None): + def onchange_product_id(self, cr, uid, ids, product_id, context=None): res = {} if product_id: product = self.pool.get('product.product').browse(cr, uid, product_id, context=context) res['name'] = product.name amount_unit = product.price_get('standard_price')[product.id] res['unit_amount'] = amount_unit - if not uom_id: - res['uom_id'] = product.uom_id.id + res['uom_id'] = product.uom_id.id return {'value': res} + def onchange_uom(self, cr, uid, ids, product_id, uom_id, context=None): + res = {'value':{}} + if product_id: + product = self.pool.get('product.product').browse(cr, uid, product_id, context=context) + uom = self.pool.get('product.uom').browse(cr, uid, uom_id, context=context) + if uom.category_id.id != product.uom_id.category_id.id: + res['warning'] = {'title': _('Warning'), 'message': _('Selected Unit of Measure does not belong to the same category as the product Unit of Measure')} + uom_id = product.uom_id.id + res['value'].update({'uom_id': uom_id}) + return res + hr_expense_line() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/hr_expense/hr_expense_view.xml b/addons/hr_expense/hr_expense_view.xml index 67c08ee8a65..57b7a4cc37f 100644 --- a/addons/hr_expense/hr_expense_view.xml +++ b/addons/hr_expense/hr_expense_view.xml @@ -92,7 +92,7 @@
- + @@ -102,12 +102,24 @@
+ + + + + + + + + + + +
From 4cc8dce4ec176928cf7d092f587f9c1b6ec9db75 Mon Sep 17 00:00:00 2001 From: "Ajay Chauhan (OpenERP)" Date: Thu, 9 Aug 2012 16:21:03 +0530 Subject: [PATCH 007/118] [IMP] hr_expense : added condition to function bzr revid: cha@tinyerp.com-20120809105103-tm0m7g854zglxfrg --- addons/hr_expense/hr_expense.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/addons/hr_expense/hr_expense.py b/addons/hr_expense/hr_expense.py index 74eac5d99c2..d822d466901 100644 --- a/addons/hr_expense/hr_expense.py +++ b/addons/hr_expense/hr_expense.py @@ -294,13 +294,14 @@ class hr_expense_line(osv.osv): def onchange_uom(self, cr, uid, ids, product_id, uom_id, context=None): res = {'value':{}} - if product_id: - product = self.pool.get('product.product').browse(cr, uid, product_id, context=context) - uom = self.pool.get('product.uom').browse(cr, uid, uom_id, context=context) - if uom.category_id.id != product.uom_id.category_id.id: - res['warning'] = {'title': _('Warning'), 'message': _('Selected Unit of Measure does not belong to the same category as the product Unit of Measure')} - uom_id = product.uom_id.id - res['value'].update({'uom_id': uom_id}) + if uom_id: + if product_id: + product = self.pool.get('product.product').browse(cr, uid, product_id, context=context) + uom = self.pool.get('product.uom').browse(cr, uid, uom_id, context=context) + if uom.category_id.id != product.uom_id.category_id.id: + res['warning'] = {'title': _('Warning'), 'message': _('Selected Unit of Measure does not belong to the same category as the product Unit of Measure')} + uom_id = product.uom_id.id + res['value'].update({'uom_id': uom_id}) return res hr_expense_line() From 5e0f7094105b8722f3d5b0007f46188be095d888 Mon Sep 17 00:00:00 2001 From: Vo Minh Thu Date: Mon, 13 Aug 2012 11:10:47 +0200 Subject: [PATCH 008/118] [IMP] views: allow create/delete/edit attribte on form/tree/kanban views, automatically set the attributes from access rights. bzr revid: vmt@openerp.com-20120813091047-vqjk3an52dfzbhqe --- openerp/addons/base/rng/view.rng | 8 ++++++++ openerp/osv/orm.py | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/openerp/addons/base/rng/view.rng b/openerp/addons/base/rng/view.rng index c583040495b..c56892d7a07 100644 --- a/openerp/addons/base/rng/view.rng +++ b/openerp/addons/base/rng/view.rng @@ -172,6 +172,9 @@ + + + @@ -220,6 +223,8 @@ + + @@ -235,6 +240,9 @@ + + + diff --git a/openerp/osv/orm.py b/openerp/osv/orm.py index d8861a20c26..b359c135d00 100644 --- a/openerp/osv/orm.py +++ b/openerp/osv/orm.py @@ -1830,6 +1830,10 @@ class BaseModel(object): fields = self.fields_get(cr, user, None, context) fields_def = self.__view_look_dom(cr, user, node, view_id, False, fields, context=context) node = self._disable_workflow_buttons(cr, user, node) + if node.tag in ('kanban', 'tree', 'form'): + for a, b in (('create', 'check_create'), ('delete', 'check_unlink'), ('edit', 'check_write')): + if not node.get(a) and not getattr(self, b)(cr, user, raise_exception=False): + node.set(a, 'false') arch = etree.tostring(node, encoding="utf-8").replace('\t', '') for k in fields.keys(): if k not in fields_def: From 076fdb09940c57c385c3b3f7639bb893464afb69 Mon Sep 17 00:00:00 2001 From: Jigar Amin - OpenERP Date: Tue, 14 Aug 2012 18:38:21 +0530 Subject: [PATCH 009/118] [IMP] views should show the button create/edit/delete/duplicate on the view tag create/edit/delete attributes bzr revid: jam@tinyerp.com-20120814130821-ret2z62dsthle39p --- addons/web/static/src/js/view_form.js | 15 +++++++++++++-- addons/web/static/src/js/view_list.js | 11 +++++++++-- addons/web/static/src/xml/base.xml | 18 ++++++++++++------ 3 files changed, 34 insertions(+), 10 deletions(-) diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index baf8c151b83..2e800191749 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -148,9 +148,17 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM if(this.fields_view.toolbar) { this.sidebar.add_toolbar(this.fields_view.toolbar); } + if (self._is_action_enabled('delete')){ + this.sidebar.add_items('other', [ + { label: _t('Delete'), callback: self.on_button_delete }, + ]); + } + if (self._is_action_enabled('create')){ + this.sidebar.add_items('other', [ + { label: _t('Duplicate'), callback: self.on_button_duplicate } + ]); + } this.sidebar.add_items('other', [ - { label: _t('Delete'), callback: self.on_button_delete }, - { label: _t('Duplicate'), callback: self.on_button_duplicate }, { label: _t('Set Default'), callback: function (item) { self.open_defaults_dialog(); } } ]); } @@ -1042,6 +1050,9 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM open_translate_dialog: function(field) { return this._super(field); }, + _is_action_enabled: function(action) { + return (_.has(this.fields_view.arch.attrs, action))?JSON.parse(this.fields_view.arch.attrs[action]):true; + } }); /** diff --git a/addons/web/static/src/js/view_list.js b/addons/web/static/src/js/view_list.js index 986b0e49faf..3d6ec27d065 100644 --- a/addons/web/static/src/js/view_list.js +++ b/addons/web/static/src/js/view_list.js @@ -353,9 +353,13 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi this.sidebar.appendTo(this.options.$sidebar); this.sidebar.add_items('other', [ { label: _t("Import"), callback: this.on_sidebar_import }, - { label: _t("Export"), callback: this.on_sidebar_export }, - { label: _t('Delete'), callback: this.do_delete_selected } + { label: _t("Export"), callback: this.on_sidebar_export } ]); + if (self._is_action_enabled('delete')){ + this.sidebar.add_items('other', [ + { label: _t('Delete'), callback: this.do_delete_selected } + ]); + } this.sidebar.add_toolbar(this.fields_view.toolbar); this.sidebar.$element.hide(); } @@ -831,6 +835,9 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi this.$element.prepend( $('
').html(this.options.action.help) ); + }, + _is_action_enabled: function(action) { + return (_.has(this.fields_view.arch.attrs, action))?JSON.parse(this.fields_view.arch.attrs[action]):true; } }); instance.web.ListView.List = instance.web.Class.extend( /** @lends instance.web.ListView.List# */{ diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index 0eddd914f01..21d006e23ab 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -672,9 +672,11 @@
- + + + or Import @@ -747,10 +749,14 @@
-
- -
+ +
+ +
+
+ +
or Discard From 9c04845999c0c7176077781650332beb673e7a70 Mon Sep 17 00:00:00 2001 From: Jigar Amin - OpenERP Date: Tue, 14 Aug 2012 19:02:42 +0530 Subject: [PATCH 010/118] [IMP] Addded the common view attrib check method for the access ui support bzr revid: jam@tinyerp.com-20120814133242-y7ofa6oy59gj0uj4 --- addons/web/static/src/js/view_form.js | 3 --- addons/web/static/src/js/view_list.js | 3 --- addons/web/static/src/js/views.js | 8 ++++++++ 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 2e800191749..239460bbcb4 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -1050,9 +1050,6 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM open_translate_dialog: function(field) { return this._super(field); }, - _is_action_enabled: function(action) { - return (_.has(this.fields_view.arch.attrs, action))?JSON.parse(this.fields_view.arch.attrs[action]):true; - } }); /** diff --git a/addons/web/static/src/js/view_list.js b/addons/web/static/src/js/view_list.js index 3d6ec27d065..f420001669b 100644 --- a/addons/web/static/src/js/view_list.js +++ b/addons/web/static/src/js/view_list.js @@ -835,9 +835,6 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi this.$element.prepend( $('
').html(this.options.action.help) ); - }, - _is_action_enabled: function(action) { - return (_.has(this.fields_view.arch.attrs, action))?JSON.parse(this.fields_view.arch.attrs[action]):true; } }); instance.web.ListView.List = instance.web.Class.extend( /** @lends instance.web.ListView.List# */{ diff --git a/addons/web/static/src/js/views.js b/addons/web/static/src/js/views.js index 7c9dfe1d543..0fdd49633b1 100644 --- a/addons/web/static/src/js/views.js +++ b/addons/web/static/src/js/views.js @@ -1357,6 +1357,14 @@ instance.web.View = instance.web.Widget.extend({ */ reload: function () { return $.when(); + }, + _is_action_enabled: function(action) { + /** + * Takes action (e.g. create/edit/delete) and return the tag attribute from + * the view (e.g. ) + * will help to check access ui of the view. + */ + return (_.has(this.fields_view.arch.attrs, action))?JSON.parse(this.fields_view.arch.attrs[action]):true; } }); From cf464eb2733efc5a872451c08208410a45bd1b79 Mon Sep 17 00:00:00 2001 From: Jigar Amin - OpenERP Date: Thu, 16 Aug 2012 10:03:10 +0530 Subject: [PATCH 011/118] [FIX] kanban : Keep is_action_enable consistant as per previous commit bzr revid: jam@tinyerp.com-20120816043310-b0sbicnv73jgzhti --- addons/web_kanban/static/src/js/kanban.js | 6 +++--- addons/web_kanban/static/src/xml/web_kanban.xml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/web_kanban/static/src/js/kanban.js b/addons/web_kanban/static/src/js/kanban.js index 6c70ecfb8ec..155f03b8aae 100644 --- a/addons/web_kanban/static/src/js/kanban.js +++ b/addons/web_kanban/static/src/js/kanban.js @@ -68,11 +68,11 @@ instance.web_kanban.KanbanView = instance.web.View.extend({ return JSON.parse(this.fields_view.arch.attrs.quick_create); return !! this.group_by; }, - _is_create_enabled: function() { + _is_action_enabled: function(action) { if (! this.options.creatable) return false; - if (this.fields_view.arch.attrs.create !== undefined) - return JSON.parse(this.fields_view.arch.attrs.create); + if (_.has(this.fields_view.arch.attrs, action)) + return JSON.parse(this.fields_view.arch.attrs[action]); return true; }, add_qweb_template: function() { diff --git a/addons/web_kanban/static/src/xml/web_kanban.xml b/addons/web_kanban/static/src/xml/web_kanban.xml index 4bcc9a709a3..7aba4d6ee87 100644 --- a/addons/web_kanban/static/src/xml/web_kanban.xml +++ b/addons/web_kanban/static/src/xml/web_kanban.xml @@ -14,7 +14,7 @@
- + From a1182d97ed749ddf175d1c6f9f88ca3dc8ebdb1b Mon Sep 17 00:00:00 2001 From: "Twinkle Christian (OpenERP)" Date: Thu, 16 Aug 2012 15:11:23 +0530 Subject: [PATCH 012/118] [IMP]Remove or bzr revid: tch@tinyerp.com-20120816094123-f1yiealw1p59j95n --- addons/web/static/src/xml/base.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index 1728bfb584b..96adbd42d2e 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -678,7 +678,7 @@ - or Import + Import
From 4c9205ff4aa8590ec49cc9131e312c6158a8819c Mon Sep 17 00:00:00 2001 From: Jigar Amin - OpenERP Date: Thu, 16 Aug 2012 15:57:58 +0530 Subject: [PATCH 013/118] [IMP] Kanan quick create action should also repect the create tag on view bzr revid: jam@tinyerp.com-20120816102758-2swimfa9dxu3uotv --- addons/web_kanban/static/src/js/kanban.js | 7 ++++++- addons/web_kanban/static/src/xml/web_kanban.xml | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/addons/web_kanban/static/src/js/kanban.js b/addons/web_kanban/static/src/js/kanban.js index 155f03b8aae..27b3184977c 100644 --- a/addons/web_kanban/static/src/js/kanban.js +++ b/addons/web_kanban/static/src/js/kanban.js @@ -514,7 +514,12 @@ instance.web_kanban.KanbanGroup = instance.web.Widget.extend({ self.view.dataset.ids.push(id); self.do_add_records(records, true); }); - } + }, + _is_action_enabled: function(action) { + if (_.has(this.fields_view.arch.attrs, action)) + return JSON.parse(this.fields_view.arch.attrs[action]); + return true; + } }); instance.web_kanban.KanbanRecord = instance.web.Widget.extend({ diff --git a/addons/web_kanban/static/src/xml/web_kanban.xml b/addons/web_kanban/static/src/xml/web_kanban.xml index 7aba4d6ee87..7e316a2b47e 100644 --- a/addons/web_kanban/static/src/xml/web_kanban.xml +++ b/addons/web_kanban/static/src/xml/web_kanban.xml @@ -25,7 +25,7 @@
- +
]
From d42261907c2bb2f2e3c690b2d88720e6b7ecc838 Mon Sep 17 00:00:00 2001 From: Jigar Amin - OpenERP Date: Thu, 16 Aug 2012 16:32:43 +0530 Subject: [PATCH 014/118] [FIX] Gantt View Create button Shouls repect the view create teg bzr revid: jam@tinyerp.com-20120816110243-blbjzmb2xdemoupg --- addons/web_gantt/static/src/js/gantt.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/addons/web_gantt/static/src/js/gantt.js b/addons/web_gantt/static/src/js/gantt.js index 202fb2aecc6..05488fcdca9 100644 --- a/addons/web_gantt/static/src/js/gantt.js +++ b/addons/web_gantt/static/src/js/gantt.js @@ -183,12 +183,14 @@ instance.web_gantt.GanttView = instance.web.View.extend({ self.on_task_display(task_info.internal_task); } }); - - // insertion of create button - var td = $($("table td", self.$element)[0]); - var rendered = QWeb.render("GanttView-create-button"); - $(rendered).prependTo(td); - $(".oe_gantt_button_create", this.$element).click(this.on_task_create); + + // insertion of create button if gantt has crate false do not render create button + if (this._is_action_enabled('create')){ + var td = $($("table td", self.$element)[0]); + var rendered = QWeb.render("GanttView-create-button"); + $(rendered).prependTo(td); + $(".oe_gantt_button_create", this.$element).click(this.on_task_create); + } }, on_task_changed: function(task_obj) { var self = this; From 9ec6f82e382984c9e0fc415090d8c5c56892b6c4 Mon Sep 17 00:00:00 2001 From: "Twinkle Christian (OpenERP)" Date: Thu, 16 Aug 2012 16:59:20 +0530 Subject: [PATCH 015/118] [IMP]Remove or bzr revid: tch@tinyerp.com-20120816112920-i4gnwzn7z7n3v0gs --- addons/web/static/src/xml/base.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index 96adbd42d2e..614c2a91d79 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -678,7 +678,7 @@ - Import + or Import
From cfa66e42f8e99609aaddd09a612884a4c373c1fe Mon Sep 17 00:00:00 2001 From: "Ajay Chauhan (OpenERP)" Date: Thu, 16 Aug 2012 18:06:17 +0530 Subject: [PATCH 016/118] [IMP] hr_expense: improve code as per suggestion bzr revid: cha@tinyerp.com-20120816123617-afade73y5wqune2r --- addons/hr_expense/hr_expense.py | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/addons/hr_expense/hr_expense.py b/addons/hr_expense/hr_expense.py index 3683eff9f1d..fca62261814 100644 --- a/addons/hr_expense/hr_expense.py +++ b/addons/hr_expense/hr_expense.py @@ -254,12 +254,8 @@ class hr_expense_line(osv.osv): return res def _get_uom_id(self, cr, uid, context=None): - try: - proxy = self.pool.get('ir.model.data') - result = proxy.get_object_reference(cr, uid, 'product', 'product_uom_unit') - return result[1] - except Exception, ex: - return False + result = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'product', 'product_uom_unit') + return result and result[1] or False _columns = { 'name': fields.char('Expense Note', size=128, required=True), @@ -294,14 +290,15 @@ class hr_expense_line(osv.osv): def onchange_uom(self, cr, uid, ids, product_id, uom_id, context=None): res = {'value':{}} - if uom_id: - if product_id: - product = self.pool.get('product.product').browse(cr, uid, product_id, context=context) - uom = self.pool.get('product.uom').browse(cr, uid, uom_id, context=context) - if uom.category_id.id != product.uom_id.category_id.id: - res['warning'] = {'title': _('Warning'), 'message': _('Selected Unit of Measure does not belong to the same category as the product Unit of Measure')} - uom_id = product.uom_id.id - res['value'].update({'uom_id': uom_id}) + if not uom_id: + return res + if product_id: + product = self.pool.get('product.product').browse(cr, uid, product_id, context=context) + uom = self.pool.get('product.uom').browse(cr, uid, uom_id, context=context) + if uom.category_id.id != product.uom_id.category_id.id: + res['warning'] = {'title': _('Warning'), 'message': _('Selected Unit of Measure does not belong to the same category as the product Unit of Measure')} + uom_id = product.uom_id.id + res['value'].update({'uom_id': uom_id}) return res hr_expense_line() From 9aca3bac8bcff422f1f7354f97cf43f1efbbd6e9 Mon Sep 17 00:00:00 2001 From: Jigar Amin - OpenERP Date: Thu, 16 Aug 2012 18:27:06 +0530 Subject: [PATCH 017/118] [REF/IMP] refectorec the varibale names and added the gantt view, added create ndoe button diable condition bzr revid: jam@tinyerp.com-20120816125706-h92owusp47t6chl1 --- openerp/addons/base/rng/view.rng | 4 ++++ openerp/osv/orm.py | 12 ++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/openerp/addons/base/rng/view.rng b/openerp/addons/base/rng/view.rng index c56892d7a07..b82c96fdb60 100644 --- a/openerp/addons/base/rng/view.rng +++ b/openerp/addons/base/rng/view.rng @@ -184,6 +184,7 @@ + @@ -381,6 +382,9 @@ 5years + + + diff --git a/openerp/osv/orm.py b/openerp/osv/orm.py index 0a8a05e7706..ea9f1c094e3 100644 --- a/openerp/osv/orm.py +++ b/openerp/osv/orm.py @@ -1824,6 +1824,10 @@ class BaseModel(object): if node.getchildren()[0].tag == 'node': node_fields = self.pool.get(node.getchildren()[0].get('object')).fields_get(cr, user, None, context) fields.update(node_fields) + if not node.get("create"): + fn = getattr(self.pool.get(node.getchildren()[1].get('object')), 'check_create') + if not fn(cr, user, raise_exception=False): + node.set("create", 'false') if node.getchildren()[1].tag == 'arrow': arrow_fields = self.pool.get(node.getchildren()[1].get('object')).fields_get(cr, user, None, context) fields.update(arrow_fields) @@ -1831,10 +1835,10 @@ class BaseModel(object): fields = self.fields_get(cr, user, None, context) fields_def = self.__view_look_dom(cr, user, node, view_id, False, fields, context=context) node = self._disable_workflow_buttons(cr, user, node) - if node.tag in ('kanban', 'tree', 'form'): - for a, b in (('create', 'check_create'), ('delete', 'check_unlink'), ('edit', 'check_write')): - if not node.get(a) and not getattr(self, b)(cr, user, raise_exception=False): - node.set(a, 'false') + if node.tag in ('kanban', 'tree', 'form', 'gantt'): + for action, fn in (('create', 'check_create'), ('delete', 'check_unlink'), ('edit', 'check_write')): + if not node.get(action) and not getattr(self, fn)(cr, user, raise_exception=False): + node.set(action, 'false') arch = etree.tostring(node, encoding="utf-8").replace('\t', '') for k in fields.keys(): if k not in fields_def: From 41964c4b9d9b53358b3fc01700bd2306f13916c6 Mon Sep 17 00:00:00 2001 From: Jigar Amin - OpenERP Date: Thu, 16 Aug 2012 18:30:12 +0530 Subject: [PATCH 018/118] [IMP] View Button Constrains: Diagrem view add node button, kanban record slidebar widget mnethod support bzr revid: jam@tinyerp.com-20120816130012-ibtv0ipbbnpznqb1 --- addons/web_diagram/static/src/js/diagram.js | 2 +- addons/web_diagram/static/src/xml/base_diagram.xml | 8 +++++--- addons/web_kanban/static/src/js/kanban.js | 3 +++ 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/addons/web_diagram/static/src/js/diagram.js b/addons/web_diagram/static/src/js/diagram.js index f06e757f7f1..02216052c69 100644 --- a/addons/web_diagram/static/src/js/diagram.js +++ b/addons/web_diagram/static/src/js/diagram.js @@ -44,7 +44,7 @@ instance.web.DiagramView = instance.web.View.extend({ this.node = this.nodes.attrs.object, this.connector = this.connectors.attrs.object; - this.$element.html(QWeb.render("DiagramView", this)); + this.$element.html(QWeb.render("DiagramView", {'widget':self})); this.$element.addClass(this.fields_view.arch.attrs['class']); this.$element.find('div.oe_diagram_pager button[data-pager-action]').click(function() { diff --git a/addons/web_diagram/static/src/xml/base_diagram.xml b/addons/web_diagram/static/src/xml/base_diagram.xml index 96e32f59648..f883f949457 100644 --- a/addons/web_diagram/static/src/xml/base_diagram.xml +++ b/addons/web_diagram/static/src/xml/base_diagram.xml @@ -2,9 +2,11 @@

-
- -
+ +
+ +
+
0 / 0 diff --git a/addons/web_kanban/static/src/js/kanban.js b/addons/web_kanban/static/src/js/kanban.js index 27b3184977c..84a0a76ba0d 100644 --- a/addons/web_kanban/static/src/js/kanban.js +++ b/addons/web_kanban/static/src/js/kanban.js @@ -785,6 +785,9 @@ instance.web_kanban.KanbanRecord = instance.web.Widget.extend({ }, kanban_compute_domain: function(domain) { return instance.web.form.compute_domain(domain, this.values); + }, + _is_action_enabled: function(action) { + return (_.has(this.fields_view.arch.attrs, action))?JSON.parse(this.fields_view.arch.attrs[action]):true; } }); From b478264bded10e59ef4ff83997fe03757dcd9d75 Mon Sep 17 00:00:00 2001 From: "Ajay Chauhan (OpenERP)" Date: Thu, 16 Aug 2012 19:11:49 +0530 Subject: [PATCH 019/118] [IMP] hr_expense: made change in condition bzr revid: cha@tinyerp.com-20120816134149-wjumyv73z72sh6w5 --- addons/hr_expense/hr_expense.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/addons/hr_expense/hr_expense.py b/addons/hr_expense/hr_expense.py index fca62261814..44ecef2ebba 100644 --- a/addons/hr_expense/hr_expense.py +++ b/addons/hr_expense/hr_expense.py @@ -290,15 +290,14 @@ class hr_expense_line(osv.osv): def onchange_uom(self, cr, uid, ids, product_id, uom_id, context=None): res = {'value':{}} - if not uom_id: + if not uom_id or not product_id: return res - if product_id: - product = self.pool.get('product.product').browse(cr, uid, product_id, context=context) - uom = self.pool.get('product.uom').browse(cr, uid, uom_id, context=context) - if uom.category_id.id != product.uom_id.category_id.id: - res['warning'] = {'title': _('Warning'), 'message': _('Selected Unit of Measure does not belong to the same category as the product Unit of Measure')} - uom_id = product.uom_id.id - res['value'].update({'uom_id': uom_id}) + product = self.pool.get('product.product').browse(cr, uid, product_id, context=context) + uom = self.pool.get('product.uom').browse(cr, uid, uom_id, context=context) + if uom.category_id.id != product.uom_id.category_id.id: + res['warning'] = {'title': _('Warning'), 'message': _('Selected Unit of Measure does not belong to the same category as the product Unit of Measure')} + uom_id = product.uom_id.id + res['value'].update({'uom_id': uom_id}) return res hr_expense_line() From 811466be2faef29b9a0f53f4ae5126a8a8134bba Mon Sep 17 00:00:00 2001 From: "Divyesh Makwana (Open ERP)" Date: Fri, 17 Aug 2012 11:21:34 +0530 Subject: [PATCH 020/118] [IMP] account : Improved the onchange uos_id method. bzr revid: mdi@tinyerp.com-20120817055134-4p4gcsgusmyk34wd --- addons/account/account_invoice.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/addons/account/account_invoice.py b/addons/account/account_invoice.py index 225904f28b7..f0d2f2d8360 100644 --- a/addons/account/account_invoice.py +++ b/addons/account/account_invoice.py @@ -1479,10 +1479,11 @@ class account_invoice_line(osv.osv): prod = self.pool.get('product.product').browse(cr, uid, product, context=context) prod_uom = self.pool.get('product.uom').browse(cr, uid, uom, context=context) if prod.uom_id.category_id.id != prod_uom.category_id.id: - warning = { + warning = { 'title': _('Warning!'), 'message': _('The selected unit of measure is not compatible with the unit of measure of the product.') - } + } + res['value'].update({'uos_id': prod.uom_id.id}) return {'value': res['value'], 'warning': warning} return res From 32201e28604f119a0c59f6aee8fe4b511f637c6f Mon Sep 17 00:00:00 2001 From: "Divyesh Makwana (Open ERP)" Date: Fri, 17 Aug 2012 11:26:39 +0530 Subject: [PATCH 021/118] [IMP] account : Improved the code. bzr revid: mdi@tinyerp.com-20120817055639-sc5c9awb2h8d59zl --- addons/account/account_invoice.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/account/account_invoice.py b/addons/account/account_invoice.py index f0d2f2d8360..44531a1a266 100644 --- a/addons/account/account_invoice.py +++ b/addons/account/account_invoice.py @@ -1362,7 +1362,7 @@ class account_invoice_line(osv.osv): 'partner_id': fields.related('invoice_id','partner_id',type='many2one',relation='res.partner',string='Partner',store=True) } - def default_account_id(self, cr, uid, ids, context=None): + def _default_account_id(self, cr, uid, ids, context=None): prop = self.pool.get('ir.property').get(cr, uid, 'property_account_income_categ', 'product.category', context=context) return prop and prop.id or False @@ -1370,7 +1370,7 @@ class account_invoice_line(osv.osv): 'quantity': 1, 'discount': 0.0, 'price_unit': _price_unit_default, - 'account_id': default_account_id, + 'account_id': _default_account_id, } def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False): From cb33a1cf130ca60c5fd36cd4202e59997b98f3e1 Mon Sep 17 00:00:00 2001 From: "Twinkle Christian (OpenERP)" Date: Fri, 17 Aug 2012 12:58:30 +0530 Subject: [PATCH 022/118] [IMP]Add class bzr revid: tch@tinyerp.com-20120817072830-mlsljis5ryd9i66c --- addons/crm/crm_lead_view.xml | 4 ++-- addons/hr_recruitment/hr_recruitment_view.xml | 4 ++-- addons/project/project_view.xml | 8 ++++---- addons/project_issue/project_issue_view.xml | 4 ++-- addons/survey/survey_view.xml | 4 ++-- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/addons/crm/crm_lead_view.xml b/addons/crm/crm_lead_view.xml index f2c923844ec..642d282d532 100644 --- a/addons/crm/crm_lead_view.xml +++ b/addons/crm/crm_lead_view.xml @@ -311,8 +311,8 @@
í