From 74fbbc36e143cef98c8546ac560c5fb630a41b4e Mon Sep 17 00:00:00 2001 From: "Naresh (OpenERP)" Date: Fri, 2 Dec 2011 15:52:02 +0530 Subject: [PATCH 01/14] [FIX]:Properties should be deleted when the related record is deleted lp bug: https://launchpad.net/bugs/891580 fixed bzr revid: nch@tinyerp.com-20111202102202-0jzzlqu68fypbbl3 --- openerp/osv/orm.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/openerp/osv/orm.py b/openerp/osv/orm.py index 90a8975b27a..db5006cf71d 100644 --- a/openerp/osv/orm.py +++ b/openerp/osv/orm.py @@ -3659,6 +3659,13 @@ class BaseModel(object): self.check_unlink(cr, uid) properties = self.pool.get('ir.property') + ##search if there are properties created with resource that is about to be deleted + ## if found delete the properties too. + unlink_properties = properties.search(cr, uid, [('res_id', 'in', ['%s,%s' % (self._name, i) for i in ids])], context=context) + if unlink_properties: + properties.unlink(cr, uid, unlink_properties, context=context) + + ## check if the model is used as a default property domain = [('res_id', '=', False), ('value_reference', 'in', ['%s,%s' % (self._name, i) for i in ids]), ] From 28e4bbcde34c44c9053acc101a8c45d89817cb24 Mon Sep 17 00:00:00 2001 From: vishmita Date: Tue, 3 Jan 2012 19:11:54 +0530 Subject: [PATCH 02/14] [FIX]icon page view. lp bug: https://launchpad.net/bugs/911147 fixed bzr revid: vja@vja-desktop-20120103134154-jkybx31hnijhuh12 --- addons/web/static/src/css/base.css | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/addons/web/static/src/css/base.css b/addons/web/static/src/css/base.css index 917001bb8ca..6dc7e5a51f0 100644 --- a/addons/web/static/src/css/base.css +++ b/addons/web/static/src/css/base.css @@ -1951,6 +1951,7 @@ ul.oe-arrow-list li.oe-arrow-list-selected .oe-arrow-list-after { background-position: 0px -21px; } + .openerp .oe_vm_switch_form { background-position: -22px 0px; } @@ -1961,6 +1962,15 @@ ul.oe-arrow-list li.oe-arrow-list-selected .oe-arrow-list-after { background-position: -22px -21px; } +.openerp .oe_vm_switch_page { + background-position: 0px 0px; +} +.openerp .oe_vm_switch_page:active, +.openerp .oe_vm_switch_page:hover, +.openerp .oe_vm_switch_page:focus, +.openerp .oe_vm_switch_page[disabled="disabled"] { + background-position: 0px -21px; +} .openerp .oe_vm_switch_graph { background-position: -44px 0px; } From 0fac5b69e6dbe098696b67f1a6dcf61fe0da9461 Mon Sep 17 00:00:00 2001 From: vishmita Date: Tue, 10 Jan 2012 19:08:04 +0530 Subject: [PATCH 03/14] [FIX]Improve code. bzr revid: vja@vja-desktop-20120110133804-d93dbcqr9tnak56i --- addons/web/static/src/css/base.css | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/addons/web/static/src/css/base.css b/addons/web/static/src/css/base.css index 6dc7e5a51f0..a6cdb510bf2 100644 --- a/addons/web/static/src/css/base.css +++ b/addons/web/static/src/css/base.css @@ -1916,6 +1916,7 @@ ul.oe-arrow-list li.oe-arrow-list-selected .oe-arrow-list-after { .openerp .oe_vm_switch_form, .openerp .oe_vm_switch_page, +.openerp .oe_vm_switch_tree, .openerp .oe_vm_switch_list, .openerp .oe_vm_switch_graph, .openerp .oe_vm_switch_gantt, @@ -1932,6 +1933,7 @@ ul.oe-arrow-list li.oe-arrow-list-selected .oe-arrow-list-after { .openerp .oe_vm_switch_form span, .openerp .oe_vm_switch_page span, +.openerp .oe_vm_switch_tree span, .openerp .oe_vm_switch_list span, .openerp .oe_vm_switch_graph span, .openerp .oe_vm_switch_gantt span, @@ -1951,6 +1953,15 @@ ul.oe-arrow-list li.oe-arrow-list-selected .oe-arrow-list-after { background-position: 0px -21px; } +.openerp .oe_vm_switch_tree { + background-position: 0px 0px; +} +.openerp .oe_vm_switch_tree:active, +.openerp .oe_vm_switch_tree:hover, +.openerp .oe_vm_switch_tree:focus, +.openerp .oe_vm_switch_tree[disabled="disabled"] { + background-position: 0px -21px; +} .openerp .oe_vm_switch_form { background-position: -22px 0px; @@ -1963,13 +1974,13 @@ ul.oe-arrow-list li.oe-arrow-list-selected .oe-arrow-list-after { } .openerp .oe_vm_switch_page { - background-position: 0px 0px; + background-position: -22px 0px; } .openerp .oe_vm_switch_page:active, .openerp .oe_vm_switch_page:hover, .openerp .oe_vm_switch_page:focus, .openerp .oe_vm_switch_page[disabled="disabled"] { - background-position: 0px -21px; + background-position: -22px -21px; } .openerp .oe_vm_switch_graph { background-position: -44px 0px; From 271337bce393d73dd841af141f214ebc382bf5fb Mon Sep 17 00:00:00 2001 From: Numerigraphe - Lionel Sausin Date: Tue, 10 Jan 2012 15:09:12 +0100 Subject: [PATCH 04/14] [IMP] account: fix help text on bank acounts in invoices bzr revid: ls@numerigraphe.fr-20120110140912-rifk0scy15v4rqhc --- addons/account/account_invoice.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/account/account_invoice.py b/addons/account/account_invoice.py index 9772984bc3b..166d146829b 100644 --- a/addons/account/account_invoice.py +++ b/addons/account/account_invoice.py @@ -259,7 +259,7 @@ class account_invoice(osv.osv): 'account.move.reconcile': (_get_invoice_from_reconcile, None, 50), }, help="It indicates that the invoice has been paid and the journal entry of the invoice has been reconciled with one or several journal entries of payment."), 'partner_bank_id': fields.many2one('res.partner.bank', 'Bank Account', - help='Bank Account Number, Company bank account if Invoice is customer or supplier refund, otherwise Partner bank account number.', readonly=True, states={'draft':[('readonly',False)]}), + help='Bank Account Number to which the invoice will be paid. A Company bank account if this is a Customer Invoice or Supplier Refund, otherwise a Partner bank account number.', readonly=True, states={'draft':[('readonly',False)]}), 'move_lines':fields.function(_get_lines, type='many2many', relation='account.move.line', string='Entry Lines'), 'residual': fields.function(_amount_residual, digits_compute=dp.get_precision('Account'), string='Balance', store={ From ee9a9558c0f7a0e290ebcdfb0ce0b9be9751daf8 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Tue, 10 Jan 2012 15:35:18 +0100 Subject: [PATCH 05/14] [IMP] add doc to Binary.saveas, and rename a field for clarity bzr revid: xmo@openerp.com-20120110143518-ircd8x1feyf5rquf --- addons/web/controllers/main.py | 24 +++++++++++++++++++----- addons/web/static/src/js/view_form.js | 2 +- addons/web/static/src/xml/base.xml | 2 +- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py index 852d5138177..7db8782b52e 100644 --- a/addons/web/controllers/main.py +++ b/addons/web/controllers/main.py @@ -1184,20 +1184,34 @@ class Binary(openerpweb.Controller): return open(os.path.join(addons_path, 'web', 'static', 'src', 'img', 'placeholder.png'), 'rb').read() @openerpweb.httprequest - def saveas(self, req, model, id, field, fieldname, **kw): + def saveas(self, req, model, field, id=None, filename_field=None, **kw): + """ Download link for files stored as binary fields. + + If the ``id`` parameter is omitted, fetches the default value for the + binary field (via ``default_get``), otherwise fetches the field for + that precise record. + + :param req: OpenERP request + :type req: :class:`web.common.http.HttpRequest` + :param str model: name of the model to fetch the binary from + :param str field: binary field + :param str id: id of the record from which to fetch the binary + :param str filename_field: field holding the file's name, if any + :returns: :class:`werkzeug.wrappers.Response` + """ Model = req.session.model(model) context = req.session.eval_context(req.context) if id: - res = Model.read([int(id)], [field, fieldname], context)[0] + res = Model.read([int(id)], [field, filename_field], context)[0] else: - res = Model.default_get([field, fieldname], context) + res = Model.default_get([field, filename_field], context) filecontent = base64.b64decode(res.get(field, '')) if not filecontent: return req.not_found() else: filename = '%s_%s' % (model.replace('.', '_'), id) - if fieldname: - filename = res.get(fieldname, '') or filename + if filename_field: + filename = res.get(filename_field, '') or filename return req.make_response(filecontent, [('Content-Type', 'application/octet-stream'), ('Content-Disposition', 'attachment; filename=' + filename)]) diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 4f08e909f3e..159fedbc71e 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -3023,7 +3023,7 @@ openerp.web.form.FieldBinary = openerp.web.form.Field.extend({ on_save_as: function() { var url = '/web/binary/saveas?session_id=' + this.session.session_id + '&model=' + this.view.dataset.model +'&id=' + (this.view.datarecord.id || '') + '&field=' + this.name + - '&fieldname=' + (this.node.attrs.filename || '') + '&t=' + (new Date().getTime()); + '&filename_field=' + (this.node.attrs.filename || '') + '&t=' + (new Date().getTime()); window.open(url); }, on_clear: function() { diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index d4bb5122500..642f1f89709 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -748,7 +748,7 @@
  • + + '&field=datas&filename_field=name&t=' + (new Date().getTime())"/> From 4cc9cb83cede980383709dfebe6ce48d436aaa7f Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Tue, 10 Jan 2012 15:35:56 +0100 Subject: [PATCH 06/14] [IMP] add bin_size flag to listview reads in order not to fetch binary file contents bzr revid: xmo@openerp.com-20120110143556-ijsmmhvenw93vzfb --- addons/web/static/src/js/view_list.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/web/static/src/js/view_list.js b/addons/web/static/src/js/view_list.js index 1c4911974fe..6b1621af74c 100644 --- a/addons/web/static/src/js/view_list.js +++ b/addons/web/static/src/js/view_list.js @@ -1289,7 +1289,7 @@ openerp.web.ListView.Groups = openerp.web.Class.extend( /** @lends openerp.web.L page = this.datagroup.openable ? this.page : view.page; var fields = _.pluck(_.select(this.columns, function(x) {return x.tag == "field"}), 'name'); - var options = { offset: page * limit, limit: limit }; + var options = { offset: page * limit, limit: limit, context: {bin_size: true} }; //TODO xmo: investigate why we need to put the setTimeout $.async_when().then(function() {dataset.read_slice(fields, options , function (records) { // FIXME: ignominious hacks, parents (aka form view) should not send two ListView#reload_content concurrently From 013794b978f8bf4a499f564412d19e59304108eb Mon Sep 17 00:00:00 2001 From: Vo Minh Thu Date: Tue, 10 Jan 2012 16:34:48 +0100 Subject: [PATCH 07/14] [IMP] orm: cosmetics (and the runbot will build this branch again). bzr revid: vmt@openerp.com-20120110153448-ot1vpcmwjbeykx9t --- openerp/osv/orm.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/openerp/osv/orm.py b/openerp/osv/orm.py index db5006cf71d..ac09c3179c7 100644 --- a/openerp/osv/orm.py +++ b/openerp/osv/orm.py @@ -3658,20 +3658,19 @@ class BaseModel(object): self.check_unlink(cr, uid) - properties = self.pool.get('ir.property') - ##search if there are properties created with resource that is about to be deleted - ## if found delete the properties too. - unlink_properties = properties.search(cr, uid, [('res_id', 'in', ['%s,%s' % (self._name, i) for i in ids])], context=context) - if unlink_properties: - properties.unlink(cr, uid, unlink_properties, context=context) + ir_property = self.pool.get('ir.property') - ## check if the model is used as a default property + # Check if the records are used as default properties. domain = [('res_id', '=', False), ('value_reference', 'in', ['%s,%s' % (self._name, i) for i in ids]), ] - if properties.search(cr, uid, domain, context=context): + if ir_property.search(cr, uid, domain, context=context): raise except_orm(_('Error'), _('Unable to delete this document because it is used as a default property')) + # Delete the records' properties. + property_ids = ir_property.search(cr, uid, [('res_id', 'in', ['%s,%s' % (self._name, i) for i in ids])], context=context) + ir_property.unlink(cr, uid, property_ids, context=context) + wf_service = netsvc.LocalService("workflow") for oid in ids: wf_service.trg_delete(uid, self._name, oid, cr) From d98b8b8be0145700667c0f4cc0e7619dec790c5b Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Tue, 10 Jan 2012 16:39:05 +0100 Subject: [PATCH 08/14] [ADD] handling of binary fields to the listview bzr revid: xmo@openerp.com-20120110153905-zxqkze9c4zrkmv2a --- addons/web/controllers/main.py | 7 ++-- addons/web/static/src/js/formats.js | 49 ++++++++++++++++++++------- addons/web/static/src/js/view_list.js | 20 +++++++++-- 3 files changed, 58 insertions(+), 18 deletions(-) diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py index 7db8782b52e..c775927a8cc 100644 --- a/addons/web/controllers/main.py +++ b/addons/web/controllers/main.py @@ -1201,10 +1201,13 @@ class Binary(openerpweb.Controller): """ Model = req.session.model(model) context = req.session.eval_context(req.context) + fields = [field] + if filename_field: + fields.append(filename_field) if id: - res = Model.read([int(id)], [field, filename_field], context)[0] + res = Model.read([int(id)], fields, context)[0] else: - res = Model.default_get([field, filename_field], context) + res = Model.default_get(fields, context) filecontent = base64.b64decode(res.get(field, '')) if not filecontent: return req.not_found() diff --git a/addons/web/static/src/js/formats.js b/addons/web/static/src/js/formats.js index 2418439ac46..4076c190a74 100644 --- a/addons/web/static/src/js/formats.js +++ b/addons/web/static/src/js/formats.js @@ -237,7 +237,15 @@ openerp.web.auto_date_to_str = function(value, type) { }; /** - * Formats a provided cell based on its field type + * Formats a provided cell based on its field type. Most of the field types + * return a correctly formatted value, but some tags and fields are + * special-cased in their handling: + * + * * buttons will return an actual ``