Merge lp:~openerp-dev/openerp-web/6.1-opw-576425-bth into lp:openerp-web/6.1

Proposed by Bhumi Thakkar (Open ERP)
Status: Needs review
Proposed branch: lp:~openerp-dev/openerp-web/6.1-opw-576425-bth
Merge into: lp:openerp-web/6.1
Diff against target: 76 lines (+20/-4)
2 files modified
addons/web/controllers/main.py (+14/-4)
addons/web/static/src/js/view_form.js (+6/-0)
To merge this branch: bzr merge lp:~openerp-dev/openerp-web/6.1-opw-576425-bth
Reviewer Review Type Date Requested Status
Mohammed Shekha(Open ERP) (community) Needs Resubmitting
Juan Alonso (community) Needs Fixing
Bhumi Thakkar (Open ERP) (community) Needs Resubmitting
Jiten (OpenERP) (community) Needs Fixing
OpenERP Core Team Pending
Review via email: mp+114614@code.launchpad.net

Description of the change

Hello,

   error when click on Save As button in attachments form when sending email.

1. Setting => Configuration => Email. Open or create any record.
2. Open Attachment tab. Click on Add Button => Create new attachment.
3. Select any file and then click on Save As button.

Observed: Error is coming "ValueError: No content found for field 'datas' on 'ir.attachment:'".
Expected: Download selected file

file content and file name both arguments are passed from js with 'saveas_ajax' method and parsing json data in saveas_ajax method. If attachment is exist in model then download from that if not then download selected file. After click on clear button download selected file if not selected then open attachment is downloaded.

Thanks.

To post a comment you must log in.
2401. By Xavier (Open ERP)

[FIX] m2o-in-list-o2m focus issues introduced in o2m-autosave

issue revid: <email address hidden>

2402. By Xavier (Open ERP)

[IMP] missing translation marks in form and view editor

2403. By Xavier (Open ERP)

[FIX] dynamic addition of options in select in IE8, for export screen

2404. By Xavier (Open ERP)

[MERGE] manual reimplementation of progress bar for better cross-platform consistency and usability

html5 progress bar can not show progress in letters, so much less precision

2405. By Xavier (Open ERP)

[IMP] automatically close m2o autocomplete list inside dialog if dialog is dragged or resized

avoids autocomplete list being out of sync (positionally) with related m2o dialog

2406. By Xavier (Open ERP)

[TRANSLATIONS] new extraction after addition of new translation marks

2407. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

2408. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

2409. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

2410. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

2411. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

2412. By Xavier (Open ERP)

[FIX] handling of focus/blur in date fields in relation to o2m autosave

2413. By Xavier (Open ERP)

[FIX] Ensure static file URLs are actually URLs, not windows file paths

2414. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

2415. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

2416. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

2417. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

2418. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

2419. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

2420. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

2421. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

2422. By Xavier (Open ERP)

[FIX] OPW 575691: parse server datetime manually

datejs's parser completely fails over itself during CST/EST transition

2423. By Xavier (Open ERP)

[FIX] correctly pass context to import_data so e.g. defaults from the action can reach write/update

2424. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

2425. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

2426. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

2427. By Xavier (Open ERP)

[FIX] inability to select an autocompletion via mouse in an m2o in an editable o2m list

Problem due to over-eager form autosave.

Pretty straight backport of
revid:<email address hidden>

2428. By Olivier Dony (Odoo)

[MERGE] OPW 577592: form view - properly flag m2o fields as dirty when removing the value

2429. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

2430. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

2431. By Xavier (Open ERP)

[FIX] Correctly add new kanban records (from unfolding column) to dataset so they can be edited in form view

2432. By Xavier (Open ERP)

[FIX] make attachment deletion tooltip translatable

attachment_title can't be a method on SidebarAttachment because it doesn't correctly go through qweb context overloads/copies

2433. By Xavier (Open ERP)

[IMP] avoid potential error when specifying duplicated fields in read

Can't reproduce on my browser/machine, may be config-specific, but doesn't really hurt either way

2434. By Xavier (Open ERP)

[FIX] call update_dom on all form fields on save, even when they are valid (to clear out previously set invalid flag)

2435. By Xavier (Open ERP)

[FIX] list-sorting arrow not displayed and incorrectly positioned in Firefox, Opera

2436. By Xavier (Open ERP)

[FIX] don't store current context lang in action when creating ir.ui.view.custom for custom dashboards

2437. By Xavier (Open ERP)

[IMP] reload calendar event after save failure

2438. By Xavier (Open ERP)

[FIX] correctly show import errors from detect_data

wrong class was removed from wrong element

2439. By Xavier (Open ERP)

[FIX] MSIE8 errors out when trying to delete a property on the window host object, so set jsonp callback to null instead

2440. By Xavier (Open ERP)

[FIX] red background not appearing on save button of dirty form in MSIE

also, fix nonsensical -box-shadow property

2441. By Xavier (Open ERP)

[FIX] don't lose request_context argument in One2ManyDataSet#get_context

2442. By Xavier (Open ERP)

[FIX] generate noop stubs for all console methods in case of IE8

2443. By Xavier (Open ERP)

[FIX] restrict set_default values to the current user's company, courtesy of Guewen Baconnier

2444. By Xavier (Open ERP)

[FIX] have translatable url fields work correctly, courtesy of Guewen Baconnier

2445. By Xavier (Open ERP)

[FIX] don't display empty (false) fields literally in calendar event info

2446. By Xavier (Open ERP)

[IMP] re-export translation templates

2447. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

2448. By Xavier (Open ERP)

[FIX] OPW 578531 Correctly invalidate BufferedDatasetCache when triggering an action @type=action ~/projects/tiny/web/current

otherwise when reloaded the record gets re-fetched from the cache, so
any modification from the action remains invisible until the parent
record itself is reloaded

2449. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

2450. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

2451. By Xavier (Open ERP)

[FIX] o2m breakage introduced in <email address hidden>

BufferedDataSet#read_ids expect coherent between #cache and
#to_create, patch removed a record from #cache which was in #to_create
leading to not being able to create new records in editable o2ms:

* The record would be inserted in #cache and #to_create
* The listview would reload the record
  - Evicting the record from #cache
  - And re-reading the record
  - Leading to breakage

Don't evict records locally edited from the cache, the server probably
doesn't know about it (at all) or we can assume the server's outdated,
so the local version remains the "correct" one and there's nothing
more recent to fetch.

2452. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

2453. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

2454. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

2455. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

2456. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

2457. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

2458. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

2459. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

2460. By Olivier Dony (Odoo)

[FIX] OPW 577261, 573269: properly refresh one2many records after clicking on a form button

This patch reverts the previous patch for OPW 573269
that did not properly fix all cases (workflow buttons
for instance). This is a backport of the trunk fix.

previous fix: rev-id: <email address hidden>
trunk fix: r.3104 rev-id: <email address hidden>

Revision history for this message
Jiten (OpenERP) (jiten-openerp) wrote :

Hello,

I have tested as your description and found that, Issue is solved when we select any file and than click on button 'Save As'. BUT if we does not select any file for attachment and than click on button 'Save As' then its arise same error which you described.

So, i think still it's need to improve code.

Thanks.

review: Needs Fixing
Revision history for this message
Bhumi Thakkar (Open ERP) (bth-openerp) wrote :

Hello,

    Disabled save as button and clear button until file is not selected.

Thanks.

review: Needs Resubmitting
2461. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

2462. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

2463. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

2464. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

2465. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

2466. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

2467. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

2468. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

2469. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

2470. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

2471. By Xavier ALT

[MERGE] OPW 579322: form: after field value change, force update of field's error status if field is currently marked as invalid

2472. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

2473. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

2474. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

2475. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

2476. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

2477. By Xavier (Open ERP)

[FIX] avoid overwriting sensible error message with garbage when reading or decoding the CSV file fails

also improve error message in case of decoding error (turns out UnicodeDecodeError has everything you need to know exactly what blew up, who knew?)

2478. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

2479. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

2480. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

2481. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

2482. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

2483. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

2484. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

2485. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

2486. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

2487. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

2488. By Xavier ALT

[MERGE] OPW 579391: graph view: x-axis should respect order of selection field values

2489. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

2490. By Xavier ALT

[MERGE] OPW 579638: translation box have to save value of current language.

  when changing English translation of a record created in another language
  (i.e. having no distinct ir.translation value) we force saving all other
  languages too, this to avoid loosing creation translation. (btw, this make
  the behaviour consistent with GTK client).

2491. By Xavier ALT

[MERGE] OPW 579519: many2one button should not trigger 'blur' if contenual menu is open

  if many2one contexual menu is visible, make sure we won't trigger 'blur' from
  context button otherwise in editable list, row edition will be cancelled

2492. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

2493. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

2494. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

2495. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

2496. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

2497. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

2498. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

2499. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

Revision history for this message
Juan Alonso (juan-jalogut) wrote :

I've tested the patch and it looks very good, but still having a bug:

    - When you upload a file on a binary field everything works properly, "save as" button is enabled and downloading files works like a dream. The problem comes when you open the form view of any record with binary fields already uploaded, in this case "save as" buttons are always disabled, thus you cannot download the files. So, It's like the "save as" button is only getting enabled when you select a new file, but later, when you open any form view these buttons are disabled even if there files uploaded in them.

Could you check it out?

review: Needs Fixing
2500. By Mohammed Shekha(Open ERP)

[FIX]Refixed the issue of BinaryWidget buttons, buttons should be disable if there is no value in binary field otherwise it should be enable.

Revision history for this message
Mohammed Shekha(Open ERP) (msh-openerp) wrote :

Hello Bhumi,

I have tested the scenario given in comment Juan and found that this fix breaks the feature of Save As and clear, Other logic is OK but the issue is with disabling buttons, as you have disabled buttons in start method of FieldBinary so if you go with existing record which has already binary data then also these buttons comes disable, here I have changed the code which will fix this.

Changed the code and disabled the buttons based on binary field value not based on file selection.

Thanks.

review: Needs Resubmitting

Unmerged revisions

2500. By Mohammed Shekha(Open ERP)

[FIX]Refixed the issue of BinaryWidget buttons, buttons should be disable if there is no value in binary field otherwise it should be enable.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'addons/web/controllers/main.py'
2--- addons/web/controllers/main.py 2012-11-04 19:25:08 +0000
3+++ addons/web/controllers/main.py 2012-12-20 11:42:21 +0000
4@@ -1449,6 +1449,8 @@
5 jdata = simplejson.loads(data)
6 model = jdata['model']
7 field = jdata['field']
8+ content = jdata.get('filecontent', None)
9+ fname = jdata.get('filename', None)
10 id = jdata.get('id', None)
11 filename_field = jdata.get('filename_field', None)
12 context = jdata.get('context', dict())
13@@ -1456,20 +1458,28 @@
14 context = req.session.eval_context(context)
15 Model = req.session.model(model)
16 fields = [field]
17+
18 if filename_field:
19 fields.append(filename_field)
20 if id:
21 res = Model.read([int(id)], fields, context)[0]
22 else:
23 res = Model.default_get(fields, context)
24- filecontent = base64.b64decode(res.get(field, ''))
25+ if content:
26+ filecontent = base64.b64decode(content)
27+ else:
28+ filecontent = base64.b64decode(res.get(field, ''))
29+ if fname:
30+ filename = fname
31+ else:
32+ filename = '%s_%s' % (model.replace('.', '_'), id)
33+ if filename_field:
34+ filename = res.get(filename_field, '') or filename
35+
36 if not filecontent:
37 raise ValueError("No content found for field '%s' on '%s:%s'" %
38 (field, model, id))
39 else:
40- filename = '%s_%s' % (model.replace('.', '_'), id)
41- if filename_field:
42- filename = res.get(filename_field, '') or filename
43 return req.make_response(filecontent,
44 headers=[('Content-Type', 'application/octet-stream'),
45 ('Content-Disposition', self.content_disposition(filename, req))],
46
47=== modified file 'addons/web/static/src/js/view_form.js'
48--- addons/web/static/src/js/view_form.js 2012-12-04 11:02:12 +0000
49+++ addons/web/static/src/js/view_form.js 2012-12-20 11:42:21 +0000
50@@ -3517,6 +3517,8 @@
51 id: (this.view.datarecord.id || ''),
52 field: this.name,
53 filename_field: (this.node.attrs.filename || ''),
54+ filecontent: this.filecontent || '',
55+ filename: this.filename || '',
56 context: this.view.dataset.get_context()
57 })},
58 complete: $.unblockUI,
59@@ -3544,6 +3546,8 @@
60 template: 'FieldBinaryFile',
61 update_dom: function() {
62 this._super.apply(this, arguments);
63+ var disabled = this.value ? false : true;
64+ this.$element.find('button.oe-binary-file-save, .oe-binary-file-clear').prop('disabled', disabled);
65 this.$element.find('.oe-binary-file-set, .oe-binary-file-clear').toggle(!this.readonly);
66 this.$element.find('input[type=text]').prop('readonly', this.readonly);
67 },
68@@ -3559,6 +3563,8 @@
69 },
70 on_file_uploaded_and_valid: function(size, name, content_type, file_base64) {
71 this.value = file_base64;
72+ this.filecontent = file_base64;
73+ this.filename = name;
74 this.binary_value = true;
75 var show_value = name + " (" + this.human_filesize(size) + ")";
76 this.$element.find('input').eq(0).val(show_value);