含税价采购 ,加权平均成本计算错误解决方法
-
含税价采购 ,加权平均成本计算错误,经测试,加权时,将含税价当未税价进行了加权平均。
解决方法 /purchase/purchase.py 635 行,
def _prepare_order_line_move(self, cr, uid, order, order_line, picking_id, context=None):
代码
def _prepare_order_line_move(self, cr, uid, order, order_line, picking_id, context=None):
636 # 下面两行为新加取未税价
637 tax_obj = self.pool.get('account.tax')
638 taxes = tax_obj.compute_all(cr, uid, order_line.taxes_id, order_line.price_unit, 1, order_line.product_id, order_line.order_id.partner_id)
639 return {
640 'name': order_line.name or '',
641 'product_id': order_line.product_id.id,
642 'product_qty': order_line.product_qty,
643 'product_uos_qty': order_line.product_qty,
644 'product_uom': order_line.product_uom.id,
645 'product_uos': order_line.product_uom.id,
646 'date': self.date_to_datetime(cr, uid, order.date_order, context),
647 'date_expected': self.date_to_datetime(cr, uid, order.date_order, context),
648 'location_id': order.partner_id.property_stock_supplier.id,
649 'location_dest_id': order.location_id.id,
650 'picking_id': picking_id,
651 'partner_id': order.dest_address_id.id or order.partner_id.id,
652 'move_dest_id': order_line.move_dest_id.id,
653 'state': 'draft',
654 'type':'in',
655 'purchase_line_id': order_line.id,
656 'company_id': order.company_id.id,
657 'price_unit': taxes['total'] #取未税价
658 # 'price_unit': order_line.price_unit #原版本暂且保留
659 }
本处修改,只是解决了一次全部收货时正常,多次收货 没有解决,接下来,解决多次收货时异常
/purchase/stock.py 130 行
130 def _product_cost_for_average_update(self, cr, uid, move):
131 if move.picking_id.purchase_id:
132 # 以下两行为新加,取未税价
133 tax_obj = self.pool.get('account.tax')134 taxes = tax_obj.compute_all(cr, uid, move.purchase_line_id.taxes_id, move.purchase_line_id.price_unit, 1, move.purchase_line_id.product_id, move.purchase_line_id.o rder_id.partner_id)
135 # return {'cost': move.purchase_line_id.price_unit, #保留原样,留作比较
136 return {'cost': taxes['total'], #未税价
137 'currency': move.picking_id.purchase_id.pricelist_id.currency_id.id}
138 return super(stock_partial_picking, self)._product_cost_for_average_update(cr, uid, move)
139
经采购、收货测试,达到预期效果 。
对其他模块的影响未知。。。请大牛们 斧正,及同样关注该点朋友多交流!