跳至内容
菜单
此问题已终结
2 回复
6397 查看

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?

形象
丢弃
编写者

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.

编写者 最佳答案

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.

形象
丢弃
最佳答案

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.

形象
丢弃
编写者

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.

相关帖文 回复 查看 活动
1
3月 23
3097
0
7月 21
444
1
5月 22
4599
1
5月 22
5650
0
12月 21
3144