Previous task: odoo/odoo#61287 improved warnings for when using a duplicate SN, including an auto-update of the source location when appropriate. Unfortunately the auto-update is too risky when registering a subcontracting SN tracked components. Instead, we no longer update the source location when in a subcontracting situation and update the warning message to match the expected flow to fix the issue. closes odoo/odoo#79334 Task: 2669180 X-original-commit: a430c4d7d6e2a02ef9b3905b554a779fc1643bcf Signed-off-by: Arnold Moyaux <arm@odoo.com> Signed-off-by: Tiffany Chang <tic@odoo.com>
21 lines
911 B
Python
21 lines
911 B
Python
# -*- coding: utf-8 -*-
|
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
|
|
|
|
from odoo import _, api, models
|
|
|
|
|
|
class StockMoveLine(models.Model):
|
|
_inherit = 'stock.move.line'
|
|
|
|
@api.onchange('lot_name', 'lot_id')
|
|
def _onchange_serial_number(self):
|
|
current_location_id = self.location_id
|
|
res = super()._onchange_serial_number()
|
|
if res and not self.lot_name and self.company_id.subcontracting_location_id == current_location_id:
|
|
# we want to avoid auto-updating source location in this case + change the warning message
|
|
self.location_id = current_location_id
|
|
res['warning']['message'] = res['warning']['message'].split("\n\n", 1)[0] + "\n\n" + \
|
|
_("Make sure you validate or adapt the related resupply picking to your subcontractor in order to avoid inconsistencies in your stock.")
|
|
return res
|