Hi,
I have prepared a custom module to meet your requirement of displaying product details (product name and quantity) in the Sale Orders tree view. If you know odoo developing, Below is the solution:
Python Code:
Inherit the sale.order model to add a computed field product_details that combines the product name and quantity from the order lines.
from odoo import fields, models, api
class SaleOrder(models.Model):
_inherit = 'sale.order'
product_details = fields.Text(string='Product Details', compute='_compute_product_details', store=True)
@api.depends('order_line.product_template_id', 'order_line.product_uom_qty')
def _compute_product_details(self):
for order in self:
details = []
if not order.order_line:
order.product_details = ""
else:
for line in order.order_line:
details.append(f"{line.product_template_id.name} - {line.product_uom_qty or 0.0}")
order.product_details = "\n".join(details)
XML Code:
The XML adds the product_details field as a column in the Sale Orders and Quotations tree views.
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<data>
<!-- Add product details to the Sale Order tree view -->
<record id="view_order_tree_product_details" model="ir.ui.view">
<field name="name">sale.order.tree.product.details</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_tree"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='partner_id']" position="after">
<field name="product_details" width="200"/>
</xpath>
</field>
</record>
<!-- Add product details to the Quotation tree view -->
<record id="view_order_quotation_tree_product_details" model="ir.ui.view">
<field name="name">sale.order.tree.product.details</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_quotation_tree_with_onboarding"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='partner_id']" position="after">
<field name="product_details" width="200"/>
</xpath>
</field>
</record>
</data>
</odoo>
Add the code to a new module in your custom add-ons directory.
Update your module list and install the custom module.
Open the Sale Orders menu to see the new "Product Details" column in the tree view.
Best regards,
-----------------------------
NIZAMUDHEEN MJ
Accurates