[FIX] xmo@openerp.com-20120209090214-84d6jjr1jnf32kpi excluded too many fields
authorXavier Morel <xmo@openerp.com>
Thu, 16 Feb 2012 16:31:55 +0000 (17:31 +0100)
committerXavier Morel <xmo@openerp.com>
Thu, 16 Feb 2012 16:31:55 +0000 (17:31 +0100)
previous change would exclude all fields with @readonly, but @state can remove @readonly from fields and means fields are importable again (pretty much). Need to add that, otherwise it's almost impossible to import stuff

bzr revid: xmo@openerp.com-20120216163155-wh8uory00i2qifxy

addons/web/static/src/js/data_import.js

index 4bcdd4d..83eea2c 100644 (file)
@@ -109,9 +109,19 @@ openerp.web.DataImport = openerp.web.Dialog.extend({
         _(fields).each(function (field, field_name) {
             // Ignore spec for id field
             // Don't import function fields (function and related)
-            if (field_name === 'id' || field.readonly) {
+            if (field_name === 'id') {
                 return;
             }
+            // Skip if there's no state which could disable @readonly,
+            // if a field is ever always readonly we can't import it
+            if (field.readonly) {
+                // no states at all
+                if (_.isEmpty(field.states)) { return; }
+                // no state altering @readonly
+                if (!_.any(field.states, function (modifiers) {
+                    return _(modifiers).chain().pluck(0).contains('readonly').value();
+                })) { return; }
+            }
 
             var f = {
                 id: field_name,