diff --git a/modules/purchase_trade/coffee.py b/modules/purchase_trade/coffee.py index cf2e88f..a26373e 100644 --- a/modules/purchase_trade/coffee.py +++ b/modules/purchase_trade/coffee.py @@ -1106,6 +1106,16 @@ class CoffeeLineMixin: def on_change_with_active_coffee_compatibility(self, name=None): return self.get_active_coffee_compatibility(name) + @classmethod + def view_attributes(cls): + attributes = super().view_attributes() + if not coffee_compatibility_active(): + attributes += [ + ('//page[@id="coffee_quality"]', 'states', + {'invisible': True}), + ] + return attributes + def get_coffee_quality_status(self, name=None): samples = self._coffee_samples() if not samples: diff --git a/modules/purchase_trade/configuration.py b/modules/purchase_trade/configuration.py index d88636b..dd466a0 100644 --- a/modules/purchase_trade/configuration.py +++ b/modules/purchase_trade/configuration.py @@ -177,6 +177,7 @@ class Configuration(ModelSingleton, ModelSQL, ModelView): cls.default_active_coffee_compatibility())) for values in vlist) cls._sync_coffee_menu_visibility(records, active=active) + cls._clear_coffee_view_cache() return records @classmethod @@ -190,6 +191,8 @@ class Configuration(ModelSingleton, ModelSQL, ModelView): records = sum(args[::2], []) cls._sync_report_labels(records) cls._sync_coffee_menu_visibility(records, active=active) + if active is not None: + cls._clear_coffee_view_cache() @classmethod def _sync_report_labels(cls, records): @@ -231,3 +234,7 @@ class Configuration(ModelSingleton, ModelSQL, ModelView): if menus: with Transaction().set_user(0): Menu.write(menus, {'active': active}) + + @classmethod + def _clear_coffee_view_cache(cls): + ModelView._fields_view_get_cache.clear()