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 closes odoo/odoo#87726 Signed-off-by: Arnold Moyaux <arm@odoo.com>
20 lines
791 B
Python
20 lines
791 B
Python
# -*- coding: utf-8 -*-
|
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
|
|
from odoo import models
|
|
from odoo.osv.expression import OR
|
|
|
|
|
|
class StockPicking(models.Model):
|
|
_inherit = 'stock.picking'
|
|
|
|
def action_view_stock_valuation_layers(self):
|
|
action = super(StockPicking, self).action_view_stock_valuation_layers()
|
|
subcontracted_productions = self._get_subcontract_production()
|
|
if not subcontracted_productions:
|
|
return action
|
|
domain = action['domain']
|
|
domain_subcontracting = [('id', 'in', (subcontracted_productions.move_raw_ids | subcontracted_productions.move_finished_ids).stock_valuation_layer_ids.ids)]
|
|
domain = OR([domain, domain_subcontracting])
|
|
return dict(action, domain=domain)
|