Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
2 ตอบกลับ
883 มุมมอง

Hello,

with Studio I make a related field in the MO: procurement_group_id.mrp_production_ids.move_raw_ids.forecast_expected_date

If I have several compononents in my MO, the result of that field is the expected date of the 1st component.

How can I have the expected date of the 2nd or the 3rd component?

Thanks for your help

Denis

อวตาร
ละทิ้ง

What are you trying to accomplish? Please give more detail(maybe add images as well).

คำตอบที่ดีที่สุด

Denis,

Here is a code that should work for you.
If you have any questions feel free to ask.

Link of view: https://ibb.co/bdtTjSc

Link of automated action: https://ibb.co/KmzCtvk

อวตาร
ละทิ้ง
ผู้เขียน

Hello,

I have an error:
ValueError: <class 'ValueError'>: "max() arg is an empty sequence" while evaluating

can you send me screenshot of your code?

Probably you need to create the following if statement for the "mrp.write" call:

if dates:
mrp.write({'x_studio_date': max(dates)})

ผู้เขียน

I try with the if statement. No error message but no change on date field of my MO

https://ibb.co/mtDF1dY

ผู้เขียน

Sorry,
in fact, I think that it works... Very great...

How can I do if piece are on stock then date is today and if there are no order date is very late (1 year)?

Denis,

I think you should also set the trigger to: on creation & update.

To set the the current date when pieces are on stock, you should create the following else statement:
else:
mrp.write({'x_studio_date': date.today()})

Denis, unfortunately the comparison between current date and other date (1 year apart) is out of my knowledge maybe you could ask in another post more specifically for that.

If my answer was helpful please mark it as best, so that others can learn as well

ผู้เขียน

Thanks Nomad for your help...

ผู้เขียน คำตอบที่ดีที่สุด

Hello Nomad_King

https://ibb.co/GkQXtD3

Date of availability of component:  procurement_group_id.mrp_production_ids.move_raw_ids.forecast_expected_date

It return the date of the 1st component of my MO but I want to have the date of for example the 3rd component of the list (Product: E547-0305)

Denis

อวตาร
ละทิ้ง

Denis,
the date of availability of component field you added with studio is of type "date and time". You cannot have this field display more than 1 value.

So my question is, do you always want only the value of component 3?

Or is it always same component you want to check its availability? Product: E547-0305

ผู้เขียน

Nomad,

Nomad_King,

I want to calculate the latest date of all the components and that date will be "Date of availability of component"