-
-
Notifications
You must be signed in to change notification settings - Fork 815
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
Base contact by function #20
Conversation
d0ac771
to
32b98d7
Compare
from . import functions | ||
from . import res_institutions | ||
|
||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
vim line
👍 |
|
||
class functions(orm.Model): | ||
_description = 'Functions' | ||
_name = 'functions' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm concerned this may be a bit too generic and confusing (function fields...). Also the convention nowadays is to use a singular form for Model _name
.
I suggest "res.partner.function"
for _name
.
b1ed151
to
8ad1ae5
Compare
Allow to manage contacts by function
Add firstname before name. Name is considered like the lastname and we have firstname and lastname on partner view and contact view.
2ab513b
to
2b0ef42
Compare
Inconsistent fail between Odoo and OCB |
Functions for contacts of companies should be created in the Functions Tab. Functions created straight in the Contact form will not end up in the Functions Tab. Does not change behaviour on systems without web_m2x_options
name = name.split(' / ')[-1] | ||
ids = self.search(cr, user, [('name', operator, name)] + args, | ||
limit=limit, context=context) | ||
if ids: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this whole section doesn't respect the limit parameter, that will yield too many results when there are a lot of subcategories
cr, user, [('parent_id', 'child_of', ids)], | ||
context=context) | ||
if child_ids: | ||
ids.extend(child_ids) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the childof operator also returns the id itself, so add them only if not included already
@bwrsandman the difference is caused by ocb using browse() in name_get and odoo using read(). The latter discards double ids and gives a random(?) order, the former delivers all ids in the order of the id list. So to fix the test, we shouldn't pass double ids to name_get as pointed out in my comment above, and we should only check for set equality (= no order) |
@hbrunn I have fixed the limits and the duplicates problem. I don't understand this issue with id order, though. In this implementation, I used |
I personally think that every name_get should return its list sorted alphabetically, but not all name_gets do that. As for the issue at hand: The test fails because it checks for list equality (https://github.com/OCA/partner-contact/pull/20/files#diff-482719082e50caa32544883db16a8259R156) and there, order matters. Given that I don't think we care about the lists' orders, I think you'd better use assertItemsEqual: https://docs.python.org/2/library/unittest.html#unittest.TestCase.assertItemsEqual |
Thanks @hbrunn. As for the order, I thought odoo relied on the defined |
🙌 |
yay! Concerning Anyway: 👍 |
👍 |
The base_contact_function_partner_firstname module depends on partner_firstname and base_contact_function module.
Previous reviews:
@StefanRijnhart
@bwrsandman