如何解决如何仅从 odoo13 中的 pos 源位置加载产品
我只想加载在 pos 的库存位置退出的产品。我尝试使用以下代码。但显示所有产品。我该怎么做?我尝试使用此模块 https://apps.odoo.com/apps/modules/13.0/pos_product_available/.But 该模块显示所有产品。我想要仅加载产品及其库存位置中的数量。
class PosConfig(models.Model):
_inherit = "pos.config"
show_qtys = fields.Boolean(
"Show Product Qtys",help="Show Product Qtys in POS",default=True
)
default_location_src_id = fields.Many2one(
"stock.location",related="picking_type_id.default_location_src_id"
)
我将这段代码添加到 js 文件中。
var rpc = require("web.rpc");
var models = require("point_of_sale.models");
var field_utils = require("web.field_utils");
models.load_fields("product.product",["qty_available","type"]);
var PosModelSuper = models.PosModel.prototype;
models.PosModel = models.PosModel.extend({
get_product_model: function() {
return _.find(this.models,function(model) {
return model.model === "product.product";
});
},initialize: function(session,attributes) {
// Compatibility with pos_cache module
// preserve product.product model data for future request
this.product_product_model = this.get_product_model(this.models);
PosModelSuper.initialize.apply(this,arguments);
},load_server_data: function() {
// Compatibility with pos_cache module
var self = this;
var loaded = PosModelSuper.load_server_data.call(this);
if (this.get_product_model(this.models)) {
return loaded;
}
// If product.product model is not presented in this.models after super was called then pos_cache module installed
return loaded.then(function() {
return rpc
.query({
model: "product.product",method: "search_read",args: [],fields: ["qty_available","type"],domain: self.product_product_model.domain,context: _.extend(self.product_product_model.context,{
location: self.config.default_location_src_id[0],}),})
.then(function(products) {
self.add_product_qty(products);
});
});
},
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。