Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0][ADD] queue_job_chunk: add module #737

Open
wants to merge 18 commits into
base: 16.0
Choose a base branch
from

Conversation

clementmbr
Copy link
Member

Adds the notion of queue job chunks, essentially a queue job with some metadata.
Useful to store the JSON received by an API request before their treatment in Odoo.

cc @florian-dacosta @kevinkhao @bealdav @sebastienbeau @rvalyi

@clementmbr
Copy link
Member Author

@bealdav following your suggestion I moved the PR OCA/sale-channel#20 to this repo.
@rvalyi I squashed the commit and cleaned history

@clementmbr clementmbr force-pushed the 16-add_queue_job_chunk branch from f76736b to df8afc2 Compare January 17, 2025 16:15
@clementmbr clementmbr marked this pull request as ready for review January 17, 2025 16:15
except RetryableJobError:
raise
except Exception as e:
if DEBUG_MODE:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kevinkhao coming back to your remark on the last PR, what do you mean by :
if "pdb" in config.get("dev_mode"): ?

I've never seen something like this, but I'll be happy to learn with an example!
Thanks!

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@clementmbr
odoo-bin --dev=pdb will evaluate to True

@rvalyi
Copy link
Member

rvalyi commented Jan 27, 2025

Adds the notion of queue job chunks, essentially a queue job with some metadata. Useful to store the JSON received by an API request before their treatment in Odoo.

cc @florian-dacosta @kevinkhao @bealdav @sebastienbeau @rvalyi

Hello, please pardon me if I'm wrong, but isn't it a bit the same idea of the split method that was merged recently in the queue_job module #658 ? If not, how does it differ?
In fact @paradoxxxzero even did a comment suggesting it was a bit similar in #658 (comment)

cc @sebastienbeau @simahawk @clementmbr

@clementmbr
Copy link
Member Author

@rvalyi

Hello, please pardon me if I'm wrong, but isn't it a bit the same idea of the split method that was merged recently in the queue_job module #658 ? If not, how does it differ?

From what I understand the main difference with @paradoxxxzero 's split() method is that the chunk allows a more in depth control of the incoming data, with the fields like data_str, state_info and the stack_trace in case of errors, which is vital when importing Sale Orders like in sale_import_base.

So it looks like different use cases.

@florian-dacosta
Copy link
Contributor

Yes, I think the goal here is not to use queue job directly because it is a very technical object.
I guess it is a bit in the same spirit than https://github.com/OCA/server-tools/tree/16.0/attachment_queue

We want to use queue job and all the machinery to run stuff automatically and all, but we want to have a separate object which allow to :

  • Have a dedicated menu, allowing to filter stuff and to make it more understandable to user than a queue.job
  • Avoid the deletion of the data after one month
  • Do not overcomplicate queue job object with new fields specific to one use case (as the payload received here between other stuff
  • Possibility to edit the payload in case of mistake
  • ...

Now, @rvalyi has a point... if it is not used to split jobs...why is it named queue_job_chunk? It does not really make sense.
Also, do we really want something so generic without other use cases presently ? Probably not.

I think this should be fully refactored doing the following :

  • Rename it sale_import_payload or something similar/more specific to its real current use case.
  • Rename the model accordingly
  • Move the menu to the "Sale App", probably with a new sale group
  • Change reference field by many2one toward sale.channel and remove obsolete field (like model_name, record_id, processor...
  • Make it more userfriendly (Show create_date, change order to display more recent first, add default filters (on create date, on payload, on error, maybe more ?),
  • Log changes on payload, maybe error also to have some history if the payload is retried...
  • Log a message on sale order when created from sale_import_payload so we can easily find which was the payload (and easily be sure that the sale order was created from a payload)
  • Move it back to sale_channel
  • Make a migraton script. Since the module will change name, I guess we can put a pre_init_hook, which will check if the old module was installed and do the migration if it is the case.
  • ... Maybe I forgot some stuff, but it can be improved more later

Nice to have but can wait I guess

  • Implement a configurable system to purge it, maybe with a default retention time of 1 year for instance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants