Skip to Content
Menu
This question has been flagged
2 Replies
630 Views

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

Avatar
Discard

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

Best Answer

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

Avatar
Discard
Author

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)})

Author

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

https://ibb.co/mtDF1dY

Author

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

Author

Thanks Nomad for your help...

Author Best Answer

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

Avatar
Discard

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

Author

Nomad,

Nomad_King,

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