Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
1 Odpovědět
112 Zobrazení

Hi all!

I have multiple operators that utilize the shop floor app only, and sometimes they have to add in work/tasks that would be outside of normal planning.


I would like to add a dummy work order that they can access and record time/notes for when those occurrences do happen. I already have that set up.


Upon marking it complete, I would like to have an automated action repopulate another identical work order in it's place, but with a new number that would be next in sequence.


Assuming the "execute python code" function is necessary here. Is there someone that can help me out with the code to complete this?

TIA!

Avatar
Zrušit
Nejlepší odpověď

Hi,

You can solve this by creating an Automated Action on the Work Order (mrp.workorder) model with trigger On Update, and using the following Python code in the action:


if record.state == 'done' and record.production_id:

    new_wo = record.copy({

        'state': 'ready',

        'time_ids': [(5, 0, 0)],

        'qty_produced': 0,

    })

    new_wo.name = self.env['ir.sequence'].next_by_code('mrp.workorder') or new_wo.name


This will duplicate your dummy work order when marked done, reset it to ready, clear logs, and give it the next sequence number.


Hope it helps

Avatar
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
2
srp 25
496
2
srp 25
1536
0
úno 25
1624
1
srp 25
2246
2
pro 24
1882