Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No way to get the response of a transaction #31

Open
spaceone opened this issue May 3, 2024 · 2 comments
Open

No way to get the response of a transaction #31

spaceone opened this issue May 3, 2024 · 2 comments

Comments

@spaceone
Copy link

spaceone commented May 3, 2024

Collmex returns lines about the status (https://www.collmex.de/c.cmx?1005,1,help,api_Rueckmeldungen), e.g. about the Nummernvergabe (https://www.collmex.de/c.cmx?1005,1,help,daten_importieren_nummernvergabe) when creating objects.

E.g. when creating a customer without an ID, I am unable to get the ID of the newly created object.
It would be nice to write the returned lines of self.utility._post(self.data.getvalue()) in tpc_vote() into some variable.

@spaceone
Copy link
Author

spaceone commented May 3, 2024

Alternative would be to provide a second create method:

    def create_direct(self, items):                                                                                                                                                                                                             
        data = io.StringIO()                                                                                                                                                                                                       
        writer = csv.writer(data, dialect=CollmexDialect)                                                                                                                                                                                      
        for item in items:
            item.company = self.company_id                                                                                                                                                                                                         
            writer.writerow([elem for elem in list(item)])                                                                                                                                                                                         
        return self.utility._post(data.getvalue())

     def get_new_object_id(self, lines, temp_num):
         for line in lines:
             if line[0] == 'NEW_OBJECT_ID' and (not temp_num or str(temp_num) == line[2]):
                 return line[1]

and use it like:
new_id = self.get_new_object_id(self.create_direct(items), '-1000')

@spaceone
Copy link
Author

spaceone commented Sep 13, 2024

Best would probably that after transaction.commit() was called, for each item a function is called which receives the input row and the result row.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant