Keeping employee doing workflow on model when using cron

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 :slight_smile:

Why not update the date on the stock move?

No you have to manage it yourself.

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:

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