Files
odoo_source/addons/mrp_subcontracting/models/stock_move_line.py
T
JF Aubert ec4473a381 [IMP] mrp_subcontracting: allow multiple locations
Ease subcontractor stock tracking by using dedicated locations.
Simply declare location as a subcontracting one (rules are
automatically adapted) and set it on vendor.

closes odoo/odoo#88644

Task: 2720393
Related: odoo/upgrade#3755
Signed-off-by: Tiffany Chang <tic@odoo.com>
2022-08-12 17:05:36 +02:00

21 lines
892 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 current_location_id.is_subcontracting_location:
# 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