-
-
Notifications
You must be signed in to change notification settings - Fork 729
[16.0][MIG] stock_valuation_fifo_lot: Migration to 16.0 #1676
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 16.0
Are you sure you want to change the base?
Conversation
a3ece53 to
3c26a62
Compare
|
Test failed from |
b60bb4e to
71c8a67
Compare
|
@matt454357 |
|
I started a review, and will post some suggestions. |
|
@matt454357 After you review and the PR is merged, you can create a new PR to follow up on your idea. What do you think? |
71c8a67 to
07a5f63
Compare
@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 |
|
The believe PR #1677 supports the idea of enforcing single lot/serial per SVL. |
matt454357
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm just commenting on this PR, not suggesting that we make these changes immediately.
stock_valuation_fifo_lot/tests/test_stock_valuation_fifo_lot.py
Outdated
Show resolved
Hide resolved
| "license": "AGPL-3", | ||
| "author": "Ecosoft, Odoo Community Association (OCA)", | ||
| "website": "https://github.com/OCA/stock-logistics-workflow", | ||
| "depends": ["stock_account", "stock_no_negative", "mrp_landed_costs"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure we should depend on mrp_landed_costs. Could that be handled in a separate module?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe move to a separate module?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. I will handle it.
| if not self.company_id.use_lot_get_price_unit_fifo: | ||
| return super()._get_price_unit() | ||
| if ( | ||
| not self.purchase_line_id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Depends on purchase module, which I guess is okay.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added hasattr(self, "purchase_line_id") in the conditon. So, there is no issue I guess.
| if ( | ||
| not self.purchase_line_id | ||
| and self.product_id.cost_method == "fifo" | ||
| and len(self.lot_ids) == 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we raise an error when len(self.lot_ids) > 1?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you have any concerns or inconveniences if we use Odoo's standard behavior for this case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we raise an error when
len(self.lot_ids) > 1?
I think we could make it configurable if the community requires it. I don't have a strong need for that at the moment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, single lot per SVL would not work when migrating/installing with existing data. So, I don't think we can do that.
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. |
07a5f63 to
2a2dfb9
Compare
|
@TheerayutEncoder |
@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. |
matt454357
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me
fbff13d to
a7a187c
Compare
| if ( | ||
| not self.purchase_line_id | ||
| and self.product_id.cost_method == "fifo" | ||
| and len(self.lot_ids) == 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we raise an error when
len(self.lot_ids) > 1?
I think we could make it configurable if the community requires it. I don't have a strong need for that at the moment.
|
/ocabot migration stock_valuation_fifo_lot |
|
We will also need odoo/odoo#179447, in order to do revaluation (later). |
6f75469 to
6d0c7c6
Compare
|
I squashed the commits. |
…ility - Adapt Odoo's standard method _get_fifo_candidates. - Improve _get_price_unit to retrieve the value from the most recent incoming move line for the lot in No PO stock moves (e.g., customer returns) and make the logic configurable to also support Odoo’s standard behavior. - Add test cases - Enhances stock_valuation_layer handling for deliveries when products were received before this module was installed. Previously, missing lot_ids in older valuation records led to incorrect valuations. This update ensures accurate cost calculations during deliveries. Related Link: OCA#1350 (comment) - Add lot_ids in search view - Avoid completely overriding _run_fifo and use the standard behavior. - Add quantity and value-related fields in stock_move_line to 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 serials 001, 002 and 003 for an incoming move. Deliver 002, return 002 and deliver > - Add force_fifo_lot_id in stock_move_line to handle cases where a delivery needs to be made for an existing lot created before the installation of this module (e.g., lots 001 and 002 were received, lot 002 was delivered before the module's installation, and lot 001 is delivered after the module is installed). - Add a post_init_hook to update the lot_ids in SVL for existing records and to update the field values in existing stock_move_line records. - Remove stock_no_negative from dependency and check negative inventory is created when SVL is created for delivery. - Remove updating standard price
… stock_valuation_fifo_lot_mrp_landed_cost
6d0c7c6 to
9d7ddec
Compare
yostashiro
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Used in production now.
kanda999
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I didn't review latest code. I couldn't approve this yet.
3824e2c to
3580456
Compare
kanda999
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Functional review
3580456 to
8988b91
Compare
yostashiro
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Partial review on the revaluation feature.
| all_candidates = self._sort_by_all_candidates(all_candidates, sort_by) | ||
| return all_candidates | ||
|
|
||
| # Depends on https://github.com/odoo/odoo/pull/180245 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's remove this comment.
stock_valuation_fifo_lot/wizard/stock_valuation_layer_revaluation.py
Outdated
Show resolved
Hide resolved
stock_valuation_fifo_lot/wizard/stock_valuation_layer_revaluation.py
Outdated
Show resolved
Hide resolved
stock_valuation_fifo_lot/wizard/stock_valuation_layer_revaluation.py
Outdated
Show resolved
Hide resolved
stock_valuation_fifo_lot/wizard/stock_valuation_layer_revaluation.py
Outdated
Show resolved
Hide resolved
stock_valuation_fifo_lot/wizard/stock_valuation_layer_revaluation.py
Outdated
Show resolved
Hide resolved
stock_valuation_fifo_lot/wizard/stock_valuation_layer_revaluation.py
Outdated
Show resolved
Hide resolved
stock_valuation_fifo_lot/wizard/stock_valuation_layer_revaluation.py
Outdated
Show resolved
Hide resolved
stock_valuation_fifo_lot/wizard/stock_valuation_layer_revaluation.py
Outdated
Show resolved
Hide resolved
stock_valuation_fifo_lot/wizard/stock_valuation_layer_revaluation.py
Outdated
Show resolved
Hide resolved
stock_valuation_fifo_lot/wizard/stock_valuation_layer_revaluation.py
Outdated
Show resolved
Hide resolved
stock_valuation_fifo_lot/wizard/stock_valuation_layer_revaluation.py
Outdated
Show resolved
Hide resolved
629e739 to
19bd99b
Compare
19bd99b to
2cc88f1
Compare
yostashiro
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The module now handles revaluation for specific lots.
25b2dd7 to
203e476
Compare
kanda999
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Functional review: it works as expected
Superseding of #1527
In this PR, I address the following points:
_run_fifo()and use the standard behavior._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.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.)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).post_init_hookto update thelot_idsin SVL for existing records and to update the field values in existing stock_move_line records.Depends on odoo/odoo#180245
@qrtl QT4650