Workflow has no attribute _transitions

Hello,
I’m trying to use the workflow mixin in my model but It’s giving me this error:

Traceback (most recent call last):
  File "/home/xcodinas/.virtualenvs/develop/bin/trytond-admin", line 7, in <module>
    exec(compile(f.read(), __file__, 'exec'))
  File "/home/xcodinas/projectes/develop/trytond/bin/trytond-admin", line 21, in <module>
    admin.run(options)
  File "/home/xcodinas/projectes/develop/trytond/trytond/admin.py", line 54, in run
    activatedeps=options.activatedeps)
  File "/home/xcodinas/projectes/develop/trytond/trytond/pool.py", line 160, in init
    lang=lang, activatedeps=activatedeps)
  File "/home/xcodinas/projectes/develop/trytond/trytond/modules/__init__.py", line 418, in load_modules
    _load_modules(update)
  File "/home/xcodinas/projectes/develop/trytond/trytond/modules/__init__.py", line 388, in _load_modules
    load_module_graph(graph, pool, update, lang)
  File "/home/xcodinas/projectes/develop/trytond/trytond/modules/__init__.py", line 201, in load_module_graph
    pool.setup(classes)
  File "/home/xcodinas/projectes/develop/trytond/trytond/pool.py", line 234, in setup
    cls.__setup__()
  File "/home/xcodinas/projectes/develop/trytond/trytond/modules/purchase_intake/purchase.py", line 137, in __setup__
    cls._transitions |= set((
AttributeError: type object 'purchase.intake' has no attribute '_transitions'

i’m defining the class this way:

class PurchaseIntake(ModelSQL, ModelView, Workflow):
    'Purchase Intake'
    __name__ = 'purchase.intake'

Any idea on what I’m doing wrong?

My guess would be that either you’re not calling super() or that Workflow should be the first parent of the class (ie (Workflow, ModelSQL, ModelView) instead of (ModelSQL, ModelView, Workflow)).

This is the requirement because Workflow does not inherit from any Model but it is using their attribute.

I’m wondering if it makes sense that Workflow inherits from Model to prevent this kind of errors.

The problem is that it overrides copy which is defined in ModelStorage. But do we want to force to use Workflow only with ModelStorage? transition decorator uses write method which seems to make it only works with at least a ModelStorage.

If we go this way, DictSchemaMixin, MultiValueMixin, SequenceOrderedMixin, TreeMixin and UnionMixin should be revisited also.

This may break some existing code that uses those Mixin in a different way.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.