Hi everyone,
I'm currently working on an Odoo 16 module to enhance the sorting functionality in quotation orders for the company I'm working with. Our quotation template has distinct sections for 'Devices' and 'Additional Fees.' The goal is to automatically place products in the appropriate sections when operators add them to the quotation. For example, adding a device should automatically position it under the 'Devices' section, while adding an extra fee like a shipment fee should be placed in the 'Additional Fees' section.
By default, Odoo places all products as the last item. As I'm relatively new to Odoo development, I need help understanding the best approach to implement this logic.
After some debugging, I looked into the 'call_kw/sale.order.line/read' API that is called after a product is added with the "Add multiple products" button, which returns the 'SaleOrderLine' RecordSet. My understanding is that I can modify this RecordSet using custom logic.
Here are my specific questions:
- How can I effectively modify the 'SaleOrderLine' RecordSet to automatically sort products into the respective sections?
- Are there alternative approaches that could be more efficient or better suited to achieve the automated sorting of products?
If anyone could provide me with code examples or point me in the right direction, I'd greatly appreciate your help and insights.
Thank you all in advance!
I think it's not a matter of sorting. For me it's a matter of having proper data. I haven't fully get the picture from your description of what you are trying to accomplish
Hi Axel, I'm going to try to be clearer. Here's a step-by-step explanation:
1. Let's say the operator needs to create a new quotation.
2. To begin, the operator opens the quotation template provided by the company, which contains 4 lines. The first line is a section labeled 'Devices,' the second line contains the actual device products, the third line is a section labeled 'additional fees,' and the fourth line is for the shipment fee product.
3. Assuming the operator adds a device to the quotation, the device doesn't get positioned in the 'Devices' section but instead ends up as the last line of the quotation. Visually, it appears within the 'additional fees' section.
In the example I provided, the device should be placed at line 3, before the 'Additional fees' section. To distinguish the products from the additional fees, I can use a regex since the devices have similar names. So, that's not a big deal.
Hi Ovidio, maybe you're complicating matters, just add first section then all products of this section then continue with other sections