Re,
I try to add Addresses it’s ok now.
A new question, it’s not possible to delete all adresses of a party ?
party, = Party.find([('code', '=', rowCustomer['Code'])])
while party.addresses:
party.addresses.pop()
I got the error bellow :
Traceback (most recent call last):
File "/mnt/d/Developpement/docker/dockermssqldph/source/GRCToTryton.py", line 76, in <module>
party.save()
File "/mnt/d/Developpement/docker/dockermssqldph/source/venv/lib/python3.10/site-packages/proteus/__init__.py", line 102, in newfunc
return self.func(owner, [instance], *args, **kwargs)
File "/mnt/d/Developpement/docker/dockermssqldph/source/venv/lib/python3.10/site-packages/proteus/__init__.py", line 866, in save
proxy.write(*values)
File "/usr/lib/python3.10/xmlrpc/client.py", line 1122, in __call__
return self.__send(self.__name, args)
File "/usr/lib/python3.10/xmlrpc/client.py", line 1464, in __request
response = self.__transport.request(
File "/usr/lib/python3.10/xmlrpc/client.py", line 1166, in request
return self.single_request(host, handler, request_body, verbose)
File "/usr/lib/python3.10/xmlrpc/client.py", line 1182, in single_request
return self.parse_response(resp)
File "/usr/lib/python3.10/xmlrpc/client.py", line 1354, in parse_response
return u.close()
File "/usr/lib/python3.10/xmlrpc/client.py", line 668, in close
raise Fault(**self._stack[0])
xmlrpc.client.Fault: <Fault 1: "Vous ne pouvez pas changer le tiers de l'adresse «\xa0.......\xa0». - ">
When I search in the party module, I find this code :
@classmethod
def write(cls, *args):
actions = iter(args)
for addresses, values in zip(actions, actions):
if 'party' in values:
for address in addresses:
if address.party.id != values['party']:
raise AccessError(
gettext('party.msg_address_change_party',
address=address.rec_name))
super(Address, cls).write(*args)
I’ve debug the different Id (party and party.id in address) and they are identical. I don’t understand this error.
A workaround is to get all adresses of a party with find and to delete each address, like this :
address = Address.find([('party', '=', rowCustomer['Code'])])
for ad in address:
ad.delete()
I’ll try to add a contact on an address now.
Thank you
Johan