【发布时间】:2019-08-17 16:49:27
【问题描述】:
我正在使用 odoo11(python3) 并 开发自定义模块。
我想获取单个库存公司的产品数量(手动或预测)。
我只需选择任何单个仓库并显示该仓库的产品数量。 其实我的目标是两件事 1.产品总可用数量 2.产品可用数量基于位置 这是我的代码
class Threshold(models.Model):
_name="threshold.threshold"
main_location=fields.Many2many("stock.warehouse", string="Main Location")
product=fields.Many2many("product.template", string="Product")
category=fields.Many2one("product.category", string="Category")
attribute=fields.Many2many("product.attribute", string="Attribute")
threshold_value=fields.Integer(string="Threshold Value")
transfer_quantity=fields.Integer(string="Transfer Quantity")
status_button=fields.Selection([('0','Active'),('1','Dissmiss')], default='0', index=True, string="Status")
threshold_selection=fields.Selection([('0','Product'),('1','Category'),], default= '0', index=True, string="Threshold Selection")
product_quantity=fields.Integer(compute="_product_based_on_warehouse", store=True)
@api.depends('main_location','product_quantity')
def _product_based_on_warehouse(self):
count_products = 0
self.env['product.template'].with_context(warehouse=self.main_location).search([], limit=1)
self.product_quantity=products print(f'Product Quantity: {self.product_quantity}')
【问题讨论】:
标签: python python-3.x odoo odoo-11