Browse Source

[ADD] Agregado imagenes en las variantes

Rodney Elpidio Enciso Arias 7 năm trước cách đây
mục cha
commit
dbb360c0b4
4 tập tin đã thay đổi với 15 bổ sung5 xóa
  1. BIN
      __init__.pyc
  2. 5 4
      static/src/css/ppt.css
  3. 9 1
      static/src/js/ppt.js
  4. 1 0
      static/src/xml/ppt.xml

BIN
__init__.pyc


+ 5 - 4
static/src/css/ppt.css

@@ -130,6 +130,7 @@
 
 /*  ********* Variant Display  ********************************************* */
 /* This part is a copy paste from Odoo Project, with some values changed     */
+
 .pos .variant {
     position:relative;
     vertical-align: top;
@@ -137,8 +138,8 @@
     line-height: 100px;
     font-size: 11px;
     margin: 5px !important;
-    width: 240px;
-    height:60px;
+    width: 200px;
+    height: 150px;
     background:#fff;
     border: 1px solid #e2e2e2;
     border-radius: 3px;
@@ -149,8 +150,8 @@
 
 .pos .variant .variant-header {
     position: relative;
-    width: 240px;
-    height: 30px;
+    width: 200px;
+    height: 50px;
     background: white;
     text-align: center;
 }

+ 9 - 1
static/src/js/ppt.js

@@ -143,6 +143,7 @@ Define : pos_product_template.SelectVariantPopupWidget
         show: function(product_tmpl_id){
             var self = this;
             var template = this.pos.db.template_by_id[product_tmpl_id];
+            // console.log(template);
 
             // Display Name of Template
             this.$('#variant-title-name').html(template.name);
@@ -236,11 +237,16 @@ Define: pos_product_template.VariantListWidget
             this.filter_variant_list = variant_list;
             this.renderElement();
         },
+        get_product_image_url: function(variant){
+            return window.location.origin + '/web/binary/image?model=product.product&field=image_medium&id='+variant.id;
+        },
 
         render_variant: function(variant){
+            var self = this;
             var variant_html = QWeb.render('VariantWidget', {
-                    widget:  this,
+                    widget:  self,
                     variant: variant,
+                    image_url: self.get_product_image_url(variant),
                 });
             var variant_node = document.createElement('div');
             variant_node.innerHTML = variant_html;
@@ -250,6 +256,7 @@ Define: pos_product_template.VariantListWidget
 
         renderElement: function() {
             var self = this;
+            // console.log(variant);
             var el_html  = openerp.qweb.render(this.template, {widget: this});
             var el_node = document.createElement('div');
             el_node.innerHTML = el_html;
@@ -369,6 +376,7 @@ Define: pos_product_template.AttributeListWidget
                 this.el.parentNode.replaceChild(el_node,this.el);
             }
             this.el = el_node;
+            // console.log(variant);
 
             var list_container = el_node.querySelector('.attribute-list');
             for(var i = 0, len = this.attribute_list.length; i < len; i++){

+ 1 - 0
static/src/xml/ppt.xml

@@ -117,6 +117,7 @@
     <t t-name="VariantWidget">
         <span class='variant' t-att-data-variant-id="variant.id">
             <div class="variant-header">
+                <img t-att-src='image_url' />
                 <t t-if="!variant.to_weight">
                     <span class="price-tag">
                         <t t-esc="widget.format_currency(variant.price,'Product Price')"/>