簡體   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