[16.0][MIG] stock_valuation_fifo_lot: Migration to 16.0
Superseding of https://github.com/OCA/stock-logistics-workflow/pull/1527
In this PR, I address the following points:
- Standard migration
- Improved code by using the Odoo standard function _get_fifo_candidates() and adjustments to _get_price_unit()
- Fixed the issue proposed in https://github.com/OCA/stock-logistics-workflow/pull/1350#issuecomment-1840407086
- Avoid completely overriding
_run_fifo()and use the standard behavior. - Update the product's standard price to the first available lot price.
- Improve
_get_price_unit()to retrieve the value from the most recent incoming move line for the lot for the No PO (e.g. customer returns) stock moves. - Add quantity and value-related fields in
stock_move_lineto cover all cases including multiple lots exist in an SVL record, and it is unclear which lot's remaining quantity is being delivered(Eg. Receive serials001,002and003for an incoming move. Deliver002, return002and deliver002again.) - Add
force_fifo_lot_idinstock_move_lineto handle cases where a delivery needs to be made for an existing lot created before the installation of this module (e.g., lots001and002were received, lot002was delivered before the module's installation, and lot001is delivered after the module is installed). - Add a
post_init_hookto update thelot_idsin SVL for existing records and to update the field values in existing stock_move_line records.
Depends on https://github.com/odoo/odoo/pull/180245 @qrtl QT4650
Test failed from stock_picking_line_sequence is fixed at https://github.com/OCA/stock-logistics-workflow/pull/1557.
@matt454357 Can you please review this PR and bring your ideas from your module https://github.com/OCA/stock-logistics-warehouse/pull/2139 as we talked?
I started a review, and will post some suggestions.
@matt454357 What I am thinking is that I will handle adding the option for a single lot/serial per SVL record or multiple lots/serials per SVL record in this PR (since some users may not need a single lot/serial per SVL).
After you review and the PR is merged, you can create a new PR to follow up on your idea. Or would you prefer to include your idea as a new commit in this PR by creating a PR in our repository?
What do you think?
I will handle adding the option for a single lot/serial per SVL record or multiple lots/serials per SVL record in this PR (since some users may not need a single lot/serial per SVL).
@matt454357 I will not add this enhancement in the current PR because it is not related to migration, and there is no use case with the current design. So, could you please handle this when you work on revaluation?
I think it's a good idea to finish this migration PR, and then do a follow up PR. And, I'm happy to do the follow up PR. However, there a couple of problems with allowing multiple lots/serials per SVL.
Maybe this initial migration should prevent revaluation of tracked products?
Maybe also raise an error when _get_price_unit() is called with multiple lot_ids?
The believe PR https://github.com/OCA/stock-logistics-workflow/pull/1677 supports the idea of enforcing single lot/serial per SVL.
I think it's a good idea to finish this migration PR, and then do a follow up PR. And, I'm happy to do the follow up PR. However, there a couple of problems with allowing multiple lots/serials per SVL.
Thanks for the pointer and your interest in following up. What do you think of my idea of adding an option to choose a single or multiple lot/serial per SVL? As I mentioned, I don't want to make this adjustment in the migration PR because it would make the module bigger, and the community might be less interested in reviewing it. So, my idea is to get this PR merged quickly and then follow up with the changes.
Yes, keep this PR small.
Regarding the option to choose between multiple or single lot per SVL: I'm not sure why someone would want multiple, but it sounds like you have a use case in mind. So, I suppose it's fine, as long as we raise errors for the issues described above.
@TheerayutEncoder
I have separated the module for passing lot_producing_id of mrp_production_ids to the SVL when adding the landed cost for these MOs, as you proposed in this commit.
What do you think about it?
Additionally, I am not entirely sure of the purpose of this, since the remaining_qty of the SVL for landed costs is 0.0, and I believe these SVLs will not be considered when _run_fifo() is called, if I understand correctly. Is this intended for user experience, to see the related lot_ids in the SVL? Could you please explain the initial purpose?
What do you think of my idea of adding an option to choose a single or multiple lot/serial per SVL?
@matt454357 Please let me handle this part and include it in this PR because we urgently need this module, and I don't know when this PR will be merged.
@AungKoKoLin1997 any contribution you make is very much appreciated, Do it the way you feel is best, and I will work with it.
/ocabot migration stock_valuation_fifo_lot
We will also need https://github.com/odoo/odoo/pull/179447, in order to do revaluation (later).
@AungKoKoLin1997 @yostashiro Is this PR dead? 🦴
@AungKoKoLin1997 @yostashiro Is this PR dead? 🦴
@ValentinVinagre It's alive and you are more than welcome to review it. 😁
@AungKoKoLin1997 @yostashiro Is this PR dead? 🦴
@ValentinVinagre It's alive and you are more than welcome to review it. 😁
Perfect, I'll sign up to review it 👍🏻 . I thought it was at a standstill, so I wanted to know the status.
I squashed the commits.