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

[10.0][MIG] migrate module mail_forward #256

Merged
merged 2 commits into from
Jul 9, 2018

Conversation

ecino
Copy link
Contributor

@ecino ecino commented Apr 12, 2018

This takes the module mail_forward that was available in version 8.0 and updates it in order to work on version 10.0

@ecino ecino mentioned this pull request Apr 12, 2018
21 tasks
------------

* Emanuel Cino <ecino@compassion.ch>
* Jairo Llopis <j.llopis@grupoesoc.es>
Copy link
Member

Choose a reason for hiding this comment

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

Please change the author to the new company: jairo.llopis@tecnativa.com

"version": "10.0.1.0.0",
"category": "Social Network",
"website": "https://grupoesoc.es",
"author": "Grupo ESOC Ingeniería de Servicios, "
Copy link
Member

Choose a reason for hiding this comment

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

Change also the company to the new one: Tecnativa

@pedrobaeza pedrobaeza added this to the 10.0 milestone Apr 12, 2018
@ecino ecino force-pushed the 10.0-mig-mail_forward branch 4 times, most recently from 903f39e to d6f188a Compare April 13, 2018 14:03
Copy link
Member

@rafaelbn rafaelbn left a comment

Choose a reason for hiding this comment

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

Hi @ecino , thank!

I've tested and it work fine just one thing you should fix. After fordward the message, the chatter is not refreshed and user have to press F5... I think chatter should be refreshed in the same way that sending a new message happends

Let me know please

Thanks

@ecino
Copy link
Contributor Author

ecino commented Apr 16, 2018

@rafaelbn I added the functionnality in cac0a83.
However I'm not sure it's the most efficient way to refresh, as I'm not familiar with what is available in the javascript functions of the mail module. This requires as well #257 to work, because it uses the chat_manager.make_message function.
But in the end, it does what you suggested.

@ecino
Copy link
Contributor Author

ecino commented Apr 24, 2018

@rafaelbn The module is now working with #257 being merged.

Copy link
Member

@rafaelbn rafaelbn left a comment

Choose a reason for hiding this comment

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

Tested in runbot functionally 👍

"summary": "Add option to forward messages",
"version": "10.0.1.0.0",
"category": "Social Network",
"website": "https://grupoesoc.es",
Copy link
Member

Choose a reason for hiding this comment

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

"version": "10.0.1.0.0",
"category": "Social Network",
"website": "https://grupoesoc.es",
"author": "Odoo Community Association (OCA)"
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

@rafaelbn rafaelbn left a comment

Choose a reason for hiding this comment

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

Please @yajo as original author review this migration. Thanks!

Contributors
------------

* Emanuel Cino <ecino@compassion.ch>
Copy link
Member

Choose a reason for hiding this comment

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

@ecino you should add you name after older contributors and not before

Copy link
Member

@rafaelbn rafaelbn left a comment

Choose a reason for hiding this comment

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

Please @ecino check my comments. Thank you!

@ecino
Copy link
Contributor Author

ecino commented Apr 27, 2018

@rafaelbn Thanks for reviewing it. Corrections are done.

@api.one
@api.multi
def send_mail_action(self):
return self.send_mail()
Copy link
Member

Choose a reason for hiding this comment

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

Remove this method.

} else if (subject.length < 2) {
subject.push(_t("(No subject)"));
}
MessageModel.call('read', [message_id, read_fields], {context: session.user_context}).then(function (result) {
Copy link
Member

Choose a reason for hiding this comment

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

Please put this into a separate, proxied, class-level method.

Just for inheritance/maintainability. 😉

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure what you mean by proxied method. I'm no javascript expert, I just ported the module to v10.

this.trigger("message_forward", message_id);
};
},
thread_reload: function(){
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure I like this new feature.

I did a test from the Odoo inbox forwarding to a different object... If you are forwarding to a different object, why to reload? It should never get displayed...

It moves me above in the message list if I was browsing somewhere below, and clears the messages. Well... it's a confusing behavior.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@rafaelbn originally requested this feature. As I said, I'm no javascript expert so maybe I did not implement it the best way. Anyway I would need help to improve javascript.

@yajo
Copy link
Member

yajo commented Apr 27, 2018

I tested on runbot.

I go to events, and try to forward one message to another event. Events model don't appear in the dropdown list. Is this intentional?

Copy link
Contributor

@AaronHForgeFlow AaronHForgeFlow left a comment

Choose a reason for hiding this comment

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

Tested on runbot and worked fine. Installed Sales and can forwarded messages between different SO successfully. However I don't see Even't models. Maybe it's been filtered somewhere. Can you check?

@ecino
Copy link
Contributor Author

ecino commented Jun 4, 2018

Hi @aheficent, sorry for the delay of my answer. You should add the Event model in the referenceable models (see the README of the module). You find the menu in Admin Settings -> Technical -> Database Structure -> Referenceable Models

@yajo
Copy link
Member

yajo commented Jun 4, 2018

Yikes! that was in the README! Bad me for not reading myself 😆

OK, then all you need to do is fix that ❌ in Travis. The JS improvements are needed, yes, but that can be done later.

Thanks!

@AaronHForgeFlow
Copy link
Contributor

Thank you for your reply @ecino

I'm getting an error when forwarding messages between events. The trace:

File "/home/odoo/odoo-10.0/addons/web/controllers/main.py", line 896, in call_button
action = self._call_kw(model, method, args, {})
File "/home/odoo/odoo-10.0/addons/web/controllers/main.py", line 884, in _call_kw
return call_kw(request.env[model], method, args, kwargs)
File "/.repo_requirements/odoo/odoo/api.py", line 685, in call_kw
method = getattr(type(model), name)
AttributeError: type object 'mail_forward.compose_message' has no attribute 'send_mail_action'

@ecino
Copy link
Contributor Author

ecino commented Jun 4, 2018

Oops, that was after I removed the method as suggested by @yajo. It looks like the method is needed, so I will add it again. I will tell you when it's done.

@ecino
Copy link
Contributor Author

ecino commented Jun 29, 2018

The pull request is ready to go. Travis errors should be fixed with #288

@yajo
Copy link
Member

yajo commented Jul 2, 2018

Then please rebase to get those changes; right now bots are ❌

@ecino
Copy link
Contributor Author

ecino commented Jul 2, 2018

@yajo , successfully rebased, everything looks good. ✔️

Copy link
Member

@yajo yajo left a comment

Choose a reason for hiding this comment

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

I tested on runbot:

  1. In messages view, clicking on the ⭐ or ✔️ icons, has no effect

  2. When forwarding message to a partner, an error appears:

    Odoo Server Error
    
    Traceback (most recent call last):
      File "/.repo_requirements/odoo/odoo/http.py", line 642, in _handle_exception
        return super(JsonRequest, self)._handle_exception(exception)
      File "/.repo_requirements/odoo/odoo/http.py", line 684, in dispatch
        result = self._call_function(**self.params)
      File "/.repo_requirements/odoo/odoo/http.py", line 334, in _call_function
        return checked_call(self.db, *args, **kwargs)
      File "/.repo_requirements/odoo/odoo/service/model.py", line 101, in wrapper
        return f(dbname, *args, **kwargs)
      File "/.repo_requirements/odoo/odoo/http.py", line 327, in checked_call
        result = self.endpoint(*a, **kw)
      File "/.repo_requirements/odoo/odoo/http.py", line 942, in __call__
        return self.method(*args, **kw)
      File "/.repo_requirements/odoo/odoo/http.py", line 507, in response_wrap
        response = f(*args, **kw)
      File "/home/odoo/odoo-10.0/addons/web/controllers/main.py", line 896, in call_button
        action = self._call_kw(model, method, args, {})
      File "/home/odoo/odoo-10.0/addons/web/controllers/main.py", line 884, in _call_kw
        return call_kw(request.env[model], method, args, kwargs)
      File "/.repo_requirements/odoo/odoo/api.py", line 685, in call_kw
        method = getattr(type(model), name)
    AttributeError: type object 'mail_forward.compose_message' has no attribute 'send_mail_action'
    

@ecino
Copy link
Contributor Author

ecino commented Jul 2, 2018

Maybe I dropped something during the rebase, sorry about that. I'll check it and let you know when it's fixed. Thanks for double checking it.

@ecino
Copy link
Contributor Author

ecino commented Jul 5, 2018

@yajo How do you access the runbot? I cannot find how to launch it, I just see the build logs.

@yajo
Copy link
Member

yajo commented Jul 5, 2018

There it is:

peek 2018-07-05 13-03

@ecino
Copy link
Contributor Author

ecino commented Jul 5, 2018

@yajo I fixed the forward bug (method send_action was not to be removed). However your other issues with the star and check icons seem not related with this module. I checked on the current runbot of the branch 10.0 and the same issue happens.

Copy link
Member

@rafaelbn rafaelbn left a comment

Choose a reason for hiding this comment

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

Tested again functionally 👍

@antoniocanovas
Copy link

Tested functionality

@pedrobaeza
Copy link
Member

@yajo please update your review


@api.multi
def send_mail_action(self):
return self.send_mail()
Copy link
Member

Choose a reason for hiding this comment

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

Why to declare 2 methods to do the same? Am I missing something? 🤔 Otherwise, remove one of them please. 😉

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The way odoo mail_compose_message is done works the same, if we don't declare them it will fail. I tried to remove this one but then it fails.

Copy link
Member

Choose a reason for hiding this comment

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

OK, I see now. However, you are repeating here the same code as upstream, so it still makes no sense that it fails... (You should only override a method if anything changes)

Besides, it breaks inheritance too. In case this were needed, it should be:

return super(MailComposeMessage, self).send_mail()

Could you double-check this please?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I know it's weird but when I removed that send_mail_action method, Travis was failing so I don't know why but this method is needed. If I do as you suggest, we will bypass our send_mail method which is not good. The other solution I can do is to call super of send_mail_action. I know the code seems weird to only call super method but if you want me I can remove it again and you will see by yourself that tests are failing without it.

Copy link
Member

Choose a reason for hiding this comment

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

Oh snap, excuse me! It was right as it was. I didn't realize this was a _inherits model, not an _inherit one.

This kind of inheritance inherits fields, but not methods. Possibly calling super() will not work, and the correct code is the one you had indeed.

Just please add a comment similar to upstream's, so reviewers can understand the reasoning behind that code.

Thanks, and sorry!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No worries, I didn't know as well that _inherits don't inherit the methods. Now it's clear why it's needed. I added the comment and restore the previous version. Thanks for your review.

@ecino ecino force-pushed the 10.0-mig-mail_forward branch 2 times, most recently from 2a8533e to cd66216 Compare July 9, 2018 07:43
Copy link
Member

@yajo yajo left a comment

Choose a reason for hiding this comment

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

Awesome, thanks!

@pedrobaeza pedrobaeza merged commit 15d2e40 into OCA:10.0 Jul 9, 2018
@ecino ecino deleted the 10.0-mig-mail_forward branch March 4, 2020 14:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants