forked from OCA/stock-logistics-warehouse
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IMP] stock_inventory_lockdown: black, isort
- Loading branch information
1 parent
e861f81
commit d922fc7
Showing
6 changed files
with
147 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,33 @@ | ||
# © 2016 Numérigraphe SARL | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from odoo import api, models, _ | ||
from odoo import _, api, models | ||
from odoo.exceptions import ValidationError | ||
|
||
|
||
class StockLocation(models.Model): | ||
"""Refuse changes during exhaustive Inventories""" | ||
_inherit = 'stock.location' | ||
_order = 'name' | ||
|
||
_inherit = "stock.location" | ||
_order = "name" | ||
|
||
@api.multi | ||
@api.constrains('location_id') | ||
@api.constrains("location_id") | ||
def _check_inventory_location_id(self): | ||
"""Error if an inventory is being conducted here""" | ||
vals = set(self.ids) | set(self.mapped('location_id').ids) | ||
location_inventory_open_ids = self.env['stock.inventory'].sudo().\ | ||
_get_locations_open_inventories(vals) | ||
vals = set(self.ids) | set(self.mapped("location_id").ids) | ||
location_inventory_open_ids = ( | ||
self.env["stock.inventory"].sudo()._get_locations_open_inventories(vals) | ||
) | ||
if location_inventory_open_ids: | ||
raise ValidationError( | ||
_('An inventory is being conducted at this location')) | ||
raise ValidationError(_("An inventory is being conducted at this location")) | ||
|
||
@api.multi | ||
def unlink(self): | ||
"""Refuse unlink if an inventory is being conducted""" | ||
location_inventory_open_ids = self.env['stock.inventory'].sudo().\ | ||
_get_locations_open_inventories(self.ids) | ||
location_inventory_open_ids = ( | ||
self.env["stock.inventory"].sudo()._get_locations_open_inventories(self.ids) | ||
) | ||
if location_inventory_open_ids: | ||
raise ValidationError( | ||
_('An inventory is being conducted at this location')) | ||
raise ValidationError(_("An inventory is being conducted at this location")) | ||
return super(StockLocation, self).unlink() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters