I have a problem getting proteus to execute the account.invoice.pay
wizard. It raises the following error:
Traceback (most recent call last):
File "./pay_invoices.py", line 221, in <module>
run()
File "./pay_invoices.py", line 217, in run
main(args.database, args.config_file, args.source)
File "./pay_invoices.py", line 202, in main
pay_supply_invoices(source, config.get_config())
File "./pay_invoices.py", line 188, in pay_supply_invoices
pay_invoice = Wizard("account.invoice.pay", context=config.context)
File "/home/richi/work/pyenv/tryton54/lib/python3.6/site-packages/proteus/__init__.py", line 1207, in __init__
self.execute(self.start_state)
File "/home/richi/work/pyenv/tryton54/lib/python3.6/site-packages/proteus/__init__.py", line 1234, in execute
ctx)
File "/home/richi/work/pyenv/tryton54/lib/python3.6/site-packages/proteus/config.py", line 188, in __call__
result = rpc.result(meth(*args, **kwargs))
File "/home/richi/work/pyenv/tryton54/lib/python3.6/site-packages/trytond/wizard/wizard.py", line 295, in execute
return wizard._execute(state_name)
File "/home/richi/work/pyenv/tryton54/lib/python3.6/site-packages/trytond/wizard/wizard.py", line 307, in _execute
list(view['fields'].keys()))
File "/home/richi/work/pyenv/tryton54/lib/python3.6/site-packages/trytond/wizard/wizard.py", line 93, in get_defaults
defaults.update(default(fields))
File "/home/richi/work/pyenv/tryton54/lib/python3.6/site-packages/trytond/modules/account_invoice/invoice.py", line 2738, in default_start
default['company'] = invoice.company.id
File "/home/richi/work/pyenv/tryton54/lib/python3.6/site-packages/trytond/model/modelstorage.py", line 1401, in __getattr__
return super(ModelStorage, self).__getattr__(name)
File "/home/richi/work/pyenv/tryton54/lib/python3.6/site-packages/trytond/model/model.py", 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(active_id=invoice.id):
pay_invoice = Wizard("account.invoice.pay", context=config.context)
pay_invoice.form.date = invoice.invoice_date
pay_invoice.form.description = mov_id
pay_invoice.execute('choice', context=config.context)
if (pay_invoice.form.__class__.__name__ == 'account.invoice.pay.ask'):
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?