-
-
Notifications
You must be signed in to change notification settings - Fork 235
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] [10.0] hr_employee_operating_unit #97
Conversation
@aheficent Could you please review ? |
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.
Hi @Matiar Thanks for your module. A couple of things:
- As there's a field user_id in the employee, if the employee has an user associated, then the employee should have an operating unit from the operating unit of the users.
- IMHO an employee may belong to different operating units so the field may be One2many. The problem here is that it may be inconsistencies between the operating unit of the employee and the operating unit of the related user.
- Please attend travis and also fix the description in this PR
Hello @aarón Henríquez, Thanks for your valuable feedback. I'll fix as you suggested and get back to you. |
…f the employee will be the same as user account
Hello Aarón Henríquez, Thanks for your valuable feedback. As you suggested, when an employee will associate with an user account the operating unit of employee is set with the operating unit of the associated user. But also you suggest an one2many relationship between employee and operating unit, I didn't yet implement that. I have a question on that as you know the employee has a relationship between department and that is Many2One; Then will it not confusing to maintain One2Many relationship. Would you please review and let me know your valuable feedback ? |
@aheficent Could you please review ? |
Hi @Matiar the question is, can an employee belong to different operating units? If the answer it's true then the field have to be Many2many. |
I think it's not necessary to have a default_operating_unit field in the employee. I'd leave just the many2many relationship. Don't you agree? |
|
||
@api.onchange('user_id') | ||
def _onchange_user(self): | ||
super(HREmployee, self)._onchange_user() |
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.
Hi @Matiar Thank you for doing the thing but I was wrong. An employee may belong to different operating units but as a user manage different operating units. So probably this is not needed now. I'm sorry for the misunderstanding.
|
||
@api.model | ||
def _get_operating_unit(self): | ||
return self.operating_unit_default_get(self._uid) |
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.
Is it possible to achieve the same result in a single method?
…n change user method
Hey @Matiar, thank you for your Pull Request. It looks like some users haven't signed our Contributor License Agreement, yet.
Appreciation of efforts, |
Hello @aheficent , Thanks for your overall feedback and reviewing the PR. I'm not sure how to fix codecov/project & codecov/patch failure issue. Could you please share some source or link to understand the problem and fixing it. |
Hi @Matiar, You need to add some tests in order to turn green codecov. For example you can test that users cannot see the employees the are not allowed to. You can also test the default method.Are you familiarized with unit test? |
Hello @aheficent, Thanks for your valuable feedback and keeping your patience to accept my mistakes. I added the unit tests as you suggested. Could you please review again ? |
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.
Code looks nice. Only a minor thing
# © 2017 Genweb2 Limited - Matiar Rahman | ||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). | ||
from . import models | ||
from . import tests |
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.
Importing tests is not needed
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.
Hi @aheficent ,
I fixed that. Thanks.
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.
Hello @aheficent , Thanks for your review and valuable feedback, But IMHO, the change you suggested belongs to the feature of HR module, do you think this module (hr_employee_operating_unit) is the right place to |
He meant from the operating unit field.
…On Oct 28, 2017 5:07 PM, "Matiar Rahman" ***@***.***> wrote:
Hello @aheficent <https://github.com/aheficent> ,
Thanks for your review and valuable feedback, But IMHO, the change you
suggested belongs to the feature of HR module, do you think this module
(hr_employee_operating_unit) is the right place to
implement your suggested change ?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#97 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AHU_Vkjn2KmjhRGfoPQ57GSGZVUCoKN7ks5sw0M7gaJpZM4Pxryw>
.
|
Hey @Matiar, thank you for your Pull Request. It looks like some users haven't signed our Contributor License Agreement, yet.
Appreciation of efforts, |
Hey @Matiar, Appreciation of efforts, |
Hello @aheficent , Thanks for your feedback. I incorporated your suggested change. Could you please review again ? |
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.
Tested on runbot and working fine. Just some minor comments to the code.
<?xml version="1.0" encoding="utf-8"?> | ||
|
||
<odoo> | ||
<data noupdate="0"> |
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.
data it's not necessary anymore. Use
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.
Sorry. I meant <odoo noupdate="0">
but it does not matter because that it's the same as <odoo>
@@ -0,0 +1,27 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
|
|||
<openerp> |
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.
odoo
</field> | ||
</record> | ||
|
||
<!-- Employee --> |
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.
Not needed IMO
Hello @aheficent , Thanks again for your time and feedback. I've fixed your suggested changes. Take a look at your convenient time. |
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.
👍 Functional + code. Thanks @Matiar for attending all the comments.
Hello @aheficent , Thanks for your time and approve the PR. Could you please inform me what will be my next step to merge the PR with OCA branch or when it will be merged ? |
Hi @Matiar we need at least two more approvals. Normally it takes some time but eventually it'll be merged 😄 |
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.
@Matiar
Thanks for your contribution. Here are a few remarks/recommandations.
|
||
@api.model | ||
def _get_operating_unit(self): | ||
user = self.env['res.users'].browse(self._uid) |
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.
No need to browse here, you can do return self.env.user.default_operating_unit_id
return user.default_operating_unit_id | ||
|
||
@api.model | ||
def _get_operating_units(self): |
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 suppose you can get rid of this method and call directly _get_operating_unit
?
operating_unit_ids = fields.Many2many('operating.unit', | ||
'operating_unit_emp_rel', | ||
'emp_id', 'ou_id', 'Operating Units', | ||
default=_get_operating_units) |
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.
Please use lambda to proxy the call to _get_operating_unit
def _create_user(self, login, groups, company, operating_units): | ||
""" Create a user. """ | ||
group_ids = [group.id for group in groups] | ||
user = self.res_users_model.create({ |
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.
Here would be nice to add with_context('no_reset_password': True, 'mail_create_nosubscribe': True)
to avoid sending unnecessary emails during the test.
|
||
def _create_user(self, login, groups, company, operating_units): | ||
""" Create a user. """ | ||
group_ids = [group.id for group in groups] |
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.
You can remove this line and do groups.ids
to get the same list.
'email': 'test@yourcompany.com', | ||
'company_id': company.id, | ||
'company_ids': [(4, company.id)], | ||
'operating_unit_ids': [(4, ou.id) for ou in operating_units], |
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.
Shouldn't [6, 0, operating_units.ids]
do the same ?
|
||
emp = self.hr_employee_model.sudo(self.user2.id).search( | ||
[('id', '=', self.emp1.id), | ||
('operating_unit_ids', '=', self.main_OU.id)]) |
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.
Not sure this is working as operating_unit_ids is a x2m field. You probably should use in
instead of =
or remove the line all together as you're already searching with an id.
@@ -0,0 +1,17 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
|
|||
<odoo> |
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.
Missed in the last review but please add noupdate="1"
here.
<field eval="1" name="perm_unlink"/> | ||
<field eval="1" name="perm_write"/> | ||
<field eval="1" name="perm_read"/> | ||
<field eval="1" name="perm_create"/> |
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 not sure about this but all the other modules only define perm_read to 1 on the record rule. Is there any reason to set all the perms to 1 ?
Hi @Matiar are you still working on this? |
There hasn't been any activity on this pull request in the past 4 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days. |
This module introduces the following features: