Hi,
Here first you have to add a field of type Many2one with comodel as product.product has to be added in the sale.order model, then you can define a compute function for the same field which computes the first line from the sale.order.line.
Regarding the field type that has to be added in the sale.order its upto you, if you need to get only the product name you can add a char field also, but better go with the Many2one field.
You can inherit the sale.order model and add field like this,
product_id = fields.Many2one('product.product', 'First Product')
Now you have to define the compute function for the field,
@api.depends('order_line', 'order_line.product_id')
def _compute_advice_product(self):
for rec in self:
advice_pro_lines = rec.order_line.sorted('sequence').filtered(lambda line: line.product_id.categ_id.name == 'Advice')
if advice_pro_lines:
rec.product_id = advice_pro_lines[0].product_id.id
add update the field with compute function,
product_id = fields.Many2one('product.product', 'First Product', compute=_compute_advice_product)
The code is not TESTED, you can check and make necessary adjustments.
Thanks