[FIX] mrp: update stock move date on mark done production
Issue: ===== The stock move date is the scheduled date of the production and not the date the production is done. Steps to reproduce the issue: ============================= - Create a manufacturing order with any product (large desk) - Assign a date in the past for scheduled date (5 days before) - Confirm the order. - Added quantity produced and mark as done - Go to traceability , you will see the date here is the scheduled date and not the production date. - You can see also the inventory at date in inventory/reporting/locations will have the product they after the scheduled date. Solution: ========= Use the value of `date_finished` if it's set when calculating the `date` for `move_finished_ids` opw-3640708 closes odoo/odoo#154811 X-original-commit: ac94a429ed5ab0ffe7ac8fbc55243adaed3ce60f Signed-off-by: William Henrotin (whe) <whe@odoo.com> Signed-off-by: Mahdi Cheikh Rouhou (macr) <macr@odoo.com>
This commit is contained in:
@@ -7,6 +7,7 @@ from odoo.exceptions import UserError
|
||||
|
||||
from datetime import datetime
|
||||
import logging
|
||||
from freezegun import freeze_time
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -665,3 +666,19 @@ class TestTraceability(TestMrpCommon):
|
||||
# generate serial lot_3 from the MO (next from sequence)
|
||||
mo.action_generate_serial()
|
||||
self.assertIn(datetime.now().strftime('%j'), mo.lot_producing_id.name)
|
||||
|
||||
def test_assign_stock_move_date_on_mark_done(self):
|
||||
product_final = self.env['product.product'].create({
|
||||
'name': 'Finished Product',
|
||||
'type': 'product',
|
||||
})
|
||||
with freeze_time('2024-01-15'):
|
||||
production = self.env['mrp.production'].create({
|
||||
'product_id': product_final.id,
|
||||
'product_qty': 1,
|
||||
'date_start': datetime(2024, 1, 10)
|
||||
})
|
||||
production.action_confirm()
|
||||
production.qty_producing = 1
|
||||
production.button_mark_done()
|
||||
self.assertEqual(production.move_finished_ids.date, datetime(2024, 1, 15), "Stock move should be availbale after the production is done.")
|
||||
|
||||
Reference in New Issue
Block a user