Skip to content

Commit 4c067fe

Browse files
committed
stock_usability: mig method auto unpack on internal locations from v10
1 parent 88452b7 commit 4c067fe

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

stock_usability/models/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from . import stock_location_route
66
from . import stock_warehouse_orderpoint
77
from . import stock_quant
8+
from . import stock_quant_package
89
from . import stock_inventory
910
from . import procurement_group
1011
from . import procurement_scheduler_log
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Copyright 2024 Akretion France (https://www.akretion.com/)
2+
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
3+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
4+
5+
from odoo import api, models
6+
import logging
7+
8+
logger = logging.getLogger(__name__)
9+
10+
11+
class StockQuantPackage(models.Model):
12+
_inherit = "stock.quant.package"
13+
14+
@api.model
15+
def _cron_auto_unpack_on_internal_locations(self):
16+
# Problem in v10: when you manage packs in Odoo for customer pickings,
17+
# you have the following problem: when you return a customer picking,
18+
# if you return all the products that were in the same pack, the pack
19+
# is returned, so you have in your stock one or several quants
20+
# inside a pack. This is a problem when you want to ship those
21+
# products again.
22+
# I provide the code in this module, but not the cron, because in some
23+
# scenarios, you may want to have packs in your stock.
24+
# Just add the cron in the specific module of your project.
25+
# Underlying problem solved in Odoo v11. Don't port that to v14 !
26+
logger.info('START cron auto unpack on internal locations')
27+
int_locs = self.env['stock.location'].search([('usage', '=', 'internal')])
28+
packages = self.search([('location_id', 'in', int_locs.ids)])
29+
logger.info('Unpacking %d packages on internal locations', len(packages))
30+
packages.unpack()
31+
logger.info('END cron auto unpack on internal locations')

0 commit comments

Comments
 (0)