details: https://code.tryton.org/tryton/commit/cc6d7d01ebe9
branch: default
user: Cédric Krier <[email protected]>
date: Mon Jul 13 15:34:03 2026 +0200
description:
Show warehouses field of cron only for methods that need them
Closes #14952
diffstat:
modules/product_cost_warehouse/ir.py | 35 ++++++++++++++++++++++++++++++++++-
1 files changed, 34 insertions(+), 1 deletions(-)
diffs (56 lines):
diff -r bea535142d87 -r cc6d7d01ebe9 modules/product_cost_warehouse/ir.py
--- a/modules/product_cost_warehouse/ir.py Mon Jul 13 15:33:35 2026 +0200
+++ b/modules/product_cost_warehouse/ir.py Mon Jul 13 15:34:03 2026 +0200
@@ -1,7 +1,8 @@
# 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.model import ModelSQL, ModelView, dualmethod, fields
-from trytond.pool import PoolMeta
+from trytond.pool import Pool, PoolMeta
+from trytond.pyson import Eval, If
from trytond.transaction import Transaction
@@ -10,10 +11,42 @@
warehouses = fields.Many2Many(
'ir.cron-stock.warehouse', 'cron', 'warehouse',
"Warehouses",
+ states={
+ 'readonly': Eval('running', False),
+ 'invisible': ~Eval('warehouse_needed', False),
+ },
domain=[
('type', '=', 'warehouse'),
+ If(~Eval('warehouse_needed'),
+ ('id', '=', None),
+ ()),
],
help="Warehouses registered for this cron.")
+ warehouse_needed = fields.Function(fields.Boolean(
+ "Warehouse Needed"),
+ 'on_change_with_warehouse_needed')
+
+ @classmethod
+ def __setup__(cls):
+ super().__setup__()
+ cls.methods_warehouse_needed = {
+ 'product.product|recompute_cost_price_from_moves',
+ }
+
+ @fields.depends('method')
+ def on_change_with_warehouse_needed(self, name=None):
+ return self.method in self.__class__.methods_warehouse_needed
+
+ @fields.depends('warehouses', methods=['on_change_with_company_needed'])
+ def on_change_method(self):
+ pool = Pool()
+ Warehouse = pool.get('stock.location')
+ if self.on_change_with_warehouse_needed():
+ self.warehouses = Warehouse.search([
+ ('type', '=', 'warehouse'),
+ ])
+ else:
+ self.warehouses = []
@dualmethod
@ModelView.button