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

Better partner_firstname. #104

Merged
merged 20 commits into from Jul 3, 2015
Merged

Better partner_firstname. #104

merged 20 commits into from Jul 3, 2015

Conversation

yajo
Copy link
Member

@yajo yajo commented Mar 30, 2015

Pros:

  • Cleaner v8 API code.
  • Cleaner tests.
  • Less overload of framework methods.
  • Instead of having a required last name field, now it's required to
    provide either the last or the first name.

Cons:

  • Broken backwards compatibility when copying a partner. The "(copy)"
    suffix is added to the first name instead of the last name. However,
    the user is expected to replace that word for the real one, so this
    should not be a big problem.
  • Translations must be updated.

@oca-clabot
Copy link

Hey @yajo, thank you for your Pull Request.

It looks like some users haven't signed our Contributor License Agreement, yet.
You can read and sign our full Contributor License Agreement here: http://odoo-community.org/page/website.cla
Here is a list of the users:

  • @yajo (login unknown in OCA database)

Appreciation of efforts,
OCA CLAbot

@coveralls
Copy link

Coverage Status

Coverage decreased (-2.49%) to 47.93% when pulling 1203f38 on grupoesoc:better_partner_firstname into 856babf on OCA:8.0.

@yajo
Copy link
Member Author

yajo commented Mar 30, 2015

Sorry because I sent the pull request and later I saw some mistakes. Now it's ready for review. I already sent the signed CLA.

The point in upgrading this module is that I'm also creating a partner_lastname2 module that I need and I think it can be useful for other users of this repo. I'll post it too ASAP.

@yajo yajo mentioned this pull request Mar 30, 2015
@gurneyalex
Copy link
Member

@yajo could you tell me under which name the CLA has been sent? I'm not able to identify you from the github login only. Thanks

'description': """
This module splits first name and last name for non company partners
====================================================================
Split first name and last name for non company partners
Copy link
Member

Choose a reason for hiding this comment

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

Can you move description under README.rst ? using OCA template: https://github.com/OCA/maintainer-tools/blob/master/template/module/README.rst

@coveralls
Copy link

Coverage Status

Coverage decreased (-2.6%) to 47.82% when pulling 4e728c9 on grupoesoc:better_partner_firstname into 856babf on OCA:8.0.

@yajo
Copy link
Member Author

yajo commented Apr 20, 2015

What do the coverage messages mean? Is there anything left to be done? Thanks.

@pedrobaeza
Copy link
Member

It means the quantity of the repo code that it's been tested automatically. The ideal is 100%.

More reviews are needed to be merged.

@coveralls
Copy link

Coverage Status

Coverage decreased (-2.21%) to 49.26% when pulling 18650fb on grupoesoc:better_partner_firstname into 6628900 on OCA:8.0.


@property
def value(self):
raise NotImplementedError()
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the point of subclassing if it is only used once? Can we merge these two Exceptions?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's a common pattern I follow for modules: do a base exception for that module and subclass it. It helps with submodules and tests. However, seems like after finishing only one possible exception was left, so I will merge it as you say.

@bwrsandman
Copy link
Contributor

Could we add a test for _install_firstname and for the exceptions' value functions?

There are also a few branches in _name_inverse which could use a test case.

@bwrsandman
Copy link
Contributor

👍
Overall, this looks like a very good improvement.
Great job!

@gurneyalex gurneyalex changed the title Beter partner_firstname. Better partner_firstname. May 17, 2015
@yajo
Copy link
Member Author

yajo commented May 18, 2015

Could we add a test for _install_firstname

Hardly, the method's effect can be checked only by creating a partner, then installing the module and then checking the partner's firstname and lastname, because after installing the module all that happens automatically with the constraints.

On the other hand, to run tests, you have to install the module first.

Suggestions are welcome, however.

and for the exceptions' value functions?

After the last update, it's not necessary now.

There are also a few branches in _name_inverse which could use a test case.

I'm working on all of it, I'll update soon. Thanks everyone!

@yajo
Copy link
Member Author

yajo commented May 20, 2015

Everything fixed AFAIK.

@api.depends("firstname", "lastname")
def _name_compute(self):
"""Write the 'name' field according to splitted data."""
self.name = " ".join((p for p in (self.lastname,
Copy link
Contributor

Choose a reason for hiding this comment

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

Just a detail but u" ".join seems better

@nbessi
Copy link
Contributor

nbessi commented May 20, 2015

Some details but it is globally OK.

Thanks

@antespi
Copy link
Contributor

antespi commented Jun 30, 2015

👍 tested on production instance

@antespi
Copy link
Contributor

antespi commented Jun 30, 2015

@yajo I've PR https://github.com/grupoesoc/partner-contact/pull/1 to you to be able to select names order ('firstname lastname' or 'lastname firstname'), please review, thanks

@yajo
Copy link
Member Author

yajo commented Jul 1, 2015

@antespi Wow you were faster than me in testing on production! 😄

To others... seems like runbots hate me 😕:

@rafaelbn
Copy link
Member

rafaelbn commented Jul 1, 2015

@yajo we have in several production enviroment firstname's module with a couple of issues that are correctect with your fix, that's why! :-D
👍

Jairo Llopis added 4 commits July 1, 2015 10:47
This happened because the invert method was not being called when using
the UI, and because lastname & firstname fields were required while
hidden.
@yajo
Copy link
Member Author

yajo commented Jul 1, 2015

@antespi @rafaelbn Glad to hear that. If so, please update to last version, it fixes some critical usability bugs I found today.

@yajo
Copy link
Member Author

yajo commented Jul 3, 2015

Coveralls fails because the code is shorter, so it should be considered OK.

@pedrobaeza
Copy link
Member

👍

pedrobaeza added a commit that referenced this pull request Jul 3, 2015
@pedrobaeza pedrobaeza merged commit 1520e0d into OCA:8.0 Jul 3, 2015
@yajo
Copy link
Member Author

yajo commented Jul 3, 2015

Sorry to bother you again, but I found a bug with the onchange method that I'm fixing right now. Maybe you want to roll this back before it's too late.

@pedrobaeza
Copy link
Member

Please make it the PR fast and I'll fast track it.

@yajo
Copy link
Member Author

yajo commented Jul 4, 2015

I could not fix it in time, I'll patch it this monday. Sorry for that, the bug was just in the very one line that is not tested 😁. Is there a way to unit test onchange methods?

@hbrunn
Copy link
Member

hbrunn commented Jul 4, 2015

@yajo say

with self.env.do_in_onchange():
    self.env['my.model'].new(whatever_values).my_onchange_method()

@yajo
Copy link
Member Author

yajo commented Jul 5, 2015

@hbrunn You guys are awesome. You'll have the fix tomorrow.

@oca-clabot
Copy link

Hey @yajo,
We acknowledge that the following users have signed our Contributor License Agreement:

Appreciation of efforts,
OCA CLAbot

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.