[18.0][IMP] edi_core_oca: add listener action#232
[18.0][IMP] edi_core_oca: add listener action#232ArnauCForgeFlow wants to merge 2 commits intoOCA:18.0from
Conversation
0bc4d2e to
7a14077
Compare
|
@simahawk Thanks for the review! So, basically, your suggestion is moving the helper method _trigger_edi_event_make_name from the component module to the core, and then simply calling the _trigger_edi_event hook from the other modules? |
yes. And we should move the hook to the consumer mixin so that the logic won't be put into generic models like exc record. |
The problem with moving the hook to the consumer mixin is that for input exchanges that fail early, there is no record_id yet. For example, in edi_storage_oca, even if the process fails, we still need to execute the hook to move the file from 'pending' directory to 'error' directory. Any idea on how to handle this? Thanks! |
|
@ArnauCForgeFlow good point. Well, that's why components have been used so far 😄 A possible approach is the one I took on endpoint_route_handler to check cross models that we wouldn't have any routing conflict. See https://github.com/OCA/web-api/blob/18.0/endpoint_route_handler/models/endpoint_route_handler.py#L90 We could collect all models inheriting from consumer mixin and trigger their handlers if any. WDYT? |
|
Answering myself: this can lead to overlapping handlers as you could have the same hook for different exchanges. Could we leverage |
|
Hi @simahawk Thanks for the suggestion! I've been looking into the edi.configuration approach, but to be honest, I'm a bit lost, so I'd love a bit more context on the implementation details.
Any quick example or guidance would be appreciated. Thanks! |
|
All starts with notify_action_complete. This must be called all the times an "official" action is done. There we should trigger the event an all related records and all consumer models. Hence, for related records, we should do what is done already for state change, create and write https://github.com/OCA/edi-framework/blob/18.0/edi_core_oca/models/edi_exchange_consumer_mixin.py#L449 When we don't have a record, we have to decide how to lookup for edi.confg. Today we always rely on a m2m relation via partner (we have a m2m relation to be able to reuse configs). We should probably state which configs are meant to run globally for a given model (eg: w/ a flag I hope it's clear. Otherwise we can organize a call 😉 |
Move _trigger_edi_event_make_name method to edi_core_oca module in order to make the listener usable without requiring the edi_component_oca module