[FIX] stock_account: negative quant cost
- Set up a product with 'Real Price' costing method, in real time valuation - Receive 1000 units at $0.10 each - Create a landed cost of $456.70, validate => it creates a quants of 999 units at cost $0.56 and 1 unit at cost $-2.74. - Perform an inventory adjustment, and set the quantity to 0 instead of 1000, post inventory. An error arises due to the constrain debit + credit >= 0. This is caused by the method `_prepare_account_move_line` from `stock.move`, which cannot handle negative cost for quants. opw-752063 Fixes #17707
This commit is contained in:
@@ -312,8 +312,8 @@ class StockMove(models.Model):
|
||||
'product_uom_id': self.product_id.uom_id.id,
|
||||
'ref': self.picking_id.name,
|
||||
'partner_id': partner_id,
|
||||
'debit': debit_value,
|
||||
'credit': 0,
|
||||
'debit': debit_value if debit_value > 0 else 0,
|
||||
'credit': -debit_value if debit_value < 0 else 0,
|
||||
'account_id': debit_account_id,
|
||||
}
|
||||
credit_line_vals = {
|
||||
@@ -323,8 +323,8 @@ class StockMove(models.Model):
|
||||
'product_uom_id': self.product_id.uom_id.id,
|
||||
'ref': self.picking_id.name,
|
||||
'partner_id': partner_id,
|
||||
'credit': credit_value,
|
||||
'debit': 0,
|
||||
'credit': credit_value if credit_value > 0 else 0,
|
||||
'debit': -credit_value if credit_value < 0 else 0,
|
||||
'account_id': credit_account_id,
|
||||
}
|
||||
res = [(0, 0, debit_line_vals), (0, 0, credit_line_vals)]
|
||||
|
||||
Reference in New Issue
Block a user