Skip to content

Conversation

@kobros-tech
Copy link
Contributor

@kobros-tech kobros-tech commented Jan 13, 2025

In this new feature, web client user can observe each sign request update in the status bar without needing to reload the page or even clicking on the pen icon.

Observe that event is sent only to scoped users who should sign on the new created sign request. and not for everybody.

@OCA-git-bot
Copy link
Contributor

Hi @etobella,
some modules you are maintaining are being modified, check this out!

@kobros-tech
Copy link
Contributor Author

@dnplkndll
@victoralmau
@ovnicraft
@pedrobaeza
@etobella

Hi guys, I need you to review this new feature, with which user can observe each sign request update in the status bar without needing to reload the page.

Observe that event is sent only to scoped users and not for everybody.

@pedrobaeza
Copy link
Member

You should explain the new feature on the commit message and PR description, and if it makes sense in this module or in a separate one.

@kobros-tech
Copy link
Contributor Author

You should explain the new feature on the commit message and PR description, and if it makes sense in this module or in a separate one.

@pedrobaeza
no worries this PR is not the new feature that I plan to add in a separate module.

The new one is to show sign requests to customers in the portal and to enable them to sign there.

For this PR feature, it is syncing changes instantly to backend users who are asked to sign and not everybody to save our servers from unnecessarily load.

@pedrobaeza
Copy link
Member

OK, that explanation is the one it should go in the commit message. Adding 2 new contributors seems too much for this change, isn't it? Then, there are weird changes in .po files that are not coming from your improvement and should be avoided.

@kobros-tech
Copy link
Contributor Author

OK, that explanation is the one it should go in the commit message. Adding 2 new contributors seems too much for this change, isn't it? Then, there are weird changes in .po files that are not coming from your improvement and should be avoided.

thanks, let me improve it all

@kobros-tech
Copy link
Contributor Author

@pedrobaeza

I have just added the 3 improvements that you requested from me, I can see the code in the PR is more clean and descriptive.

@victoralmau
Copy link
Member

Sorry, if I understood the enhancement correctly it should not be necessary to reload the page to update systray, but testing it does not work as expected.
ejemplo

Maybe I am forgetting something?

@kobros-tech
Copy link
Contributor Author

Sorry, if I understood the enhancement correctly it should not be necessary to reload the page to update systray, but testing it does not work as expected. ejemplo ejemplo

Maybe I am forgetting something?

@victoralmau

all right I will debug this.

could you try to create sign request from button in the template views?

@pedrobaeza
Copy link
Member

One thing is clear: a total reload of the single-page app shouldn't be done in any case.

@kobros-tech
Copy link
Contributor Author

@victoralmau
I need you to try this on chrome and on firefox

with me chrome was not listening to bus events, don't know why

@kobros-tech
Copy link
Contributor Author

One thing is clear: a total reload of the single-page app shouldn't be done in any case.

scenario is not to reload the page at all.

@dnplkndll
Copy link

One thing is clear: a total reload of the single-page app shouldn't be done in any case.

are there any other projects working with this concept of pushing the events to the clients over polling for changes? I was hoping to prove it out then move to a more generic approach as you would then be able to push render update events on much more expensive areas to re-render. or areas with a lot of subscribers

@kobros-tech
Copy link
Contributor Author

kobros-tech commented Jan 14, 2025

@pedrobaeza

Can we figure out whether or no OCA boat is using workers > 0, if they are 0 nobody can use OCA boat for reviewing this PR and will be reviewed locally with --workers=1

@pedrobaeza
Copy link
Member

@sbidoul should know if runboat can be run with multiple workers activating the bus.

@dnplkndll
Copy link

@pedrobaeza

Can we figure out whether or no OCA boat is using workers > 0, of they are 0 nobody can use OCA boat for review this PR and will be reviewed locally with --workers=1

https://github.com/sbidoul/runboat/blob/main/src/runboat/kubefiles/runboat-start.sh#L39

@sbidoul
Copy link
Member

sbidoul commented Jan 14, 2025

runboat runs in multithread mode (the default, --workers=0). Why is that a problem for this PR?

@pedrobaeza
Copy link
Member

I think the bus doesn't work with multi-threaded mode.

@kobros-tech
Copy link
Contributor Author

I think the bus doesn't work with multi-threaded mode.

workers should be 1 or more to be effective with this PR or any similar case.

@sbidoul
Copy link
Member

sbidoul commented Jan 14, 2025

I don't know what is special in this PR, but I tried chatting between two sessions on the same runboat database and it works, so I would assume the bus is functional on runboat.

I would say that if we have features that requires multi worker, this would need a big warning and/or something that prevent installing the module in multithread mode.

@dnplkndll
Copy link

since: odoo/odoo#191222
you would see a warning if not working right?

@victoralmau
Copy link
Member

Perhaps the way it is used in mail.activity can be useful https://github.com/odoo/odoo/blob/81bf1bab9bed9aa0780601d69a1c89942d92b657/addons/mail/models/mail_activity.py#L308

@kobros-tech
Copy link
Contributor Author

kobros-tech commented Jan 14, 2025

Perhaps the way it is used in mail.activity can be useful https://github.com/odoo/odoo/blob/81bf1bab9bed9aa0780601d69a1c89942d92b657/addons/mail/models/mail_activity.py#L308

In fact method used in the link is based on the method I used here, no lower level than what I provided.

I guess chatter is using bus as both methods should use bus module.

Comment on lines 334 to 340
partner_list_ids = partner_recs.mapped("id")
for partner_id in partner_list_ids:
self.env["bus.bus"]._sendone(
"broadcast",
f"sign_oca_request_updates_{partner_id}",
{"message": "Sign OCA Requests Model updated"},
)

Choose a reason for hiding this comment

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

Suggested change
partner_list_ids = partner_recs.mapped("id")
for partner_id in partner_list_ids:
self.env["bus.bus"]._sendone(
"broadcast",
f"sign_oca_request_updates_{partner_id}",
{"message": "Sign OCA Requests Model updated"},
)
partner_recs._bus_send(
"sign.oca.request/insert",
{}
)

Choose a reason for hiding this comment

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

  1. better not send to broadcast channel or all users will receive a notification
  2. you can use higher-level method _bus_send() method on partners (see here)
  3. maybe sign.oca.request itself could implement bus.listener.mixin to cover more events type?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What I am doing here is a uniqe notification sent to it related partner and not everybody.
Only partners related to the created request are in scope.

If you find something else in review, refer to me, please?

Choose a reason for hiding this comment

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

  • by sending your notification to the broadcast channel, all clients will receive it
  • if you're not convinced, you can inspect messages received by the websocket worker here: chrome://inspect/#workers
  • of course you are filtering client-side, but server-side would be better (by using the already existing partner channel)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, it sounds interesting to check

Comment on lines +347 to +348
partner_recs = record.signer_ids.mapped("partner_id")
self.notify_changes(partner_recs)

Choose a reason for hiding this comment

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

Suggested change
partner_recs = record.signer_ids.mapped("partner_id")
self.notify_changes(partner_recs)
partner_recs = records.signer_ids.mapped("partner_id")
self.notify_changes(partner_recs)

Copy link
Contributor Author

@kobros-tech kobros-tech Mar 23, 2025

Choose a reason for hiding this comment

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

@ nilshamerlinck
thanks, but there will be no change in code functionality or syntax.

Choose a reason for hiding this comment

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

if you create 2 sign.oca.request that involve same signers, isn't it better to send only one notification to each signer?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

creating two requests does not make sense.
only one is needed to be fully signed but better if some partner is not there we send him an email again.

we made a PR on that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Currently it is possible to create multiple requests at the same time, for example, through maintenance_sign_oca (although it can be done without this module).

test

Copy link
Member

@victoralmau victoralmau left a comment

Choose a reason for hiding this comment

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

@kobros-tech
Copy link
Contributor Author

@victoralmau
The talk here is about sending notification to users of new docs to be signed if they are opening the system, this update can only work with bus port working like --workers=2 when running odoo-bin.

It is not related to creating requests, but it can not be reviewed using OCA boat so better to have a solution of sending notifications without workers app.

@nilshamerlinck gave me suggestion but I need a suggestion to use same port 8069 instead of 8073 of workers, by the way only important notificatios are sent via 8069 but ordinary ones use 8073 port.

@victoralmau
Copy link
Member

@victoralmau The talk here is about sending notification to users of new docs to be signed if they are opening the system, this update can only work with bus port working like --workers=2 when running odoo-bin.

It is not related to creating requests, but it can not be reviewed using OCA boat so better to have a solution of sending notifications without workers app.

Sorry, but I don't understand the reason for having to configure what you indicate, in the previous examples (https://github.com/OCA/server-ux/blob/59205647d92f9c6c6ee955f1ae23d5f7b8b0409d/base_tier_validation/models/tier_validation.py#L784 + https://github.com/OCA/server-ux/blob/59205647d92f9c6c6ee955f1ae23d5f7b8b0409d/base_tier_validation/static/src/js/services/tier_review_service.esm.js#L14) it is not necessary to configure anything and it works correctly in oca boat for example.

@kobros-tech
Copy link
Contributor Author

@victoralmau The talk here is about sending notification to users of new docs to be signed if they are opening the system, this update can only work with bus port working like --workers=2 when running odoo-bin.
It is not related to creating requests, but it can not be reviewed using OCA boat so better to have a solution of sending notifications without workers app.

Sorry, but I don't understand the reason for having to configure what you indicate, in the previous examples (https://github.com/OCA/server-ux/blob/59205647d92f9c6c6ee955f1ae23d5f7b8b0409d/base_tier_validation/models/tier_validation.py#L784 + https://github.com/OCA/server-ux/blob/59205647d92f9c6c6ee955f1ae23d5f7b8b0409d/base_tier_validation/static/src/js/services/tier_review_service.esm.js#L14) it is not necessary to configure anything and it works correctly in oca boat for example.

this also looks interesting, and I must check

@kobros-tech
Copy link
Contributor Author

@nilshamerlinck
@victoralmau

your suggestions were useful to reduce code, it is ok to use one single common channel to send notification as the update will apply on the partners who should sign because large workers need large processors.

I can run the module when workers=1 but not less although I use the same method that you suggest it did not apply with workers=0

Copy link
Member

@victoralmau victoralmau left a comment

Choose a reason for hiding this comment

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

IMO it does not work as it should, the icon in the upper right corner with the total number of signatures pending is not updated (it is necessary to reload the page for it to work properly).

ejemplo

@kobros-tech
Copy link
Contributor Author

IMO it does not work as it should, the icon in the upper right corner with the total number of signatures pending is not updated (it is necessary to reload the page for it to work properly).

ejemplo ejemplo

Did you test it on run boat? It will not work on run boat unless there is a value for workers > 0.

I applied your suggestion although it needs a value for workers similar to the low level method I used before.

@victoralmau
Copy link
Member

Yes, it may work in runboat. You can check base_tier_validation https://github.com/OCA/server-ux/tree/18.0/base_tier_validation (I initially indicated that module as an example where it is implemented and works correctly). although to check it functionally, you will have to do so with sale_tier_validation https://github.com/OCA/sale-workflow/tree/18.0/sale_tier_validation

@dnplkndll
Copy link

@kobros-tech did this feature with event update over refresh prove valuable? can is be used in other place or in a more general way?

@kobros-tech
Copy link
Contributor Author

@kobros-tech did this feature with event update over refresh prove valuable? can is be used in other place or in a more general way?

if you plan to use same feature we can think to make a base module, but it needs smart implementation.

not sure but all what I have done I was not sure about before I start.

@github-actions
Copy link

There hasn't been any activity on this pull request in the past 4 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days.
If you want this PR to never become stale, please ask a PSC member to apply the "no stale" label.

@github-actions github-actions bot added the stale label Dec 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants