Connectors mailing list archives

connectors@odoo-community.org

Avatar

Re: Delayed execution of jobs

by
Open Source Integrators, Maxime Chambreuil
- 24/07/2019 23:45:03
Hello,

Thanks Laurent. It is working perfectly.

With the execution of the job being delayed, we get duplicate jobs. Here is the scenario:

Configuration: 
* A job is created when a fsm order enters the confirmed stage.
* The jobs are scheduled to be executed everyday at 4pm
* When the job is executed, the customer gets a phone call.

Usage:
9am
Order 1 enters the confirmed stage --> Job 1 is created and scheduled for 4pm.

10am
Order 1 goes back to draft stage

11am
Order 1 goes to confirmed stage --> Job 2 is created and scheduled for 4pm.

4pm
Job 1 and 2 gets executed --> The customer gets 2 phone calls saying that the order has been confirmed. :(

How can we implement uniqueness of the job based on the order and the stage? To get something like:

9am
Order 1 enters the confirmed stage --> Job 1 is created and scheduled for 4pm.

10am
Order 1 goes back to draft stage

11am
Order 1 goes to confirmed stage --> A job for that order and stage already exists. Nothing happen.

4pm
Job 1 is executed --> The customer gets 1 phone call saying that the order has been confirmed. :)

Thank you!

MAXIME CHAMBREUIL
PROJECT MANAGER/CONSULTANT
O: 1.855.877.2377 EXT. 710
M: 602.427.5632
E: MChambreuil@OpenSourcelntegrators.com
P.O. BOX 940, HIGLEY, AZ 85236




On Thu, Jun 13, 2019 at 10:55 AM Maxime Chambreuil <mchambreuil@opensourceintegrators.com> wrote:
Thank you Laurent. We will try that tomorrow.

Have a great evening!

MAXIME CHAMBREUIL
PROJECT MANAGER/CONSULTANT
O: 1.855.877.2377 EXT. 710
M: 602.427.5632
E: MChambreuil@OpenSourcelntegrators.com
P.O. BOX 940, HIGLEY, AZ 85236



On Thu, Jun 13, 2019 at 9:57 AM Mignon, Laurent <laurent.mignon@acsone.eu> wrote:
Hi Maxime,

When delaying a method with queue_job you can specify the eta..... (https://github.com/OCA/queue/blob/12.0/queue_job/job.py#L224)


class XYZ(models.Model):
     _name = 'xyz'
   
    @job
    def my_method(self)
        pass

...

self.env["xyz"].browse(1).with_delay(eta=....).my_method()


Regards,

lmi


On Thu, Jun 13, 2019 at 4:42 PM Maxime Chambreuil <mchambreuil@opensourceintegrators.com> wrote:
Hello,

We are working on a connector with Voicent, a telephony platform, to automatically call customers when a helpdesk ticket or field service order is completed.

As we can't call the customer in the middle of the night, the voicent backend defines times to call, like 10am, 2pm, 4pm.

We are creating a job in the queue when the ticket or order is completed (at 7pm) but we want to delay the execution of the job by the worker until the next day at 10am. The problem is that the worker executes the job immediately and marks it as Done.

Do you have any suggestions to work around this issue?


Thank you.

MAXIME CHAMBREUIL
PROJECT MANAGER/CONSULTANT
O: 1.855.877.2377 EXT. 710
M: 602.427.5632
E: MChambreuil@OpenSourcelntegrators.com
P.O. BOX 940, HIGLEY, AZ 85236

_______________________________________________
Mailing-List: https://odoo-community.org/groups/connectors-30
Post to: mailto:connectors@odoo-community.org
Unsubscribe: https://odoo-community.org/groups?unsubscribe

_______________________________________________
Mailing-List: https://odoo-community.org/groups/connectors-30
Post to: mailto:connectors@odoo-community.org
Unsubscribe: https://odoo-community.org/groups?unsubscribe

Reference