Add warehouses selection to supply stock wizard

issue10532
review353701002
This commit is contained in:
David Blanco Bautista committed 2022-04-07 00:06:34 +02:00
1 parent d4e0aef9e0
commit 06f84aa761
4 files changed
+38 -4

No files matched your search

+1
View File
@@ -1,3 +1,4 @@
* Add warehouses selection to supply stock wizard
* Add support for Python 3.10
* Remove support for Python 3.6
+8 -1
View File
@@ -13,7 +13,7 @@ class ShipmentInternal(ModelSQL, ModelView):
__name__ = 'stock.shipment.internal'
@classmethod
def generate_internal_shipment(cls, clean=True):
def generate_internal_shipment(cls, clean=True, warehouses=None):
"""
Generate internal shipments to meet order points defined on
non-warehouse location.
@@ -29,6 +29,11 @@ class ShipmentInternal(ModelSQL, ModelView):
Move = pool.get('stock.move')
LeadTime = pool.get('stock.location.lead_time')
if warehouses is None:
warehouses = Location.search([
('type', '=', 'warehouse'),
])
user_record = User(Transaction().user)
today = Date.today()
lead_time = LeadTime.get_max_lead_time()
@@ -43,6 +48,8 @@ class ShipmentInternal(ModelSQL, ModelView):
order_points = OrderPoint.search([
('type', '=', 'internal'),
])
order_points = [
op for op in order_points if op.location.warehouse in warehouses]
id2product = {}
product2op = {}
id2location = {}
+28 -3
View File
@@ -1,7 +1,7 @@
# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
from trytond.i18n import gettext
from trytond.model import ModelView
from trytond.model import ModelView, fields
from trytond.pool import Pool
from trytond.transaction import Transaction
from trytond.wizard import (
@@ -91,14 +91,24 @@ class Supply(Wizard):
def generate_internal(self, clean):
pool = Pool()
ShipmentInternal = pool.get('stock.shipment.internal')
return ShipmentInternal.generate_internal_shipment(clean=clean)
# Use getattr because start is empty when run by cron
if getattr(self.start, 'warehouses', None):
warehouses = self.start.warehouses
else:
warehouses = None
return ShipmentInternal.generate_internal_shipment(
clean=clean, warehouses=warehouses)
def transition_internal(self):
return self.next_action('internal')
@property
def _purchase_parameters(self):
return {}
parameters = {}
# Use getattr because start is empty when run by cron
if getattr(self.start, 'warehouses', None):
parameters['warehouses'] = self.start.warehouses
return parameters
def generate_purchase(self, clean):
pool = Pool()
@@ -113,3 +123,18 @@ class Supply(Wizard):
class SupplyStart(ModelView):
"Supply Stock"
__name__ = 'stock.supply.start'
warehouses = fields.Many2Many(
'stock.location', None, None, "Warehouses",
domain=[
('type', '=', 'warehouse'),
],
help="If empty all warehouses are used.")
@classmethod
def default_warehouses(cls):
pool = Pool()
Location = pool.get('stock.location')
warehouse = Location.get_default_warehouse()
if warehouse:
return [warehouse]
+1
View File
@@ -5,4 +5,5 @@ this repository contains the full copyright notices and license terms. -->
<image name="tryton-question" xexpand="0" xfill="0"/>
<label string="Supply Stock?" id="supply"
yalign="0.0" xalign="0.0" xexpand="1"/>
<field name="warehouses" colspan="2"/>
</form>