gooderp_addons icon indicating copy to clipboard operation
gooderp_addons copied to clipboard

盘点单生成盘亏单据时计算成本bug

Open grey27 opened this issue 5 years ago • 0 comments

bug复现: A商品为常规不带批号商品 1.采购A商品100个 2.采购A商品20个 3.销售A商品80个 (按照先进先出原则,这80个来自于第一批采购入库) 3,盘点单盘点A产品 账面数量40 设置实际数量为10 (盘亏30个) 4.生成盘点数据报错 商品A的库存数量不够本次出库

bug原因: wh.inventory.line模型的get_move_line方法 这个方法用于返回其他出库单,并且计算了成本,但是成本计算使用goods模型的get_suggested_cost_by_warehouse方法,传参时,传入lot_id,导致写死为按批号商品计算成本导致计算不带批号的商品时成本计算报错

修复建议: 传参lot_id时加入对商品的判断

cost, cost_unit = inventory.goods_id. \
                get_suggested_cost_by_warehouse(
                    inventory.warehouse_id, abs(inventory.difference_qty),
<<<<<<< HEAD
                    lot_id=inventory.new_lot_id,
=======
                    lot_id=inventory.new_lot_id if inventory.goods_id.using_batch else None,
>>>>>>> fix
                    attribute=inventory.attribute_id)

grey27 avatar Sep 20 '19 08:09 grey27