Przeglądaj źródła

[FIX] tags color

deisy 6 lat temu
rodzic
commit
69c2dc800a
2 zmienionych plików z 45 dodań i 45 usunięć
  1. 44 45
      static/src/js/project_kanban.js
  2. 1 0
      views/activity.xml

+ 44 - 45
static/src/js/project_kanban.js

@@ -85,13 +85,7 @@ openerp.custom_project = function(instance) {
     }
   });
   instance.web_kanban.KanbanView.include({
-
-
-    // set_background: function() {
-    //   this.$el.find('.oe_kanban_groups_records').css('background', 'url("/custom_project/static/src/image/fondo7.jpeg")');
-    //   this.$el.find('.oe_kanban_groups_records').css('background-repeat', 'round');
-    // },
-    //
+    
     start: function() {
       var self = this;
 
@@ -101,46 +95,51 @@ openerp.custom_project = function(instance) {
       }
     },
 
-    postprocess_m2m_tags: function() {
-      var self = this;
-      if (!this.many2manys.length) {
-        return;
-      }
-      var relations = {};
-      this.groups.forEach(function(group) {
-        group.records.forEach(function(record) {
-          self.many2manys.forEach(function(name) {
-            var field = record.record[name];
-            var $el = record.$('.oe_form_field.oe_tags[name=' + name + ']').empty();
-            if (!relations[field.relation]) {
-              relations[field.relation] = {
-                ids: [],
-                elements: {},
-                context: self.m2m_context[name]
-              };
-            }
-            var rel = relations[field.relation];
-            field.raw_value.forEach(function(id) {
-              rel.ids.push(id);
-              if (!rel.elements[id]) {
-                rel.elements[id] = [];
-              }
-              rel.elements[id].push($el[0]);
+      postprocess_m2m_tags: function() {
+        var self = this;
+
+        if (self.dataset.model == 'project.task') {
+          if (!this.many2manys.length) {
+            return;
+          }
+          var relations = {};
+          this.groups.forEach(function(group) {
+            group.records.forEach(function(record) {
+              self.many2manys.forEach(function(name) {
+                var field = record.record[name];
+                var $el = record.$('.oe_form_field.oe_tags[name=' + name + ']').empty();
+                if (!relations[field.relation]) {
+                  relations[field.relation] = {
+                    ids: [],
+                    elements: {},
+                    context: self.m2m_context[name]
+                  };
+                }
+                var rel = relations[field.relation];
+                field.raw_value.forEach(function(id) {
+                  rel.ids.push(id);
+                  if (!rel.elements[id]) {
+                    rel.elements[id] = [];
+                  }
+                  rel.elements[id].push($el[0]);
+                });
+              });
             });
           });
-        });
-      });
-      _.each(relations, function(rel, rel_name) {
-        var dataset = new instance.web.DataSetSearch(self, rel_name, self.dataset.get_context(rel.context));
-        var defer = $.Deferred();
-        var f = new openerp.Model('project.category');
-        var fields = ['id', 'name', 'hex_value'];
-        f.query(fields).filter().all().then(function(results) {
-          _.each(results, function(item) {
-            $(rel.elements[item.id]).append('<span class="oe_tag" style="background:' + item.hex_value + '">' + _.str.escapeHTML(item.name) + '</span>');
+          _.each(relations, function(rel, rel_name) {
+            var dataset = new instance.web.DataSetSearch(self, rel_name, self.dataset.get_context(rel.context));
+            var defer = $.Deferred();
+            var f = new openerp.Model('project.category');
+            var fields = ['id', 'name', 'hex_value'];
+            f.query(fields).filter().all().then(function(results) {
+              _.each(results, function(item) {
+                $(rel.elements[item.id]).append('<span class="oe_tag" style="background:' + item.hex_value + '">' + _.str.escapeHTML(item.name) + '</span>');
+              });
+            });
           });
-        });
-      });
-    }
+        }else{
+            self._super.apply(self, arguments);
+        }
+      }
   });
 }

+ 1 - 0
views/activity.xml

@@ -76,6 +76,7 @@
         </tree>
       </field>
     </record>
+    
     <record id="activity_calendar" model="ir.actions.act_window">
       <field name="name">Actividades</field>
       <field name="res_model">project.task.activity</field>