跳至內容
選單
此問題已被標幟
1 回覆
2081 瀏覽次數

This is how it should work.For example:

1 ------column1------------

2 ------column2------------

3 ------column3------------

4 ------Column4------------

etc..

I have made an automated action for this, but it does not work as intended:

The automated action refers to the model of the one2many field and is triggered when a record is created. The following Python code is executed:



for line in record.picking_id.move_line_ids_without_package:
  for rec in str(record.x_studio_position):
    record['x_studio_position'] = len(record.picking_id.move_line_ids_without_package) 

What happens is the following for e.g. 4 columns

4 ------column1------------

4 ------column2------------

4------column3------------

4 ------column4------------

It will write the total number in each row instead of the current column number.



頭像
捨棄
最佳答案

You set the position to the number of lines in the field move_line_ids_without_package, it will be the same for all lines.

You can use enumerate to get the line sequence

Example:

for index, line in enumerate(record.picking_id.move_line_ids_without_package): line['x_studio_position'] = index + 1

頭像
捨棄