繁体   English   中英

如何在 Pos odoo 中加载 qty_avaiable

[英]How to load qty_avaiable in Pos odoo

在此处输入图片说明 我只想加载仅在 pos 的库存位置退出的数量。当我使用 qty_available 时,它​​会加载所有数量的产品。我该怎么做?

 var ks_models = require('point_of_sale.models'); var ks_screens = require('point_of_sale.screens'); var ks_utils = require('ks_pos_low_stock_alert.utils'); ks_models.load_fields('product.product', ['type', 'qty_available']);

如何仅针对特定位置的 qty_available 替换我的代码。我们可以在 js 文件中使用 self.env['product.product] 功能吗?

我建议不要加载product.product模型qty_available字段,而是加载带有inventory_quantity字段的模型stock.quant 请记住,基于产品配置Lot serial tracking, owner等,对于同一产品,可以有多个stock.quant 总数量将是这些行inventory_quantity值的总和。 您必须使用this.pos.config.location_id作为域来仅过滤 pos 库存位置的数量。 load功能上,您可以将该信息与加载的product.product模型数据进行映射。

// models: [{
//  model: [string] the name of the openerp model to load.
//  label: [string] The label displayed during load.
//  fields: [[string]|function] the list of fields to be loaded.
//          Empty Array / Null loads all fields.
//  order:  [[string]|function] the models will be ordered by
//          the provided fields
//  domain: [domain|function] the domain that determines what
//          models need to be loaded. Null loads everything
//  ids:    [[id]|function] the id list of the models that must
//          be loaded. Overrides domain.
//  context: [Dict|function] the openerp context for the model read
//  condition: [function] do not load the models if it evaluates to
//             false.
//  loaded: [function(self,model)] this function is called once the
//          models have been loaded, with the data as second argument
//          if the function returns a promise, the next model will
//          wait until it resolves before loading.
// }]

这是load_models函数文档。 domain必须由this.pos.config.location_id过滤,这是为 POS 选择的库存位置, loaded接收data结果,因此该库存位置的stock.quant记录,您可以遍历此记录并使用this.db.product_by_id[record.product_id]. available_qty=record.inventory_quantity存储available_qty this.db.product_by_id[record.product_id]. available_qty=record.inventory_quantity this.db.product_by_id[record.product_id]. available_qty=record.inventory_quantity

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM