简体   繁体   English

如何在 Pos odoo 中加载 qty_avaiable

[英]How to load qty_avaiable in Pos odoo

在此处输入图片说明 I want to load only quantity that exit in only pos's stock location.When I use qty_available, it load all quantity of product .How can I do that?我只想加载仅在 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']);

How can replace my code for only qty_available for specific location.Can we use self.env['product.product] feature in js file?如何仅针对特定位置的 qty_available 替换我的代码。我们可以在 js 文件中使用 self.env['product.product] 功能吗?

I would suggest to instead of loading product.product model qty_available field, you load model stock.quant with inventory_quantity field.我建议不要加载product.product模型qty_available字段,而是加载带有inventory_quantity字段的模型stock.quant Keep in mind that based on product configuration Lot serial tracking, owner etc, for same product there can be multiple stock.quant .请记住,基于产品配置Lot serial tracking, owner等,对于同一产品,可以有多个stock.quant Total quantity would be the sum of those lines inventory_quantity value.总数量将是这些行inventory_quantity值的总和。 You will have to use this.pos.config.location_id as domain to filter only quantity on the pos stock location.您必须使用this.pos.config.location_id作为域来仅过滤 pos 库存位置的数量。 On load function you can map that information with product.product model data loaded.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.
// }]

This is the load_models function documentation.这是load_models函数文档。 domain have to be filtered by this.pos.config.location_id which is the selected Stock location for the POS, loaded receives the data result so stock.quant records for that stock location, you can loop through this records and store available_qty using this.db.product_by_id[record.product_id]. available_qty=record.inventory_quantity 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 . 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