[MIG] stock_archive_constraint: Migration to 17.0

This commit is contained in:
Carlos Lopez
2024-07-30 13:41:19 -05:00
parent ad5eb1b5ec
commit 82dea8f734
8 changed files with 27 additions and 38 deletions

View File

@@ -42,7 +42,9 @@ Usage
1. Go to Settings > Users > Edit a user and check the "Manage Multiple
Stock Locations" permission
2. Go to Inventory > Settings > Locations and disable one
2. Go to Inventory > Settings > Locations and archive one
3. Go to inventory > Products > Products and try to archive one product
associated to stock picking
Bug Tracker
===========

View File

@@ -3,7 +3,7 @@
{
"name": "Stock archive constraint",
"version": "15.0.1.0.2",
"version": "17.0.1.0.0",
"license": "AGPL-3",
"website": "https://github.com/OCA/stock-logistics-warehouse",
"author": "Tecnativa, Odoo Community Association (OCA)",

View File

@@ -29,7 +29,8 @@ class ProductProduct(models.Model):
if res:
raise ValidationError(
_(
"It is not possible to archive product '%(display_name)s' which has "
"It is not possible to archive product "
"'%(display_name)s' which has "
"associated stock quantities."
)
% {"display_name": res.product_id.display_name}
@@ -49,7 +50,8 @@ class ProductProduct(models.Model):
if res:
raise ValidationError(
_(
"It is not possible to archive product '%(display_name)s' which has "
"It is not possible to archive product "
"'%(display_name)s' which has "
"associated picking lines."
)
% {"display_name": res.product_id.display_name}
@@ -69,7 +71,8 @@ class ProductProduct(models.Model):
if res:
raise ValidationError(
_(
"It is not possible to archive product '%(display_name)s' which has "
"It is not possible to archive product "
"'%(display_name)s' which has "
"associated stock reservations."
)
% {"display_name": res.product_id.display_name}

View File

@@ -1,12 +0,0 @@
# Copyright 2020 Tecnativa - Víctor Martínez
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import api, models
class ProductTemplate(models.Model):
_inherit = "product.template"
@api.constrains("active")
def _check_active_stock_archive_constraint(self):
self.product_variant_ids._check_active_stock_archive_constraint()

View File

@@ -31,7 +31,8 @@ class StockLocation(models.Model):
if res:
raise ValidationError(
_(
"It is not possible to archive location '%(display_name)s' which has "
"It is not possible to archive location "
"'%(display_name)s' which has "
"associated stock quantities."
)
% {"display_name": res.display_name}
@@ -54,7 +55,8 @@ class StockLocation(models.Model):
if res:
raise ValidationError(
_(
"It is not possible to archive location '%(display_name)s' which has "
"It is not possible to archive location "
"'%(display_name)s' which has "
"associated picking lines."
)
% {"display_name": res.display_name}
@@ -77,7 +79,8 @@ class StockLocation(models.Model):
if res:
raise ValidationError(
_(
"It is not possible to archive location '%(display_name)s' which has "
"It is not possible to archive location "
"'%(display_name)s' which has "
"associated stock reservations."
)
% {"display_name": res.display_name}

View File

@@ -1,3 +1,4 @@
1. Go to Settings \> Users \> Edit a user and check the "Manage
Multiple Stock Locations" permission
2. Go to Inventory \> Settings \> Locations and disable one
2. Go to Inventory \> Settings \> Locations and archive one
3. Go to inventory \> Products \> Products and try to archive one product associated to stock picking

View File

@@ -391,7 +391,9 @@ stock.quant or stock.move.</p>
<ol class="arabic simple">
<li>Go to Settings &gt; Users &gt; Edit a user and check the “Manage Multiple
Stock Locations” permission</li>
<li>Go to Inventory &gt; Settings &gt; Locations and disable one</li>
<li>Go to Inventory &gt; Settings &gt; Locations and archive one</li>
<li>Go to inventory &gt; Products &gt; Products and try to archive one product
associated to stock picking</li>
</ol>
</div>
<div class="section" id="bug-tracker">

View File

@@ -2,23 +2,15 @@
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from odoo.exceptions import ValidationError
from odoo.tests.common import Form, TransactionCase
from odoo.tests.common import Form
from odoo.addons.base.tests.common import BaseCommon
class TestLocationArchiveConstraint(TransactionCase):
class TestLocationArchiveConstraint(BaseCommon):
@classmethod
def setUpClass(cls):
super().setUpClass()
# Remove this variable in v16 and put instead:
# from odoo.addons.base.tests.common import DISABLED_MAIL_CONTEXT
DISABLED_MAIL_CONTEXT = {
"tracking_disable": True,
"mail_create_nolog": True,
"mail_create_nosubscribe": True,
"mail_notrack": True,
"no_reset_password": True,
}
cls.env = cls.env(context=dict(cls.env.context, **DISABLED_MAIL_CONTEXT))
cls.env = cls.env(
context=dict(cls.env.context, test_stock_archive_constraint=True)
)
@@ -58,7 +50,6 @@ class TestLocationArchiveConstraint(TransactionCase):
def _create_stock_move(self, location_id, location_dest_id, product_id, qty):
stock_move_form = Form(self.env["stock.move"])
stock_move_form.name = product_id.display_name
stock_move_form.location_id = location_id
stock_move_form.location_dest_id = location_dest_id
stock_move_form.product_id = product_id
@@ -73,9 +64,8 @@ class TestLocationArchiveConstraint(TransactionCase):
"location_id": location_id.id,
"location_dest_id": location_dest_id.id,
"product_id": product_id.id,
"product_uom_qty": qty,
"product_uom_id": product_id.uom_id.id,
"qty_done": qty,
"quantity": qty,
"state": "done",
}
)
@@ -92,7 +82,7 @@ class TestLocationArchiveConstraint(TransactionCase):
)
stock_picking.action_confirm()
for line in stock_picking.move_ids_without_package:
line.quantity_done = line.product_uom_qty
line.quantity = line.product_uom_qty
stock_picking.button_validate()
def test_archive_product_ok(self):