Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[18.0][MIG] stock_location_lockdown: Migration to 18.0. #2209

Open
wants to merge 43 commits into
base: 18.0
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
155aea6
Add module stock_location_lockdown for v9
florian-dacosta Sep 6, 2018
87fddd0
[MIG] stock_location_lockdown from v9 to v10
alexis-via Dec 5, 2018
776be31
[UPD] README.rst
OCA-git-bot Dec 10, 2018
704f8f2
[UPD] Update stock_location_lockdown.pot
oca-travis Dec 10, 2018
d7b1c96
Added translation using Weblate (Portuguese)
pedrocs-exo Dec 27, 2018
70691b7
[ADD] icon.png
OCA-git-bot Apr 3, 2019
566265a
[FIX] fix negative quant in blocked location
sebastienbeau Jul 5, 2019
4d67bdd
[UPD] Update stock_location_lockdown.pot
oca-travis Jul 8, 2019
1ee7186
stock_location_lockdown 10.0.1.1.0
OCA-git-bot Jul 8, 2019
8e5d3d4
Update translation files
oca-transbot Jul 20, 2019
8d9371b
[UPD] README.rst
OCA-git-bot Jul 29, 2019
fd1204d
[MIG] stock_location_lockdown : Migration to 12.0
clementmbr Sep 19, 2019
155e078
[UPD] Update stock_location_lockdown.pot
oca-travis Oct 1, 2019
0ba0485
[UPD] README.rst
OCA-git-bot Oct 1, 2019
9346cb9
Added translation using Weblate (Chinese (Simplified))
liweijie0812 Oct 16, 2019
f6113fe
Update translation files
oca-transbot Oct 16, 2019
f06b115
[IMP] stock_location_lockdown: improve error message
alexis-via Dec 4, 2020
082f38c
stock_location_lockdown 12.0.1.1.0
OCA-git-bot Dec 7, 2020
73e7cb7
[IMP] stock_location_lockdown: black, isort, prettier
florian-dacosta Dec 17, 2020
3d866f6
[MIG] stock_location_lockdown: Migration to 14.0
florian-dacosta Dec 17, 2020
5acfea6
[UPD] Update stock_location_lockdown.pot
oca-travis Feb 16, 2021
fc79f77
[UPD] README.rst
OCA-git-bot Feb 16, 2021
d7f2441
[15.0][MIG] stock_location_lockdown: Migration to 15.0
BT-dmontull Mar 4, 2022
c67b5c5
[UPD] Update stock_location_lockdown.pot
Mar 18, 2022
8b2db6d
[UPD] README.rst
OCA-git-bot Mar 18, 2022
ad95810
stock_location_lockdown 15.0.1.0.1
OCA-git-bot Mar 18, 2022
7e77e95
[IMP] stock_location_lockdown: pre-commit stuff
Urvisha-OSI Mar 23, 2023
b84c276
[MIG] stock_location_lockdown: Migration to 16.0
Urvisha-OSI Mar 23, 2023
7f864d6
[UPD] Update stock_location_lockdown.pot
Apr 28, 2023
c595186
[UPD] README.rst
OCA-git-bot Apr 28, 2023
945a423
Update translation files
weblate Apr 28, 2023
cdde824
Added translation using Weblate (Spanish)
Ivorra78 Jul 27, 2023
7468296
[UPD] README.rst
OCA-git-bot Sep 3, 2023
95ef114
Update translation files
weblate Oct 9, 2023
fe26801
Added translation using Weblate (Italian)
mymage Nov 17, 2023
d7b3688
[IMP] stock_location_lockdown: pre-commit auto fixes
celm1990 Feb 19, 2024
fde4a8d
[MIG] stock_location_lockdown: Migration to 17.0
celm1990 Feb 19, 2024
faf8fff
[UPD] Update stock_location_lockdown.pot
Jul 16, 2024
474d91b
[BOT] post-merge updates
OCA-git-bot Jul 16, 2024
3b28a5a
Update translation files
weblate Jul 16, 2024
fff1196
Translated using Weblate (Spanish)
florenciafrigieri2 Aug 22, 2024
e9b7a9b
[IMP] stock_location_lockdown: pre-commit execution
ced-adhoc Dec 2, 2024
7a6bdea
[18.0][MIG] stock_location_lockdown: Migration to 18.0
ced-adhoc Dec 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[FIX] fix negative quant in blocked location
When forcing an outgoing move and then moving it. Odoo create a
negative quant. This quant should not be in the locked location
because no quand will go in it and so the negative quant will stay
here for ever
sebastienbeau authored and ced-adhoc committed Dec 2, 2024
commit 566265a19d568d026b6a57cc5756ed486afb8f81
27 changes: 11 additions & 16 deletions stock_location_lockdown/models/stock_quant.py
Original file line number Diff line number Diff line change
@@ -3,24 +3,19 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import api, models, _
from odoo.exceptions import UserError
from odoo.exceptions import ValidationError


class StockQuant(models.Model):
_inherit = 'stock.quant'

@api.model
def quants_move(
self, quants, move, location_to, location_from=False, lot_id=False,
owner_id=False, src_package_id=False, dest_package_id=False,
entire_pack=False):
if (
location_to.usage == 'internal' and
location_to.block_stock_entrance):
raise UserError(_(
"The location '%s' is not configured to receive stock.")
% location_to.display_name)
return super(StockQuant, self).quants_move(
quants, move, location_to, location_from=location_from,
lot_id=lot_id, owner_id=owner_id, src_package_id=src_package_id,
dest_package_id=dest_package_id, entire_pack=entire_pack)
@api.constrains('location_id')
def _check_location_blocked(self):
for record in self:
if record.location_id.block_stock_entrance:
raise ValidationError(
_('The location %s is blocked and can '
'not be used for moving the product %s')
% (record.location_id.name, record.product_id.name)
)
return True
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
# Copyright 2018 Akretion France
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo.exceptions import UserError
from odoo.exceptions import ValidationError
from odoo.tests.common import TransactionCase


@@ -13,6 +13,7 @@ def setUp(self, *args, **kwargs):
self.main_stock_location = self.env.ref('stock.stock_location_stock')
self.main_stock_location.block_stock_entrance = True
self.supplier_location = self.env.ref('stock.stock_location_suppliers')
self.customer_location = self.env.ref('stock.stock_location_customers')
self.product = self.env.ref('product.product_product_27')

def test_transfer_stock_in_locked_location(self):
@@ -24,10 +25,27 @@ def test_transfer_stock_in_locked_location(self):
'location_id': self.supplier_location.id,
'location_dest_id': self.main_stock_location.id,
'product_id': self.product.id,
'product_uom_qty': '2.0',
'product_uom_qty': self.product.qty_available + 1,
'product_uom': 1,
'name': 'test',
}
stock_move = self.env['stock.move'].create(move_vals)
with self.assertRaises(UserError):
with self.assertRaises(ValidationError):
stock_move.action_done()

def test_transfer_stock_out_locked_location(self):
"""
Test to move stock within a location that should not accept
Stock entrance.
"""
move_vals = {
'location_id': self.main_stock_location.id,
'location_dest_id': self.customer_location.id,
'product_id': self.product.id,
'product_uom_qty': self.product.qty_available + 1,
'product_uom': 1,
'name': 'test',
}
stock_move = self.env['stock.move'].create(move_vals)
with self.assertRaises(ValidationError):
stock_move.action_done()