I write a custom class method on trytond. I would like to try it on proteus but I’m not sure how to use it.
The method is on party.party
@classmethod
def get_party_invoices_last_month(cls, parties):
# the method is processed
from decimal import Decimal
from proteus import config, Model
from jsonrpclib import Server as ServerProxy
import jsonrpclib
import json
import base64
Tryton server connection settings
HOST = ‘127.0.0.1’
PORT = ‘8000’
DB = ‘testdb’
USER = ‘admin’
PASSWORD = ‘mypass’
if __name__ == '__main__':
config.set_xmlrpc(
url='http://{user}:{password}@{host}:{port}/{db}/'.format(
user=USER, password=PASSWORD, host=HOST, port=PORT, db=DB))
Party = Model.get('party.party')
party = Party(name='Customer')
invoices = Party.get_party_invoices_last_month(party)
With these code I should receive an empty list, but I receive the follow message:
TypeError: cannot marshal <class ‘set’> objects
You can also add the method to RPC and then it will be possible to call it directly from proteus. This way the method is also avaiable from json-rpc and xml-rpc API calls and also from tryton and sao.
But I receive the follow message: raise TypeError("cannot marshal %s objects" % type(value)) TypeError: cannot marshal <class 'set'> objects
If a use the follow code
Sale.get_party_invoices_last_month([party.id])
The follow message is displayed
Traceback (most recent call last):
File "/opt/lib/python3.6/site-packages/trytond/protocols/dispatcher.py", line 171, in _dispatch = rpc.convert(obj, *args, **kwargs)
File "/opt/lib/python3.6/site-packages/trytond/rpc.py", line 44, in convert for key in list(context.keys()):
`xmlrpc.client.Fault: <Fault 255: "'list' object has no attribute 'keys'">`
I tried the method on tryton and sao an works fine but in proteus doesn’t work.