POS odoo 13 的产品屏幕上出现了产品变体

如何解决POS odoo 13 的产品屏幕上出现了产品变体

https://apps.odoo.com/apps/modules/12.0/pos_multi_variant/#loempia-comments

我已使用此应用程序在 pos 的弹出窗口上显示产品的变体

我不得不修改代码以使其工作,因为它的 odoo 12 并且我正在将它安装在 odoo13 上

发生的事情是主要产品出现在弹出窗口中,产品屏幕上排列着变体

有什么建议可以解决这个问题吗?

谢谢

静态 > js 文件

odoo.define('pos_multi_variant.ProductPopup',function (require)

{ "使用严格";

var PosBaseWidget = require('point_of_sale.BaseWidget');
var gui = require('point_of_sale.gui');
var models = require('point_of_sale.models');
var core = require('web.core');
var screens = require('point_of_sale.screens');
var PopupWidget = require('point_of_sale.popups');
var Widget = require("web.Widget");
var QWeb = core.qweb;
var rpc = require('web.rpc');
var _t  = require('web.core')._t;

models.load_models([
{   model: 'variants.tree',fields: ["pos_active","value","attribute","variants_id","extra_price"],loaded: function(self,variants_tree)
    {   self.variant_tree = variants_tree;
        _.each(variants_tree,function(item)
        {   self.item = item;
        });
    }
},{    model: 'product.attribute.value',fields: ["id","name"],values)
        {   self.values = values;
        }
  }]);

var super_models = models.PosModel.prototype.models;
models.load_fields('product.product','pos_variants');
models.load_fields('product.product','variant_line_ids');

var _super_orderline = models.Orderline.prototype;
models.Orderline = models.Orderline.extend
({   initialize: function(attr,options)
    {   _super_orderline.initialize.call(this,attr,options);
        this.product_variants = this.product_variants || [];
    },init_from_JSON: function(json)
    {   _super_orderline.init_from_JSON.apply(this,arguments);
        this.product_variants = json.product_variants || [];
    },export_as_JSON: function ()
    {   var json = _super_orderline.export_as_JSON.apply(this,arguments);
        json.product_variants = this.product_variants || [];
        return json;
    },});

var ProductPopUp = PopupWidget.extend
({  template: 'ProductPopUp',init: function(parent,options)
    {   this._super(parent,options);
        this.options = {};
        this.pos_reference = "";
    },show: function(options)
    {   this._super(options);
        this.render_list(options);
    },events:
    {   'click .button.cancel':  'click_cancel','click .button.confirm': 'click_confirm','click .product': 'click_variant',},click_variant:function(e)
    {   var order = this.self.pos.get('selectedOrder')
        var self = e.currentTarget
        var action = $(self).find('.action').text();
        var categories = []

        var category = $(self).find('.action').data('category');
        $('.product-img').find('.variant-selected').each(function ()
        {   if($(this).data('category') ==  category)
            {   $(this).text("").removeClass('variant-selected');
                $(self).find('.action').text("Selected").addClass('variant-selected');
            }
        });
        $(self).find('.action').text("Selected").addClass('variant-selected');
        var add = $(self).find('.extra-price').text().substr(1).slice(0,-2);
        var type = $(self).find('.variants').text();
        $(self).find('.variant-selected').attr('data-price',add);
        $(self).find('.variant-selected').attr('data-type',type);
    },render_list:function(options)
    {   this.list = options.list
        this.image_url = options.image_url
        this.pos_reference = options.data
        this.variant_values = options.values
        this.self = options.self
        var AddError = "variants are not added";
        var ActiveError = "No active variants "
        var NotActive = 0;
        var AttributeNumbers = []
        var pushed = []

        for (var i = 0; i < this.list.length; i++)
        {   if(this.list[i].pos_active == false)
            {   NotActive += 1
            }
            if(this.list.length == NotActive)
            {   $("#notify").append(ActiveError);
            }
            if(this.list[i].pos_active == true)
            {   if (!pushed.includes(this.list[i].attribute[0]))
                {   var temp = {};
                    temp.id = this.list[i].attribute[0];
                    temp.name = this.list[i].attribute[1]
                    pushed.push(this.list[i].attribute[0])
                    AttributeNumbers.push(temp)
                }
            }
        }
        var tag = "<div class='"+i+"'>";
        for ( var i in AttributeNumbers)
        {   tag += "<h2 class='tag'>"+AttributeNumbers[i].name+"</h2>";
            for (var attr = 0; attr < this.list.length; attr++)
            {   if (AttributeNumbers[i].id == this.list[attr].attribute[0])
                {   var values = this.list[attr].value.length
                    for(var j = 0; j < values; j++)
                    {   if(this.list[attr].extra_price)
                        {   var price = '+'+this.format_currency(this.list[attr].extra_price)}
                        else
                        {   var price = '+'+this.format_currency(0.00)}
                        for(var k=0; k < this.variant_values.length; k++)
                        {   if((this.variant_values[k].id == this.list[attr].value[j]) && this.list[attr].pos_active == true)
                            {   var rows ="<article class='product'>" +
                                "<div class='product-img'>"+
                                "<img src='"+this.image_url+"'/>" +
                                "<span class='extra-price'>"+price+"</span>"+
                                "<h2 class='action' data-price='' data-type='' data-category='"+AttributeNumbers[i].name+"'></h2>"+
                                "<span class='variants'>"+this.variant_values[k].name+"</span>"+
                                "</div>"+
                                "</article>"
                                tag += rows
                            }
                        }
                    }
                }
            }
        }
        tag += "</div>"
        $("#notify").append(tag);

        if(!(this.pos_reference.variant_line_ids.length>0))
        {   $("#notify").append(AddError);
        }
        },click_cancel: function()
    {   var order = this.self.pos.get('selectedOrder').selected_orderline.product_variants = []
        this.gui.close_popup();
    },click_confirm: function()
    {   var price = 0.00
        var order = this.self.pos.get('selectedOrder');
        var selected_orderline = order.selected_orderline
        $('.product-img').find('.variant-selected').each(function ()
        {   price += parseFloat($(this).data('price'))
            var variant = order.selected_orderline.product_variants
            variant.push
            ({  'extra_price': $(this).data('price'),'type': $(this).data('type'),})
        });
        selected_orderline.price_manually_set = true;
        selected_orderline.price += price
        selected_orderline.trigger('change',selected_orderline);
        this.gui.close_popup();
    }
});
gui.define_popup({name:'ProductSelection',widget: ProductPopUp});

screens.ProductScreenWidget.include
({  click_product: function(product)
    {   var image_url = this.get_product_image(product.id);
        var self = this;
        var variant_tree = this.pos.variant_tree
        var list = []
        var values = this.pos.values
        for(var i = 0; i < variant_tree.length; i++)
        {   if(variant_tree[i].variants_id[0] == product.product_tmpl_id)
            {   list.push(variant_tree[i]); }
        }
        if(product.to_weight && this.pos.config.iface_electronic_scale)
        {   this.gui.show_screen('scale',{product: product});}
        else if(product.pos_variants)
        {   this.pos.get_order().add_product(product);
            this.gui.show_popup('ProductSelection',{   'title': product.display_name,data: product,image_url: image_url,list: list,values: values,self: self
            });
        }
        else
        {   this.pos.get_order().add_product(product); }
    },get_product_image: function(product)
    {   return window.location.origin + '/web/image?model=product.product&field=image_medium&id='+product; }
});

});

这是静态的 > xml

<?xml version="1.0" encoding="UTF-8"?>
<t t-extend="Product" name="ProductStockWidget">
<t t-jquery="div.product-img" t-operation="replace">
    <div class="product-img">
            <img t-att-src='image_url' alt="Product image"/>

        <t t-if="!product.to_weight">

                <span class="price-tag">
                    <t t-esc="widget.format_currency(product.get_price(pricelist,1),'Product Price')"/>
                </span>
            <t t-if="product.pos_variants">
                    <span class="variant">Multi-variant</span>
                </t>
            </t>

        <t t-if="product.to_weight">

                <span class="price-tag">
                    <t t-esc="widget.format_currency(product.get_price(pricelist,'Product Price')"/>
                </span>
            <t t-if="product.pos_variants">
                    <span class="variant">Multi-variant</span>
                </t>
            </t>
        </div>
</t>
</t>
<t t-extend="Orderline">
    <t t-jquery="ul.info-list" t-operation="append">
        <div class="variant-orderline">
            <t t-foreach="line.product_variants" t-as="item">
                <li>
                    <em>
                    <t t-esc="item.type" />:
                    </em>
                    at
                    <t t-esc="widget.format_currency(item.extra_price)"/>
                </li>
            </t>

        </div>
    </t>
</t>
<t t-extend="PosTicket">
    <t t-jquery="tr[t-foreach*='orderlines'][t-as*='orderline']" t-operation="append">
        <tr t-foreach="orderline.product_variants" t-as="variant">
            <div>
                <td t-esc="variant.type" style="padding-left:15px;"/>
                <td style="text-align: left;" t-esc="widget.format_currency(variant.extra_price)"/>
            </div>
        </tr>
    </t>
</t>

这是静态的 > xml

<?xml version="1.0" encoding="UTF-8"?>
<t t-extend="Product" name="ProductStockWidget">
<t t-jquery="div.product-img" t-operation="replace">
    <div class="product-img">
            <img t-att-src='image_url' alt="Product image"/>

        <t t-if="!product.to_weight">

                <span class="price-tag">
                    <t t-esc="widget.format_currency(product.get_price(pricelist,'Product Price')"/>
                </span>
            <t t-if="product.pos_variants">
                    <span class="variant">Multi-variant</span>
                </t>
            </t>
        </div>
</t>
</t>
<t t-extend="Orderline">
    <t t-jquery="ul.info-list" t-operation="append">
        <div class="variant-orderline">
            <t t-foreach="line.product_variants" t-as="item">
                <li>
                    <em>
                    <t t-esc="item.type" />:
                    </em>
                    at
                    <t t-esc="widget.format_currency(item.extra_price)"/>
                </li>
            </t>

        </div>
    </t>
</t>
<t t-extend="PosTicket">
    <t t-jquery="tr[t-foreach*='orderlines'][t-as*='orderline']" t-operation="append">
        <tr t-foreach="orderline.product_variants" t-as="variant">
            <div>
                <td t-esc="variant.type" style="padding-left:15px;"/>
                <td style="text-align: left;" t-esc="widget.format_currency(variant.extra_price)"/>
            </div>
        </tr>
    </t>
</t>

视图> xml

<?xml version="1.0" encoding="UTF-8"?>
<t t-extend="Product" name="ProductStockWidget">
<t t-jquery="div.product-img" t-operation="replace">
    <div class="product-img">
            <img t-att-src='image_url' alt="Product image"/>

        <t t-if="!product.to_weight">

                <span class="price-tag">
                    <t t-esc="widget.format_currency(product.get_price(pricelist,'Product Price')"/>
                </span>
            <t t-if="product.pos_variants">
                    <span class="variant">Multi-variant</span>
                </t>
            </t>
        </div>
</t>
</t>
<t t-extend="Orderline">
    <t t-jquery="ul.info-list" t-operation="append">
        <div class="variant-orderline">
            <t t-foreach="line.product_variants" t-as="item">
                <li>
                    <em>
                    <t t-esc="item.type" />:
                    </em>
                    at
                    <t t-esc="widget.format_currency(item.extra_price)"/>
                </li>
            </t>

        </div>
    </t>
</t>
<t t-extend="PosTicket">
    <t t-jquery="tr[t-foreach*='orderlines'][t-as*='orderline']" t-operation="append">
        <tr t-foreach="orderline.product_variants" t-as="variant">
            <div>
                <td t-esc="variant.type" style="padding-left:15px;"/>
                <td style="text-align: left;" t-esc="widget.format_currency(variant.extra_price)"/>
            </div>
        </tr>
    </t>
</t>

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


使用本地python环境可以成功执行 import pandas as pd import matplotlib.pyplot as plt # 设置字体 plt.rcParams[&#39;font.sans-serif&#39;] = [&#39;SimHei&#39;] # 能正确显示负号 p
错误1:Request method ‘DELETE‘ not supported 错误还原:controller层有一个接口,访问该接口时报错:Request method ‘DELETE‘ not supported 错误原因:没有接收到前端传入的参数,修改为如下 参考 错误2:cannot r
错误1:启动docker镜像时报错:Error response from daemon: driver failed programming external connectivity on endpoint quirky_allen 解决方法:重启docker -&gt; systemctl r
错误1:private field ‘xxx‘ is never assigned 按Altʾnter快捷键,选择第2项 参考:https://blog.csdn.net/shi_hong_fei_hei/article/details/88814070 错误2:启动时报错,不能找到主启动类 #
报错如下,通过源不能下载,最后警告pip需升级版本 Requirement already satisfied: pip in c:\users\ychen\appdata\local\programs\python\python310\lib\site-packages (22.0.4) Coll
错误1:maven打包报错 错误还原:使用maven打包项目时报错如下 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources)
错误1:服务调用时报错 服务消费者模块assess通过openFeign调用服务提供者模块hires 如下为服务提供者模块hires的控制层接口 @RestController @RequestMapping(&quot;/hires&quot;) public class FeignControl
错误1:运行项目后报如下错误 解决方案 报错2:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project sb 解决方案:在pom.
参考 错误原因 过滤器或拦截器在生效时,redisTemplate还没有注入 解决方案:在注入容器时就生效 @Component //项目运行时就注入Spring容器 public class RedisBean { @Resource private RedisTemplate&lt;String
使用vite构建项目报错 C:\Users\ychen\work&gt;npm init @vitejs/app @vitejs/create-app is deprecated, use npm init vite instead C:\Users\ychen\AppData\Local\npm-
参考1 参考2 解决方案 # 点击安装源 协议选择 http:// 路径填写 mirrors.aliyun.com/centos/8.3.2011/BaseOS/x86_64/os URL类型 软件库URL 其他路径 # 版本 7 mirrors.aliyun.com/centos/7/os/x86
报错1 [root@slave1 data_mocker]# kafka-console-consumer.sh --bootstrap-server slave1:9092 --topic topic_db [2023-12-19 18:31:12,770] WARN [Consumer clie
错误1 # 重写数据 hive (edu)&gt; insert overwrite table dwd_trade_cart_add_inc &gt; select data.id, &gt; data.user_id, &gt; data.course_id, &gt; date_format(
错误1 hive (edu)&gt; insert into huanhuan values(1,&#39;haoge&#39;); Query ID = root_20240110071417_fe1517ad-3607-41f4-bdcf-d00b98ac443e Total jobs = 1
报错1:执行到如下就不执行了,没有显示Successfully registered new MBean. [root@slave1 bin]# /usr/local/software/flume-1.9.0/bin/flume-ng agent -n a1 -c /usr/local/softwa
虚拟及没有启动任何服务器查看jps会显示jps,如果没有显示任何东西 [root@slave2 ~]# jps 9647 Jps 解决方案 # 进入/tmp查看 [root@slave1 dfs]# cd /tmp [root@slave1 tmp]# ll 总用量 48 drwxr-xr-x. 2
报错1 hive&gt; show databases; OK Failed with exception java.io.IOException:java.lang.RuntimeException: Error in configuring object Time taken: 0.474 se
报错1 [root@localhost ~]# vim -bash: vim: 未找到命令 安装vim yum -y install vim* # 查看是否安装成功 [root@hadoop01 hadoop]# rpm -qa |grep vim vim-X11-7.4.629-8.el7_9.x
修改hadoop配置 vi /usr/local/software/hadoop-2.9.2/etc/hadoop/yarn-site.xml # 添加如下 &lt;configuration&gt; &lt;property&gt; &lt;name&gt;yarn.nodemanager.res