Skip to content
This repository has been archived by the owner on Mar 4, 2020. It is now read-only.

Field DependentServices of Calculations keep the old UIDs after sync #63

Open
ramonski opened this issue Aug 14, 2018 · 3 comments
Open
Labels

Comments

@ramonski
Copy link
Contributor

Steps to reproduce

  • Create a new Senaite instance and setup the AS/Calculations as displayed below
  • Sync only setup items to a new/empty Senaite instance
  • Create a new AR the given Analyses in the new instance
  • Add results for Länge/Breite/Höhe

Translations

  • Länge -> Length
  • Breite -> Width
  • Höhe -> Height
  • Kantenlänge -> Edglength
  • Umfang -> Circumference
  • Grundfläche -> Area
  • Volumen -> Volume

Calculations

  • Edglength: 4 * ([laenge] + [breite] + [hoehe])
  • Circumference: 2 * ([laenge] + [breite])
  • Volume: [laenge] * [breite] * [hoehe]
  • Area: [laenge] * [breite]

Current behavior

The Calculations of the dependant services (Kantenlänge, Umfang, Grundfläche, Volumen) is not triggered

Expected behavior

The Calculations of the dependant services (Kantenlänge, Umfang, Grundfläche, Volumen) is triggered and calculated

Screenshot (optional)

@ramonski ramonski added the bug label Aug 14, 2018
@ramonski
Copy link
Contributor Author

The Field DependentServices is set implicitly in setFormula:
https://github.com/senaite/senaite.core/blob/master/bika/lims/content/calculation.py#L212

Existing Analyses keep a history aware version to the calculation and need to be set as well.

@ramonski
Copy link
Contributor Author

Probably the portal_repository need to be synced as well 🤔

@ramonski
Copy link
Contributor Author

The only solution I can think of the moment is to iterate through all calculations and fix them like this:

>>> from bika.lims import api

>>> catalog = api.get_tool("bika_setup_catalog")
>>> brains = catalog({"portal_type": "Calculation"})

>>> for brain in brains:
...     calc = api.get_object(brain)
...     calc.setFormula(calc.getFormula())

>>> catalog = api.get_tool("bika_analysis_catalog")
>>> brains = catalog({"portal_type": "Analysis"})

>>> for brain in brains:
...     analysis = api.get_object(brain)
...     calc = analysis.getCalculation()
...     if calc:
...         calc.setFormula(calc.getFormula())

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

No branches or pull requests

1 participant