Skip to content

Commit c62dea6

Browse files
committed
[FIX] stock_account: Added default type for 'account.move' line.
This commit will fixed the error when product has some stock quants and product category with 'Automated' valuation method, is set to that product. ============================== Steps to product the above mentioned error: 1. Create product with any category which has 'Manual' valuation method. 2. Update 'On Hand' quantity for the same product. 3. Create product category with valuation method set to 'Automated'. 4. Now set the above product category to the same product which you created in step 1. 5. And Click on the save button. ============================== Also edit the test case. closes odoo#43721 Task: 2155804 Signed-off-by: Simon Lejeune (sle) <sle@openerp.com>
1 parent 8a34a6a commit c62dea6

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

addons/stock_account/models/product.py

+2
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,7 @@ def _svl_empty_stock_am(self, stock_valuation_layers):
470470
'credit': abs(value),
471471
'product_id': product.id,
472472
})],
473+
'type': 'entry',
473474
}
474475
move_vals_list.append(move_vals)
475476
return move_vals_list
@@ -505,6 +506,7 @@ def _svl_replenish_stock_am(self, stock_valuation_layers):
505506
'credit': abs(value),
506507
'product_id': product.id,
507508
})],
509+
'type': 'entry',
508510
}
509511
move_vals_list.append(move_vals)
510512
return move_vals_list

addons/stock_account/tests/test_stockvaluationlayer.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -779,7 +779,10 @@ def test_standard_manual_to_auto_2(self):
779779
'property_stock_journal': self.stock_journal.id,
780780
})
781781

782-
self.product1.categ_id = cat2
782+
# Try to change the product category with a `default_type` key in the context and
783+
# check it doesn't break the account move generation.
784+
self.product1.with_context(default_type='product').categ_id = cat2
785+
self.assertEqual(self.product1.categ_id, cat2)
783786

784787
self.assertEqual(self.product1.value_svl, 100)
785788
self.assertEqual(self.product1.quantity_svl, 10)

0 commit comments

Comments
 (0)