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

[ADD][crm_phonecall_planner] Phonecall autoscheduler #174

Merged
merged 8 commits into from
Mar 12, 2018

Conversation

yajo
Copy link
Member

@yajo yajo commented Sep 20, 2017

A simple to use wizard that generates phonecall plannings under given criteria.

See README for further details.

WIP until:

@Tecnativa

A simple to use wizard that generates phonecall plannings under given criteria.
@yajo yajo self-assigned this Sep 20, 2017
@yajo yajo added this to the 9.0 milestone Sep 20, 2017
@yajo yajo requested a review from rafaelbn September 20, 2017 12:27
Usage
=====

To use this module, you need to specify your partners' preferred phone call
Copy link
Member

Choose a reason for hiding this comment

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

Put this paragraph on "Configuration" section.

Funders
-------

The development of this module has been financially supported by:
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 as it's not actually true (this is for final customers).

Copy link
Member

Choose a reason for hiding this comment

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

Maybe we can propose a change in the template for grouping contributors by company, putting something like:

* Tecnativa (https://www.tecnativa.com)
  * Jairo Llopis <option e-mail>
...

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

* Jairo Llopis <jairo.llopis@tecnativa.com>
Copy link
Member

Choose a reason for hiding this comment

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

Put here Tecnativa URL

from openerp.tests.common import SavepointCase


class SomethingCase(SavepointCase):
Copy link
Member

Choose a reason for hiding this comment

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

SomethingCase?

)
duration = fields.Float(
string="Call duration",
default=lambda self: self._default_duration(),
Copy link
Member

Choose a reason for hiding this comment

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

Don't do this, but move to up the default method and just put default=_default_duration (without quotes in the method).

Copy link
Member Author

Choose a reason for hiding this comment

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

Nope, check the guidelines: https://github.com/OCA/maintainer-tools/blob/master/CONTRIBUTING.md#fields

(same in comments below)

Copy link
Member

Choose a reason for hiding this comment

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

I think this guideline is deprecated. Have you tried to inherit now in v9/v10 directly the method to see if it works?

Copy link
Member Author

Choose a reason for hiding this comment

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

Well, I remember to have tried in the past with a core model that defined a lambda, and I had to redefine the field just to override the default method.

The problem when you do default=_default_duration is that you bind directly the function code object. By using a lambda, you bind directly the lambda code, but inside it you have the benefits of all the inheritance system. That's the reason behind that guideline.

Other field attributes, such as compute or search, accept a string that defines the method name and make this wrapper automatically, but in default that system is not available, since passing a string would use that string as the default value instead, so the lambda callback wrapper is the best choice here AFAIK.

Copy link
Member

Choose a reason for hiding this comment

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

OK, yes, it makes sense


@api.constrains("start", "end")
def _constrains_plan_dates(self):
if self.start > self.end:
Copy link
Member

Choose a reason for hiding this comment

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

You have to make it multi-record aware


@api.multi
def _schedule_call(self, partner, when):
call = self.env["crm.phonecall"]
Copy link
Member

Choose a reason for hiding this comment

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

To reduce cyclomatic complexity, do:

if not partner:
    return self.env["crm.phonecall"]
_logger.debug(
...

Copy link
Member Author

Choose a reason for hiding this comment

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

I think I'll just remove the returned value, it's not used after all.

@OCA OCA deleted a comment from pedrobaeza Sep 25, 2017
@yajo
Copy link
Member Author

yajo commented Sep 25, 2017

This is testable now.

@rafaelbn
Copy link
Member

Hi @yajo ,

In this use case I get an error:

2017-09-25_15-03-53

Odoo Server Error

Traceback (most recent call last):
  File "/.repo_requirements/odoo/openerp/http.py", line 650, in _handle_exception
    return super(JsonRequest, self)._handle_exception(exception)
  File "/.repo_requirements/odoo/openerp/http.py", line 687, in dispatch
    result = self._call_function(**self.params)
  File "/.repo_requirements/odoo/openerp/http.py", line 323, in _call_function
    return checked_call(self.db, *args, **kwargs)
  File "/.repo_requirements/odoo/openerp/service/model.py", line 118, in wrapper
    return f(dbname, *args, **kwargs)
  File "/.repo_requirements/odoo/openerp/http.py", line 316, in checked_call
    result = self.endpoint(*a, **kw)
  File "/.repo_requirements/odoo/openerp/http.py", line 966, in __call__
    return self.method(*args, **kw)
  File "/.repo_requirements/odoo/openerp/http.py", line 516, in response_wrap
    response = f(*args, **kw)
  File "/home/odoo/odoo-9.0/addons/web/controllers/main.py", line 899, in call_button
    action = self._call_kw(model, method, args, {})
  File "/home/odoo/odoo-9.0/addons/web/controllers/main.py", line 887, in _call_kw
    return getattr(request.registry.get(model), method)(request.cr, request.uid, *args, **kwargs)
  File "/.repo_requirements/odoo/openerp/api.py", line 250, in wrapper
    return old_api(self, *args, **kwargs)
  File "/.repo_requirements/odoo/openerp/api.py", line 381, in old_api
    result = method(recs, *args, **kwargs)
  File "/home/odoo/build/OCA/crm/crm_phonecall_planner/wizards/crm_phonecall_planner.py", line 128, in action_accept
    partner_domain = safe_eval(self.res_partner_domain) + [
  File "/.repo_requirements/odoo/openerp/tools/convert.py", line 36, in <lambda>
    safe_eval = lambda expr, ctx={}: s_eval(expr, ctx, nocopy=True)
  File "/.repo_requirements/odoo/openerp/tools/safe_eval.py", line 296, in safe_eval
    c = test_expr(expr, _SAFE_OPCODES, mode=mode)
  File "/.repo_requirements/odoo/openerp/tools/safe_eval.py", line 152, in test_expr
    expr = expr.strip()
ValueError: "'bool' object has no attribute 'strip'" while compiling
False
```

Maybe we should give a message why we cannot generate this planning

@rafaelbn
Copy link
Member

Hi @yajo ,
In other use case like this one we also need a message about what's wrong:

2017-09-25_15-06-59

Thanks

@yajo
Copy link
Member Author

yajo commented Sep 26, 2017

#174 (comment) happened when domain was empty, it should be fixed now.

#174 (comment) happens because the incompatible crm_phonecall_summary_predefined addon is installed. This addon changes dramatically the way crm.phonecall object behaves without providing a proper compatibility, so it's not this PR's problem. I added a note in known issues. Remove it and test please. 😉

@yajo
Copy link
Member Author

yajo commented Sep 27, 2017

This should go 100% coverage now.

Copy link
Member

@chienandalu chienandalu left a comment

Choose a reason for hiding this comment

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

Seems to work ok in runbot.

(I had to uninstall crm_phonecall_summary_predefined and the update this module to refresh the phonecall model)

@yajo
Copy link
Member Author

yajo commented Sep 29, 2017

@pedrobaeza @rafaelbn please update your reviews

@rafaelbn
Copy link
Member

rafaelbn commented Sep 29, 2017

Hi @yajo:

Imagine you have a Phone call Schedule for:

  • Tuesday from 09:00 to 14:00
  • Thursday from 09:00 to 14:00

This are all the posibilities for Octobre 2017

  • 10/03/2017 09:00:00
  • 10/05/2017 09:00:00
  • 10/10/2017 09:00:00
  • 10/12/2017 09:00:00
  • 10/17/2017 09:00:00
  • 10/19/2017 09:00:00
  • 10/24/2017 09:00:00
  • 10/26/2017 09:00:00
  • 10/31/2017 08:00:00

And you would like you would like to plan call for every tuesday in october.

  • How to do it? (for this opcion I expect only to lunch plannner/wizard one (1) time maximun)

  • Day gap refers to the schedule o to the Worktime of the company?

  • Which is the worktime of the company? Some companies work from monday to friday, some from monday to satudady morning, some from monday to saturday, some every day, some from sunday to thursday, some from friday to sunday, etc... So please could you add in README, which schedule take in care day gap?

  • If you have a Schedule every day from monday to friday from 9:00 to 17:00. How to schedule for October every tuesday and thursday? (for this opcion I expect only to lunch plannner/wizar two times maximun).

Thanks

@chienandalu
Copy link
Member

@yajo Maybe to achieve what @rafaelbn asks, the possibility of choosing an attending schedule that'd crop against the availability partner schedules would fit here and give way more flexibility.

@yajo
Copy link
Member Author

yajo commented Sep 29, 2017

Day gap is only the amount of calendar days you are going to leave your target callee with no calls in between.

The easiest way to fix all your concerns would be just adding 7 checkboxes (one per week day) and let the user choose what week days to include in the planning, since the working daytime is chosen by the user directly in the wizard (no need to consult company or user working schedule).

However my concern is if this is a real use case... To begin, it makes no sense to record that your customer expects to be contacted on Sundays if you're never going to call him on Sundays, don't you think?

@yajo
Copy link
Member Author

yajo commented Oct 18, 2017

So can this be merged as is and leave the rest of improvements for future iterations?

will try to schedule before all the partners that you never called under
current **criteria combination**, but if none is found it will repeat calls for
such **criteria combination** if last call was done before the minimum
*Days gap* you specified.
Copy link
Member

Choose a reason for hiding this comment

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

I don't undestand this paragraph 😢

…r] Phonecall autoscheduler

Reword weird paragraph
@yajo
Copy link
Member Author

yajo commented Oct 25, 2017

Better now @rafaelbn ?

@yajo yajo requested a review from rafaelbn January 17, 2018 09:22
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.

👍 ready thank!

@rafaelbn rafaelbn merged commit 73a3af8 into OCA:9.0 Mar 12, 2018
@rafaelbn rafaelbn deleted the 9.0-crm_phonecall_plan branch March 12, 2018 12:52
chienandalu pushed a commit to Tecnativa/crm that referenced this pull request Jul 12, 2018
* [ADD][crm_phonecall_planner] Phonecall autoscheduler

A simple to use wizard that generates phonecall plannings under given criteria.

* fixup! [ADD][crm_phonecall_planner] Phonecall autoscheduler

* fixup! fixup! [ADD][crm_phonecall_planner] Phonecall autoscheduler

* fixup! fixup! fixup! [ADD][crm_phonecall_planner] Phonecall autoscheduler

* fixup! fixup! fixup! fixup! [ADD][crm_phonecall_planner] Phonecall autoscheduler

* fixup! fixup! fixup! fixup! fixup! [ADD][crm_phonecall_planner] Phonecall autoscheduler

* fixup! fixup! fixup! fixup! fixup! fixup! [ADD][crm_phonecall_planner] Phonecall autoscheduler

*  fixup! fixup! fixup! fixup! fixup! fixup! [ADD][crm_phonecall_planner] Phonecall autoscheduler

Reword weird paragraph
chienandalu pushed a commit to Tecnativa/crm that referenced this pull request Sep 11, 2018
* [ADD][crm_phonecall_planner] Phonecall autoscheduler

A simple to use wizard that generates phonecall plannings under given criteria.

* fixup! [ADD][crm_phonecall_planner] Phonecall autoscheduler

* fixup! fixup! [ADD][crm_phonecall_planner] Phonecall autoscheduler

* fixup! fixup! fixup! [ADD][crm_phonecall_planner] Phonecall autoscheduler

* fixup! fixup! fixup! fixup! [ADD][crm_phonecall_planner] Phonecall autoscheduler

* fixup! fixup! fixup! fixup! fixup! [ADD][crm_phonecall_planner] Phonecall autoscheduler

* fixup! fixup! fixup! fixup! fixup! fixup! [ADD][crm_phonecall_planner] Phonecall autoscheduler

*  fixup! fixup! fixup! fixup! fixup! fixup! [ADD][crm_phonecall_planner] Phonecall autoscheduler

Reword weird paragraph
sergio-teruel pushed a commit to Tecnativa/crm that referenced this pull request Sep 17, 2018
* [ADD][crm_phonecall_planner] Phonecall autoscheduler

A simple to use wizard that generates phonecall plannings under given criteria.

* fixup! [ADD][crm_phonecall_planner] Phonecall autoscheduler

* fixup! fixup! [ADD][crm_phonecall_planner] Phonecall autoscheduler

* fixup! fixup! fixup! [ADD][crm_phonecall_planner] Phonecall autoscheduler

* fixup! fixup! fixup! fixup! [ADD][crm_phonecall_planner] Phonecall autoscheduler

* fixup! fixup! fixup! fixup! fixup! [ADD][crm_phonecall_planner] Phonecall autoscheduler

* fixup! fixup! fixup! fixup! fixup! fixup! [ADD][crm_phonecall_planner] Phonecall autoscheduler

*  fixup! fixup! fixup! fixup! fixup! fixup! [ADD][crm_phonecall_planner] Phonecall autoscheduler

Reword weird paragraph
Tardo pushed a commit to Tecnativa/crm that referenced this pull request Oct 25, 2019
* [ADD][crm_phonecall_planner] Phonecall autoscheduler

A simple to use wizard that generates phonecall plannings under given criteria.

* fixup! [ADD][crm_phonecall_planner] Phonecall autoscheduler

* fixup! fixup! [ADD][crm_phonecall_planner] Phonecall autoscheduler

* fixup! fixup! fixup! [ADD][crm_phonecall_planner] Phonecall autoscheduler

* fixup! fixup! fixup! fixup! [ADD][crm_phonecall_planner] Phonecall autoscheduler

* fixup! fixup! fixup! fixup! fixup! [ADD][crm_phonecall_planner] Phonecall autoscheduler

* fixup! fixup! fixup! fixup! fixup! fixup! [ADD][crm_phonecall_planner] Phonecall autoscheduler

*  fixup! fixup! fixup! fixup! fixup! fixup! [ADD][crm_phonecall_planner] Phonecall autoscheduler

Reword weird paragraph
Tardo pushed a commit to Tecnativa/crm that referenced this pull request Apr 14, 2020
* [ADD][crm_phonecall_planner] Phonecall autoscheduler

A simple to use wizard that generates phonecall plannings under given criteria.

* fixup! [ADD][crm_phonecall_planner] Phonecall autoscheduler

* fixup! fixup! [ADD][crm_phonecall_planner] Phonecall autoscheduler

* fixup! fixup! fixup! [ADD][crm_phonecall_planner] Phonecall autoscheduler

* fixup! fixup! fixup! fixup! [ADD][crm_phonecall_planner] Phonecall autoscheduler

* fixup! fixup! fixup! fixup! fixup! [ADD][crm_phonecall_planner] Phonecall autoscheduler

* fixup! fixup! fixup! fixup! fixup! fixup! [ADD][crm_phonecall_planner] Phonecall autoscheduler

*  fixup! fixup! fixup! fixup! fixup! fixup! [ADD][crm_phonecall_planner] Phonecall autoscheduler

Reword weird paragraph
Tardo pushed a commit to Tecnativa/crm that referenced this pull request May 20, 2020
* [ADD][crm_phonecall_planner] Phonecall autoscheduler

A simple to use wizard that generates phonecall plannings under given criteria.

* fixup! [ADD][crm_phonecall_planner] Phonecall autoscheduler

* fixup! fixup! [ADD][crm_phonecall_planner] Phonecall autoscheduler

* fixup! fixup! fixup! [ADD][crm_phonecall_planner] Phonecall autoscheduler

* fixup! fixup! fixup! fixup! [ADD][crm_phonecall_planner] Phonecall autoscheduler

* fixup! fixup! fixup! fixup! fixup! [ADD][crm_phonecall_planner] Phonecall autoscheduler

* fixup! fixup! fixup! fixup! fixup! fixup! [ADD][crm_phonecall_planner] Phonecall autoscheduler

*  fixup! fixup! fixup! fixup! fixup! fixup! [ADD][crm_phonecall_planner] Phonecall autoscheduler

Reword weird paragraph
redapureskill pushed a commit to redapureskill/crm that referenced this pull request Jun 1, 2021
* [ADD][crm_phonecall_planner] Phonecall autoscheduler

A simple to use wizard that generates phonecall plannings under given criteria.

* fixup! [ADD][crm_phonecall_planner] Phonecall autoscheduler

* fixup! fixup! [ADD][crm_phonecall_planner] Phonecall autoscheduler

* fixup! fixup! fixup! [ADD][crm_phonecall_planner] Phonecall autoscheduler

* fixup! fixup! fixup! fixup! [ADD][crm_phonecall_planner] Phonecall autoscheduler

* fixup! fixup! fixup! fixup! fixup! [ADD][crm_phonecall_planner] Phonecall autoscheduler

* fixup! fixup! fixup! fixup! fixup! fixup! [ADD][crm_phonecall_planner] Phonecall autoscheduler

*  fixup! fixup! fixup! fixup! fixup! fixup! [ADD][crm_phonecall_planner] Phonecall autoscheduler

Reword weird paragraph
cesar-tecnativa pushed a commit to Tecnativa/crm that referenced this pull request Jun 2, 2022
* [ADD][crm_phonecall_planner] Phonecall autoscheduler

A simple to use wizard that generates phonecall plannings under given criteria.

* fixup! [ADD][crm_phonecall_planner] Phonecall autoscheduler

* fixup! fixup! [ADD][crm_phonecall_planner] Phonecall autoscheduler

* fixup! fixup! fixup! [ADD][crm_phonecall_planner] Phonecall autoscheduler

* fixup! fixup! fixup! fixup! [ADD][crm_phonecall_planner] Phonecall autoscheduler

* fixup! fixup! fixup! fixup! fixup! [ADD][crm_phonecall_planner] Phonecall autoscheduler

* fixup! fixup! fixup! fixup! fixup! fixup! [ADD][crm_phonecall_planner] Phonecall autoscheduler

*  fixup! fixup! fixup! fixup! fixup! fixup! [ADD][crm_phonecall_planner] Phonecall autoscheduler

Reword weird paragraph
cesar-tecnativa pushed a commit to Tecnativa/crm that referenced this pull request Jun 8, 2022
* [ADD][crm_phonecall_planner] Phonecall autoscheduler

A simple to use wizard that generates phonecall plannings under given criteria.

* fixup! [ADD][crm_phonecall_planner] Phonecall autoscheduler

* fixup! fixup! [ADD][crm_phonecall_planner] Phonecall autoscheduler

* fixup! fixup! fixup! [ADD][crm_phonecall_planner] Phonecall autoscheduler

* fixup! fixup! fixup! fixup! [ADD][crm_phonecall_planner] Phonecall autoscheduler

* fixup! fixup! fixup! fixup! fixup! [ADD][crm_phonecall_planner] Phonecall autoscheduler

* fixup! fixup! fixup! fixup! fixup! fixup! [ADD][crm_phonecall_planner] Phonecall autoscheduler

*  fixup! fixup! fixup! fixup! fixup! fixup! [ADD][crm_phonecall_planner] Phonecall autoscheduler

Reword weird paragraph
mathieudelva pushed a commit to mathieudelva/crm that referenced this pull request Nov 18, 2022
* [ADD][crm_phonecall_planner] Phonecall autoscheduler

A simple to use wizard that generates phonecall plannings under given criteria.

* fixup! [ADD][crm_phonecall_planner] Phonecall autoscheduler

* fixup! fixup! [ADD][crm_phonecall_planner] Phonecall autoscheduler

* fixup! fixup! fixup! [ADD][crm_phonecall_planner] Phonecall autoscheduler

* fixup! fixup! fixup! fixup! [ADD][crm_phonecall_planner] Phonecall autoscheduler

* fixup! fixup! fixup! fixup! fixup! [ADD][crm_phonecall_planner] Phonecall autoscheduler

* fixup! fixup! fixup! fixup! fixup! fixup! [ADD][crm_phonecall_planner] Phonecall autoscheduler

*  fixup! fixup! fixup! fixup! fixup! fixup! [ADD][crm_phonecall_planner] Phonecall autoscheduler

Reword weird paragraph
SoporteOperu pushed a commit to SoporteOperu/crm that referenced this pull request May 22, 2023
* [ADD][crm_phonecall_planner] Phonecall autoscheduler

A simple to use wizard that generates phonecall plannings under given criteria.

* fixup! [ADD][crm_phonecall_planner] Phonecall autoscheduler

* fixup! fixup! [ADD][crm_phonecall_planner] Phonecall autoscheduler

* fixup! fixup! fixup! [ADD][crm_phonecall_planner] Phonecall autoscheduler

* fixup! fixup! fixup! fixup! [ADD][crm_phonecall_planner] Phonecall autoscheduler

* fixup! fixup! fixup! fixup! fixup! [ADD][crm_phonecall_planner] Phonecall autoscheduler

* fixup! fixup! fixup! fixup! fixup! fixup! [ADD][crm_phonecall_planner] Phonecall autoscheduler

*  fixup! fixup! fixup! fixup! fixup! fixup! [ADD][crm_phonecall_planner] Phonecall autoscheduler

Reword weird paragraph
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

4 participants