How to use proteus with PayInvoice Wizard

I have a problem getting proteus to execute the wizard. It raises the following error:

Traceback (most recent call last):
  File "./", line 221, in <module>
  File "./", line 217, in run
    main(args.database, args.config_file, args.source)
  File "./", line 202, in main
    pay_supply_invoices(source, config.get_config())
  File "./", line 188, in pay_supply_invoices
    pay_invoice = Wizard("", context=config.context)
  File "/home/richi/work/pyenv/tryton54/lib/python3.6/site-packages/proteus/", line 1207, in __init__
  File "/home/richi/work/pyenv/tryton54/lib/python3.6/site-packages/proteus/", line 1234, in execute
  File "/home/richi/work/pyenv/tryton54/lib/python3.6/site-packages/proteus/", line 188, in __call__
    result = rpc.result(meth(*args, **kwargs))
  File "/home/richi/work/pyenv/tryton54/lib/python3.6/site-packages/trytond/wizard/", line 295, in execute
    return wizard._execute(state_name)
  File "/home/richi/work/pyenv/tryton54/lib/python3.6/site-packages/trytond/wizard/", line 307, in _execute
  File "/home/richi/work/pyenv/tryton54/lib/python3.6/site-packages/trytond/wizard/", line 93, in get_defaults
  File "/home/richi/work/pyenv/tryton54/lib/python3.6/site-packages/trytond/modules/account_invoice/", line 2738, in default_start
    default['company'] =
  File "/home/richi/work/pyenv/tryton54/lib/python3.6/site-packages/trytond/model/", line 1401, in __getattr__
    return super(ModelStorage, self).__getattr__(name)
  File "/home/richi/work/pyenv/tryton54/lib/python3.6/site-packages/trytond/model/", line 281, in __getattr__
    % (self.__name__, name, self._values))
AttributeError: 'account.invoice' Model has no attribute 'company': None

I know the wizard accesses the current invoice ID from the context active_id, so I set this value in the proteus config context before calling the wizard, but it still doesn’t work. Here is my code:

           with config.set_context(
                pay_invoice = Wizard("", context=config.context)
       = invoice.invoice_date
                pay_invoice.form.description = mov_id
                pay_invoice.execute('choice', context=config.context)
                if (pay_invoice.form.__class__.__name__ == ''):
                    pay_invoice.form.type = 'writeoff'
                    pay_invoice.form.writeoff = writeoff_precio
                    pay_invoice.execute('pay', context=config.context)
            print(f"Paid, move {mov_id}")

I trace the error and it is due to Transaction().context['active_id'] not returning a value when PayInvoice.default_start(self, fields) is called, as if setting the active_id context in proteus config has no effect in the Transaction context.
Can someone tell me what I am doing wrong?

I figured out the problem. I was not passing the correct parameters to proteus Wizard constructor.
I need to pass the invoice to the model argument in the constructor, and within the constructor this set to active_id in the context.

So the working code is:

pay_invoice = Wizard("", context=config.context, models=[invoice])

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