[18.0][MIG] sale_automatic_workflow_job: Migration to 18.0 #3460
Conversation
3e8a3f0 to
1907b62
Compare
|
/ocabot migration sale_automatic_workflow_job |
4aff9e4 to
c4d794a
Compare
yankinmax
left a comment
There was a problem hiding this comment.
I don't get finally, why don't you replace existing string formatting with f-string. Instead you use old style.
|
|
||
| def _do_sale_done_job_options(self, sale, domain_filter): | ||
| description = _("Mark sales order {} as done").format(sale.display_name) | ||
| description = self.env._("Mark sales order %s as done", sale.display_name) |
There was a problem hiding this comment.
| description = self.env._("Mark sales order %s as done", sale.display_name) | |
| description = self.env._(f"Mark sales order {sale.display_name} as done") |
There was a problem hiding this comment.
@vvrossem FTR using f strings will break translations because the string will be evaluated at run time making the string always different. Ideally we should have named placeholders like _("Foo %(baz)s", baz=self.baz), but is not a blocker.
There was a problem hiding this comment.
Other reviewers suggested to use a positional argument if there is only one (as is the case here), and switch to named arguments in case of multiple. I like that one myself, but maybe that's all that it is, a preference?
| from odoo import fields | ||
| from odoo.tests import tagged | ||
|
|
||
| from .common import TestAutomaticWorkflowMixin, TestCommon |
There was a problem hiding this comment.
I would adapt TestCommon so it uses BaseCommon instead of TransactionCase
Use BaseCommon as base test class to reduce overhead from tracking and boost the test suite.
|
I'm wondering why we are keeping the cron jobs in this module? This seems so inefficient, when we could have the queue jobs created on creation of the various records (sale, picking, invoice) based on the configured automatic workflow. Maybe I'm missing a use case... [EDIT] use case I'm missing: external event changing something on the record which makes it match the configured domain to trigger the workflow. But this could be handled by an automated action. |
I can give you another use case: having a delay between the creation of the SO and the automatic approval (real customer use case). IMO it's better to keep the cron because it also helps not to spawn useless jobs and to not add too much overhead on save or confirm or whatever action you want to hook to. |
|
Agreed. With the cron queuing the jobs, you can plan the load on your system. |
|
/ocabot merge nobump |
|
What a great day to merge this nice PR. Let's do it! |
|
@simahawk your merge command was aborted due to failed check(s), which you can inspect on this commit of 18.0-ocabot-merge-pr-3460-by-simahawk-bump-nobump. After fixing the problem, you can re-issue a merge command. Please refrain from merging manually as it will most probably make the target branch red. |
Use Queue Jobs to process the Sales Automatic Workflow actions. The default behavior of the automatic workflow module is to use a scheduled action that searches all the record that need a workflow action and sequentially process all of them. It can hit some limits when the number of records is too high. This module keeps the scheduled action to search the records, but instead of directly executing the actions (confirm a sales order, create invoices for a sales order, validate invoices, ...), it creates one job per operation to do. It uses an identity key on the jobs so it will not create the same job for the same record and same operation twice. ~ I needed to extract methods in `sale_automatic_workflow` in order to be able to execute them as jobs. A new decorator "job_auto_delay" (to eventually move in queue_job) makes these methods automatically delayed when called.
Currently translated at 100.0% (8 of 8 strings) Translation: sale-workflow-16.0/sale-workflow-16.0-sale_automatic_workflow_job Translate-URL: https://translation.odoo-community.org/projects/sale-workflow-16-0/sale-workflow-16-0-sale_automatic_workflow_job/es/
Currently translated at 100.0% (8 of 8 strings) Translation: sale-workflow-16.0/sale-workflow-16.0-sale_automatic_workflow_job Translate-URL: https://translation.odoo-community.org/projects/sale-workflow-16-0/sale-workflow-16-0-sale_automatic_workflow_job/it/
Currently translated at 100.0% (8 of 8 strings) Translation: sale-workflow-16.0/sale-workflow-16.0-sale_automatic_workflow_job Translate-URL: https://translation.odoo-community.org/projects/sale-workflow-16-0/sale-workflow-16-0-sale_automatic_workflow_job/it/
c4d794a to
c2fc43d
Compare
c2fc43d to
9893f3b
Compare
|
Ciao @simahawk, can you review and merge again? I have found that module |
|
/ocabot merge nobump |
|
This PR looks fantastic, let's merge it! |
|
Congratulations, your PR was merged at 4561ba4. Thanks a lot for contributing to OCA. ❤️ |
stockfromsale_automatic_workflow. I removed everything related tostock._do_validate_sale_orderwill be run in job, I add_do_send_order_confirmation_mailin job and it will be run after 2 minutessale_automatic_workflow, I have removed tagged inTestAutomaticWorkflow