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

[12.0] Customer language + company_name handling #474

Merged
merged 2 commits into from
Oct 28, 2019

Conversation

simahawk
Copy link
Contributor

@simahawk simahawk commented Oct 24, 2019

Addresses #473.
I've found that company_name as well can be supported by default harmlessly.

@simahawk
Copy link
Contributor Author

simahawk commented Oct 24, 2019

@lmignon I'll have to support partner titles as well: to me it makes sense to keep it in the core as we are talking about basic core fields for odoo. What do you think? Draft here #476

Otherwise we could move everything into a separated module like shopinvader_customer_attributes or similar to aggregate non minimal attrs. Not sure, seems overwhelming for core things...

FTR, I added support for partner_firstname in a separated module here #475

def _prepare_params(self, params):
for key in self._empty_fields_to_drop():
Copy link
Collaborator

Choose a reason for hiding this comment

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

@simahawk I don't understand why empty fields should be dropped. The required attribute into the cerberus scheme means that the field must be (or not) present into the json whatever their values. The attribute nullablecan be used to say if a field can be set to null....This allows the following usages:
{'my_field': null} -> reset the value to null for my_field
{} -> nothing to change for my field
{'my_field': 'val1'l} -> set value 'val1' for my_field

Copy link
Contributor Author

Choose a reason for hiding this comment

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

but AFAIS if you pass an empty string this is not popped out which means you gonna have an empty string where you expect none.
Maybe using a custom coerce is better?

Copy link
Collaborator

Choose a reason for hiding this comment

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

If you don't want to modify a field, don't put it into the json...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

but the client might send it anyway (eg: an hidden field). I just want to be defensive in such cases. 🤷‍♂️

Copy link
Collaborator

Choose a reason for hiding this comment

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

it's the responsibility of the client to sent or not the field. Otherwise how will it be possible to reset these fields?

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 removed the hack, in any case if we have issues we can think about it later. Thanks for your feedback :)

@codecov-io
Copy link

codecov-io commented Oct 24, 2019

Codecov Report

Merging #474 into 12.0 will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##             12.0     #474   +/-   ##
=======================================
  Coverage   91.26%   91.26%           
=======================================
  Files         104      104           
  Lines        2898     2898           
=======================================
  Hits         2645     2645           
  Misses        253      253
Impacted Files Coverage Δ
shopinvader/services/customer.py 89.47% <ø> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7e7b3dc...be23cf8. Read the comment docs.

@lmignon
Copy link
Collaborator

lmignon commented Oct 28, 2019

/ocabot merge patch

@shopinvader-git-bot
Copy link

Hey, thanks for contributing! Proceeding to merge this for you.
Prepared branch 12.0-ocabot-merge-pr-474-by-lmignon-bump-patch, awaiting test results.

shopinvader-git-bot pushed a commit that referenced this pull request Oct 28, 2019
Signed-off-by lmignon
@lmignon lmignon mentioned this pull request Oct 28, 2019
77 tasks
@shopinvader-git-bot shopinvader-git-bot merged commit be23cf8 into shopinvader:12.0 Oct 28, 2019
@shopinvader-git-bot
Copy link

Congratulations, your PR was merged at 5890a73. Thanks a lot for contributing to shopinvader. ❤️

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.

4 participants