[IMP] stock: disable scrap locations for manufacturing operation types
Task: 2799674 Community PR: https://github.com/odoo/odoo/pull/88801 Part-of: odoo/odoo#88801
This commit is contained in:
@@ -7,7 +7,7 @@ from collections import defaultdict, OrderedDict
|
||||
from datetime import timedelta
|
||||
|
||||
from odoo import _, api, fields, models
|
||||
from odoo.exceptions import UserError
|
||||
from odoo.exceptions import UserError, ValidationError
|
||||
from odoo.osv import expression
|
||||
from odoo.tools.float_utils import float_compare
|
||||
|
||||
@@ -167,6 +167,12 @@ class Location(models.Model):
|
||||
if self.usage not in ('internal', 'inventory'):
|
||||
self.scrap_location = False
|
||||
|
||||
@api.constrains('scrap_location')
|
||||
def _check_scrap_location(self):
|
||||
for record in self:
|
||||
if record.scrap_location and self.env['stock.picking.type'].search([('code', '=', 'mrp_operation'), ('default_location_dest_id', '=', record.id)]):
|
||||
raise ValidationError(_("You cannot set a location as a scrap location when it assigned as a destination location for a manufacturing type operation."))
|
||||
|
||||
def write(self, values):
|
||||
if 'company_id' in values:
|
||||
for location in self:
|
||||
|
||||
@@ -9,7 +9,7 @@ from collections import defaultdict
|
||||
|
||||
from odoo import SUPERUSER_ID, _, api, fields, models
|
||||
from odoo.addons.stock.models.stock_move import PROCUREMENT_PRIORITIES
|
||||
from odoo.exceptions import UserError
|
||||
from odoo.exceptions import UserError, ValidationError
|
||||
from odoo.osv import expression
|
||||
from odoo.tools import DEFAULT_SERVER_DATETIME_FORMAT, format_datetime, format_date, groupby
|
||||
from odoo.tools.float_utils import float_compare, float_is_zero, float_round
|
||||
@@ -204,6 +204,12 @@ class PickingType(models.Model):
|
||||
if self.show_operations and self.code != 'incoming':
|
||||
self.show_reserved = True
|
||||
|
||||
@api.constrains('default_location_dest_id')
|
||||
def _check_default_location(self):
|
||||
for record in self:
|
||||
if record.code == 'mrp_operation' and record.default_location_dest_id.scrap_location:
|
||||
raise ValidationError(_("You cannot set a scrap location as the destination location for a manufacturing type operation."))
|
||||
|
||||
def _get_action(self, action_xmlid):
|
||||
action = self.env["ir.actions.actions"]._for_xml_id(action_xmlid)
|
||||
if self:
|
||||
|
||||
Reference in New Issue
Block a user