Hello, I’m experiencing diffculties on the development of my custom module, and I’m very new to Tryton dev, so I’m asking for your help, your knowledge and your experience on this framework.
Here is a screenshot of my module right now :
My module implements a new model called “SE Data”, which goal is to make statistics on various data of the ERP, on a chosen period set in the “Start of the Period” and “End of the Period” editable fieds. Only the three fields at the top are editable, the other fields are calculated using data from the database, so they are read-only.
The list you can see is a list of purchases (registered in the database) which purchase date is included into the period given to the “SE Data” instance. The boolean fields are fields I added to the Purchase and Party modules, to detect if a purchase is “sustainable/responsible”. Below this list, I calculated statistics on the rate of “responsible” purchases and other statistics.
My problem is that I would like to display another list than this list of purchases : instead, I would like to display a list of the suppliers (basically party instances) with the same boolean fields, and the total of the amounts of all the purchases made to this supplier in the given period. Basically, I would like to display the same list, group by party, with the sum of the amounts of the purchases corresponding to the party.
I could not find any element in the documentation that would simply make a “group by” operation on a list of instances of a model. So I thought about 2 solutions, and I did not manage to implement neither of them. These solutions are :
- Creating a new model and generating new instances of this model triggering the creation of a new SE Data instance, but I did not find how to trigger events and create a new instance in the code
- Using this example suggested by ced, but the XML implementation of the HoursEmployee model makes me think it won’t be possible to display such list as a field of another model, neither to choose as a context the fields of my SE-Data model
I’m waiting for your suggestions on new ideas to implement it, or some elements to help me implementing the solutions I’ve thought about. You can ask me to give details on how I tried to implement the solutions above if it can help. Also, if you think that the general implementation of my module does not fit with Tryton spirit, feel free to suggest me other ways to implement this feature more respectfully