mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
fixup! fixup! 12.0 create module stock move location dest constraint base
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
# Copyright 2019 Camptocamp SA
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
|
||||
from odoo import models
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
|
||||
class PutAwayStrategy(models.Model):
|
||||
@@ -12,3 +13,24 @@ class PutAwayStrategy(models.Model):
|
||||
_filter_on_constraints=True, _constraint_product=product.id
|
||||
)
|
||||
return super()._get_putaway_rule(product)
|
||||
|
||||
|
||||
class FixedPutAwayStrategy(models.Model):
|
||||
|
||||
_inherit = 'stock.fixed.putaway.strat'
|
||||
|
||||
def filtered(self, func):
|
||||
"""Filter putaway strats according to installed constraints"""
|
||||
putaway_strats = super().filtered(func)
|
||||
if self.env.context.get('_filter_on_constraints'):
|
||||
product_id = self.env.context.get('_constraint_product')
|
||||
product = self.env['product.product'].browse(product_id)
|
||||
filtered_putaways = self.browse()
|
||||
for put in putaway_strats:
|
||||
try:
|
||||
put.location_id.check_move_dest_constraint(product=product)
|
||||
except ValidationError:
|
||||
continue
|
||||
filtered_putaways |= put
|
||||
putaway_strats = filtered_putaways
|
||||
return putaway_strats
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
# Copyright 2019 Camptocamp SA
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
|
||||
from odoo import api, models, fields
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
|
||||
class StockLocation(models.Model):
|
||||
@@ -20,19 +19,3 @@ class StockLocation(models.Model):
|
||||
"""Set bypass_constrains on all the existing locations"""
|
||||
existing_locations = self.search([])
|
||||
existing_locations.write({'bypass_constraints': True})
|
||||
|
||||
def filtered(self, func):
|
||||
"""Filter locations according to installed constraints"""
|
||||
locations = super().filtered(func)
|
||||
if self.env.context.get('_filter_on_constraints'):
|
||||
product_id = self.env.context.get('_constraint_product')
|
||||
product = self.env['product.product'].browse(product_id)
|
||||
new_locations = self.browse()
|
||||
for loc in locations:
|
||||
try:
|
||||
loc.check_move_dest_constraint(product=product)
|
||||
except ValidationError:
|
||||
continue
|
||||
new_locations |= loc
|
||||
locations = new_locations
|
||||
return locations
|
||||
|
||||
Reference in New Issue
Block a user