# Keeping employee doing workflow on model when using cron

**URL:** https://discuss.tryton.org/t/keeping-employee-doing-workflow-on-model-when-using-cron/6717
**Category:** Developer
**Created:** [November 20, 2023, 12:20pm UTC](https://discuss.tryton.org/t/keeping-employee-doing-workflow-on-model-when-using-cron/6717 "2023-11-20T12:20:24Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![maxx](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/maxx/32/2320_2.png) [@maxx](https://discuss.tryton.org/u/maxx)
#### Post date: [November 20, 2023, 12:20pm UTC](https://discuss.tryton.org/t/keeping-employee-doing-workflow-on-model-when-using-cron/6717/1 "2023-11-20T12:20:25Z")

</div>

Hi,

When doing a quote on a sale, there’s a decorator to set the employee who did the quotation (Sale quoted by …) and a reset decorator to remove the employee when sale is draft.

To update a date on a move created when quoting a sale (custom code), we reset the sale to ‘draft’ state and then we set the sale in ‘quoting’ state to recreate the move with the correct date.

We’ve created a daily cron to do such operation to update outdated moves on quoted sales. As the cron is executed by root, we noticed that the field “Quoted by” is now empty for the sales that were processed because there’s no current employee linked to root user.

- Is there a way to keep the field “Quoted by” unchanged ?
- Could I bypass decorators “set\_employee” and “reset\_employee” when doing “draft” and “quote” on the sale?
- Or should I store in a variable the value of the field “quoted\_by” before processing then writing the value in the field after processing ?

Thanks for help 🙂

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [November 20, 2023, 12:34pm UTC](https://discuss.tryton.org/t/keeping-employee-doing-workflow-on-model-when-using-cron/6717/2 "2023-11-20T12:34:19Z")

</div>

> [@maxx](#):
>
> To update a date on a move created when quoting a sale (custom code), we reset the sale to ‘draft’ state and then we set the sale in ‘quoting’ state to recreate the move with the correct date.

Why not update the date on the stock move?

> [@maxx](#):
>
> Is there a way to keep the field “Quoted by” unchanged ?

No you have to manage it yourself.

---

<div class="post-metadata">

### Author: ![maxx](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/maxx/32/2320_2.png) [@maxx](https://discuss.tryton.org/u/maxx)
#### Post date: [November 21, 2023, 9:23am UTC](https://discuss.tryton.org/t/keeping-employee-doing-workflow-on-model-when-using-cron/6717/3 "2023-11-21T09:23:40Z")

</div>

> [@ced](#):
>
> Why not update the date on the stock move?

I’ll do that. First, it was because I changed a supply date on the sale and I thought I had to go back to draft to have write access to update the date but I noticed that crontab doesn’t care about write access like for shipment reschedule:

> **[modules/stock/shipment.py · branch/default · Tryton / Tryton · GitLab](https://foss.heptapod.net/tryton/tryton/-/blob/branch/default/modules/stock/shipment.py#L1103)**
>
> Business Software Modularity, scalability & security for your business Documentation Contribute

---

<div class="post-metadata">

### Author: ![system](https://discuss-cdn.tryton.org/uploads/default/original/1X/c6f8ec0a40525cdcd50058c734283450a4b3d38b.png) [@system](https://discuss.tryton.org/u/system)
#### Post date: [November 21, 2023, 9:24pm UTC](https://discuss.tryton.org/t/keeping-employee-doing-workflow-on-model-when-using-cron/6717/4 "2023-11-21T21:24:14Z")

</div>

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.
