-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FIX] mrp_subcontracting_account: read price unit at validation
In a subcontracting flow, the extra_cost on the subcontracted production is read on the purchase line (via _get_price_unit() ) at the production creation. In case the price unit on this purchase line change before the validation, the stock valuation layer linked to the production will not take this new value into account. This commit ensures the price unit is the right one at validation Note: the first version of the current fix broke a use case. The test `test_tracked_compo_and_backorder` has been added to protect that use case. closes odoo#87792 Signed-off-by: William Henrotin (whe) <whe@odoo.com> Signed-off-by: Adrien Widart <awt@odoo.com> Co-authored-by: William Henrotin (whe) <whe@odoo.com> Co-authored-by: Adrien Widart <awt@odoo.com>
- Loading branch information
Showing
4 changed files
with
73 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
# -*- coding: utf-8 -*- | ||
# Part of Odoo. See LICENSE file for full copyright and licensing details. | ||
|
||
from . import mrp_production | ||
from . import stock_picking | ||
from . import product_product | ||
from . import stock_move |
16 changes: 16 additions & 0 deletions
16
addons/mrp_subcontracting_account/models/mrp_production.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# -*- coding: utf-8 -*- | ||
# Part of Odoo. See LICENSE file for full copyright and licensing details. | ||
|
||
from odoo import models | ||
|
||
|
||
class MrpProduction(models.Model): | ||
_inherit = 'mrp.production' | ||
|
||
def _cal_price(self, consumed_moves): | ||
finished_move = self.move_finished_ids.filtered(lambda x: x.product_id == self.product_id and x.state not in ('done', 'cancel') and x.quantity_done > 0) | ||
# Take the price unit of the reception move | ||
last_done_receipt = finished_move.move_dest_ids.filtered(lambda m: m.state == 'done')[-1:] | ||
if last_done_receipt.is_subcontract: | ||
self.extra_cost = last_done_receipt._get_price_unit() | ||
return super()._cal_price(consumed_moves=consumed_moves) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters