Skip to Content
मेन्यू
This question has been flagged
2 Replies
6396 Views

If we add a related field on an invoice with Studio, you won't be able to find fields coming from the related sales order.

How can we create this field then?

Avatar
Discard
Author

Update: Since V15.0, you should first create your field with Studio then you can add the related.

For example, if the related field you want to create is a date:

1: Create a date field with Studio
2: Add the related on the field

It's really important that you directly create your Studio field with the right type.

Author Best Answer

Activate the debug mode and go to Settings > Technical > Database Structure > Fields


Create a new field and give it a name. Since we want to add it on an invoice, the model is “Journal Entry”.

 


If your invoice was created from a sales order, each invoice lines are linked to a sale order line.

So we need to create the related by field by retracing the way from the invoice line to the field you want on the sales order.


The expression you need is: invoice_line_ids.sale_line_ids.order_id


This field will give you the sales order related to the invoice. If you want a specific field from the sales order, for example the order date then I juste need to add .date_order at the end of the expression.


So: invoice_line_ids.sale_line_ids.order_id.date_order

 

Now that the field is created, you can add it on the view with Studio.


 

Be careful that it will only work correctly if the invoice was created from only one sales order.

If you have several sales order related to the invoice, the related field will take the sales order linked to the first invoice line.

Avatar
Discard
Best Answer

Hi Quentin, thanks for that. I was wondering if you would be able to help out with adding a related field on Vendor bills to the related Purchase order with Studio. Thanks in advance.

Avatar
Discard
Author

Hello Janice,
It's the same logic but you have to use purchase_line_ids instead of sale_line_ids in the expression for the related field.

Related Posts Replies Views Activity
1
मार्च 23
3097
0
जुल॰ 21
444
1
मई 22
4596
1
मई 22
5648
0
दिस॰ 21
3144