-
-
Notifications
You must be signed in to change notification settings - Fork 670
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
[MIG] Migrate hr_employee_firstname to V8 #99
Conversation
@api.cr_context | ||
def _auto_init(self, cr, context=None): | ||
res = super(hr_employee, self)._auto_init(cr, context=context) | ||
cr.execute(""" |
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 explain what this query does in docstring and explain why it cannot be done in a "create" method. Also, add a couple unit tests that check exactly what it does.
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 will add a test...the ideea is that if you already have employee's in database, and install after the module, it will split the name_related fields to firstname and lastname fields for the ones that are recorded...i've put the calculation about "-2" is to check if by mistake the employee's name doesn't start with a " ", and if it start's to pass it.
1 similar comment
1b43fdb
to
4ad935d
Compare
@dufresnedavid Can you help me here...i modify the auto_init but on runbot with the demo data, it raises error. How can i init the class and update the fields firstname and lastname to be ok? |
@feketemihai let me a couple of days and i'll get back to you with a solution. |
Remove field name related, change init script, add unittests
Thanks David for your work...i just merged it to see if it's ok on runbot. |
1 similar comment
@api.multi | ||
def write(self, vals): | ||
if vals.get('firstname') or vals.get('lastname'): | ||
self.ensure_one() |
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.
Write should work on multiple records, this prevents it.
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.
@dreispt You should never write the same firstname and lastname for multiple employees at the same 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.
@dufresnedavid I find this constraint a bit artificial
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.
@StefanRijnhart What would you suggest instead ?
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.
Don't check if first or last name are written to more than one record. It's a responsibility of the user. They might even come up with a valid use case for that.
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.
@StefanRijnhart I agree.
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.
and what the code actually does is to forbid to write either first or last name to multiple records. This two lines definitely should go away
_inherit = 'hr.employee' | ||
|
||
def split_name(self, name): | ||
new_name = [w for w in name.split(' ') if w] |
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 tell python how many parts you want: https://docs.python.org/2/library/stdtypes.html#str.split
so name.split(' ', 1)
gives you at most two tokens
Superseeded by #127 |
[BSSFL-181] Module sf_terms_and_conditions
No description provided.