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

[10.0][MIG] port hr_holidays_legal_leave for 10.0 #262

Merged
merged 6 commits into from Oct 17, 2016

Conversation

Projects
None yet
4 participants
@yelizariev
Copy link
Member

yelizariev commented Oct 10, 2016

hr.config.settings is not inherited anymore, because one is not existed
in 10.0 and there is no anything similar. Only new menu can be added,
but I don't like this solution. I have added computed fields to
hr.holidays.status instead

res.company is not inherited anymore, because there is no HR section in
Company

@yelizariev yelizariev changed the title [MIG] port hr_holidays_legal_leave for 10.0 [10.0][MIG] port hr_holidays_legal_leave for 10.0 Oct 10, 2016

@pedrobaeza
Copy link
Contributor

pedrobaeza left a comment

Change also documentation to reflect the changes in the way things are done.

def _compute_is_annual(self):
company = self.env.user.company_id
for r in self:
r.is_annual = r.id == company.legal_holidays_status_id.id

This comment has been minimized.

@pedrobaeza

pedrobaeza Oct 10, 2016

Contributor

Use self.filtered(lamba x: x == company.legal_holidays_status_id).is_annual = True

This comment has been minimized.

@yelizariev

yelizariev Oct 10, 2016

Member

It doesn't work with multiple records:

  File "/mnt/files/src/odoo-10/odoo/fields.py", line 916, in _compute_value
    getattr(records, self.compute)()
  File "/mnt/files/git/oca_hr-10/hr_holidays_legal_leave/models/hr_holidays_status.py", line 23, in _compute_is_annual
    .is_annual = True
  File "/mnt/files/src/odoo-10/odoo/fields.py", line 875, in __set__
    record.ensure_one()
  File "/mnt/files/src/odoo-10/odoo/models.py", line 4783, in ensure_one
    raise ValueError("Expected singleton: %s" % self)
ValueError: Expected singleton: hr.holidays.status()

write make the trick, but as I understand in computed fields write is not the same as __set__

    self.filtered(lambda x: x == company.legal_holidays_status_id)\
        .write({'is_annual': True})

This comment has been minimized.

@yelizariev

This comment has been minimized.

@pedrobaeza

pedrobaeza Oct 10, 2016

Contributor

Uhm, in this case is because there's no record. Anyway, you can use:

record = self.filtered(lamba x: x == company.legal_holidays_status_id)
if record:
    record.is_annual = True

or try this:

record = self.filtered(lamba x: x == company.legal_holidays_status_id).update({'is_annual': True})

@pedrobaeza pedrobaeza referenced this pull request Oct 10, 2016

Open

Migration to version 10.0 #259

14 of 58 tasks complete
@ilmir-k

This comment has been minimized.

Copy link

ilmir-k commented Oct 13, 2016

I've checked the module features (not code). It works great 👍

@ilmir-k

This comment has been minimized.

Copy link

ilmir-k commented Oct 13, 2016

Actually I found the error. It needs to be fixed:

Traceback (most recent call last):
  File "/srv/openerp/instances/openerp-oca-runbot/parts/odoo-extra/runbot/static/build/3268941-262-dd8afa/odoo/http.py", line 638, in _handle_exception
    return super(JsonRequest, self)._handle_exception(exception)
  File "/srv/openerp/instances/openerp-oca-runbot/parts/odoo-extra/runbot/static/build/3268941-262-dd8afa/odoo/http.py", line 675, in dispatch
    result = self._call_function(**self.params)
  File "/srv/openerp/instances/openerp-oca-runbot/parts/odoo-extra/runbot/static/build/3268941-262-dd8afa/odoo/http.py", line 331, in _call_function
    return checked_call(self.db, *args, **kwargs)
  File "/srv/openerp/instances/openerp-oca-runbot/parts/odoo-extra/runbot/static/build/3268941-262-dd8afa/odoo/service/model.py", line 119, in wrapper
    return f(dbname, *args, **kwargs)
  File "/srv/openerp/instances/openerp-oca-runbot/parts/odoo-extra/runbot/static/build/3268941-262-dd8afa/odoo/http.py", line 324, in checked_call
    result = self.endpoint(*a, **kw)
  File "/srv/openerp/instances/openerp-oca-runbot/parts/odoo-extra/runbot/static/build/3268941-262-dd8afa/odoo/http.py", line 933, in __call__
    return self.method(*args, **kw)
  File "/srv/openerp/instances/openerp-oca-runbot/parts/odoo-extra/runbot/static/build/3268941-262-dd8afa/odoo/http.py", line 504, in response_wrap
    response = f(*args, **kw)
  File "/srv/openerp/instances/openerp-oca-runbot/parts/odoo-extra/runbot/static/build/3268941-262-dd8afa/odoo/addons/web/controllers/main.py", line 862, in call_kw
    return self._call_kw(model, method, args, kwargs)
  File "/srv/openerp/instances/openerp-oca-runbot/parts/odoo-extra/runbot/static/build/3268941-262-dd8afa/odoo/addons/web/controllers/main.py", line 854, in _call_kw
    return call_kw(request.env[model], method, args, kwargs)
  File "/srv/openerp/instances/openerp-oca-runbot/parts/odoo-extra/runbot/static/build/3268941-262-dd8afa/odoo/api.py", line 681, in call_kw
    return call_kw_multi(method, model, args, kwargs)
  File "/srv/openerp/instances/openerp-oca-runbot/parts/odoo-extra/runbot/static/build/3268941-262-dd8afa/odoo/api.py", line 672, in call_kw_multi
    result = method(recs, *args, **kwargs)
  File "/srv/openerp/instances/openerp-oca-runbot/parts/odoo-extra/runbot/static/build/3268941-262-dd8afa/odoo/models.py", line 2999, in read
    values[name] = field.convert_to_read(record[name], record, use_name_get)
  File "/srv/openerp/instances/openerp-oca-runbot/parts/odoo-extra/runbot/static/build/3268941-262-dd8afa/odoo/models.py", line 5175, in __getitem__
    return self._fields[key].__get__(self, type(self))
  File "/srv/openerp/instances/openerp-oca-runbot/parts/odoo-extra/runbot/static/build/3268941-262-dd8afa/odoo/fields.py", line 860, in __get__
    self.determine_value(record)
  File "/srv/openerp/instances/openerp-oca-runbot/parts/odoo-extra/runbot/static/build/3268941-262-dd8afa/odoo/fields.py", line 969, in determine_value
    self.compute_value(recs)
  File "/srv/openerp/instances/openerp-oca-runbot/parts/odoo-extra/runbot/static/build/3268941-262-dd8afa/odoo/fields.py", line 924, in compute_value
    self._compute_value(records)
  File "/srv/openerp/instances/openerp-oca-runbot/parts/odoo-extra/runbot/static/build/3268941-262-dd8afa/odoo/fields.py", line 916, in _compute_value
    getattr(records, self.compute)()
  File "/srv/openerp/instances/openerp-oca-runbot/parts/odoo-extra/runbot/static/build/3268941-262-dd8afa/odoo/addons/hr_holidays_legal_leave/models/hr_employee.py", line 41, in _compute_remaining_days
    self.ensure_one()
  File "/srv/openerp/instances/openerp-oca-runbot/parts/odoo-extra/runbot/static/build/3268941-262-dd8afa/odoo/models.py", line 4787, in ensure_one
    raise ValueError("Expected singleton: %s" % self)
ValueError: Expected singleton: hr.employee(8, 2)

yelizariev added some commits Oct 10, 2016

[MIG] port hr_holidays_legal_leave for 10.0
hr.config.settings is not inherited anymore, because one is not existed
in 10.0 and there is no anything similar. Only new menu can be added,
but I don't like this solution. I have added computes fields to
hr.holidays.status instead

res.company is not inherited anymore, because there is no HR section in
Company

@yelizariev yelizariev force-pushed the it-projects-llc:10.0-hr_holidays_legal_leave branch from a75cdc8 to 40264a1 Oct 13, 2016

@yelizariev

This comment has been minimized.

Copy link
Member

yelizariev commented Oct 13, 2016

Travis found another error related hr_holidays_compute_days module.

======================================================================
2016-10-13 12:25:44,059 6338 ERROR openerp_test odoo.addons.hr_holidays_legal_leave.tests.test_holidays_legal_leave: ERROR: test_getting_remaining (odoo.addons.hr_holidays_legal_leave.tests.test_holidays_legal_leave.TestHolidaysLegalLeave)
2016-10-13 12:25:44,059 6338 ERROR openerp_test odoo.addons.hr_holidays_legal_leave.tests.test_holidays_legal_leave: Traceback (most recent call last):
2016-10-13 12:25:44,059 6338 ERROR openerp_test odoo.addons.hr_holidays_legal_leave.tests.test_holidays_legal_leave: `   File "/home/travis/build/OCA/hr/hr_holidays_legal_leave/tests/test_holidays_legal_leave.py", line 38, in setUp
2016-10-13 12:25:44,059 6338 ERROR openerp_test odoo.addons.hr_holidays_legal_leave.tests.test_holidays_legal_leave: `     'number_of_days_temp': 10
2016-10-13 12:25:44,059 6338 ERROR openerp_test odoo.addons.hr_holidays_legal_leave.tests.test_holidays_legal_leave: `   File "/home/travis/odoo-10.0/addons/hr_holidays/models/hr_holidays.py", line 351, in create
2016-10-13 12:25:44,059 6338 ERROR openerp_test odoo.addons.hr_holidays_legal_leave.tests.test_holidays_legal_leave: `     holiday = super(Holidays, self.with_context(mail_create_nolog=True, mail_create_nosubscribe=True)).create(values)
2016-10-13 12:25:44,059 6338 ERROR openerp_test odoo.addons.hr_holidays_legal_leave.tests.test_holidays_legal_leave: `   File "/home/travis/odoo-10.0/addons/mail/models/mail_thread.py", line 229, in create
2016-10-13 12:25:44,060 6338 ERROR openerp_test odoo.addons.hr_holidays_legal_leave.tests.test_holidays_legal_leave: `     thread = super(MailThread, self).create(values)
2016-10-13 12:25:44,060 6338 ERROR openerp_test odoo.addons.hr_holidays_legal_leave.tests.test_holidays_legal_leave: `   File "/home/travis/odoo-10.0/odoo/models.py", line 3802, in create
2016-10-13 12:25:44,060 6338 ERROR openerp_test odoo.addons.hr_holidays_legal_leave.tests.test_holidays_legal_leave: `     record = self.browse(self._create(old_vals))
2016-10-13 12:25:44,060 6338 ERROR openerp_test odoo.addons.hr_holidays_legal_leave.tests.test_holidays_legal_leave: `   File "/home/travis/odoo-10.0/odoo/models.py", line 3962, in _create
2016-10-13 12:25:44,060 6338 ERROR openerp_test odoo.addons.hr_holidays_legal_leave.tests.test_holidays_legal_leave: `     self.recompute()
2016-10-13 12:25:44,060 6338 ERROR openerp_test odoo.addons.hr_holidays_legal_leave.tests.test_holidays_legal_leave: `   File "/home/travis/odoo-10.0/odoo/models.py", line 5276, in recompute
2016-10-13 12:25:44,060 6338 ERROR openerp_test odoo.addons.hr_holidays_legal_leave.tests.test_holidays_legal_leave: `     vals = rec._convert_to_write({n: rec[n] for n in ns})
2016-10-13 12:25:44,060 6338 ERROR openerp_test odoo.addons.hr_holidays_legal_leave.tests.test_holidays_legal_leave: `   File "/home/travis/odoo-10.0/odoo/models.py", line 5276, in <dictcomp>
2016-10-13 12:25:44,060 6338 ERROR openerp_test odoo.addons.hr_holidays_legal_leave.tests.test_holidays_legal_leave: `     vals = rec._convert_to_write({n: rec[n] for n in ns})
2016-10-13 12:25:44,060 6338 ERROR openerp_test odoo.addons.hr_holidays_legal_leave.tests.test_holidays_legal_leave: `   File "/home/travis/odoo-10.0/odoo/models.py", line 5175, in __getitem__
2016-10-13 12:25:44,060 6338 ERROR openerp_test odoo.addons.hr_holidays_legal_leave.tests.test_holidays_legal_leave: `     return self._fields[key].__get__(self, type(self))
2016-10-13 12:25:44,060 6338 ERROR openerp_test odoo.addons.hr_holidays_legal_leave.tests.test_holidays_legal_leave: `   File "/home/travis/odoo-10.0/odoo/fields.py", line 860, in __get__
2016-10-13 12:25:44,060 6338 ERROR openerp_test odoo.addons.hr_holidays_legal_leave.tests.test_holidays_legal_leave: `     self.determine_value(record)
2016-10-13 12:25:44,060 6338 ERROR openerp_test odoo.addons.hr_holidays_legal_leave.tests.test_holidays_legal_leave: `   File "/home/travis/odoo-10.0/odoo/fields.py", line 944, in determine_value
2016-10-13 12:25:44,060 6338 ERROR openerp_test odoo.addons.hr_holidays_legal_leave.tests.test_holidays_legal_leave: `     self.compute_value(recs)
2016-10-13 12:25:44,061 6338 ERROR openerp_test odoo.addons.hr_holidays_legal_leave.tests.test_holidays_legal_leave: `   File "/home/travis/odoo-10.0/odoo/fields.py", line 924, in compute_value
2016-10-13 12:25:44,061 6338 ERROR openerp_test odoo.addons.hr_holidays_legal_leave.tests.test_holidays_legal_leave: `     self._compute_value(records)
2016-10-13 12:25:44,061 6338 ERROR openerp_test odoo.addons.hr_holidays_legal_leave.tests.test_holidays_legal_leave: `   File "/home/travis/odoo-10.0/odoo/fields.py", line 916, in _compute_value
2016-10-13 12:25:44,061 6338 ERROR openerp_test odoo.addons.hr_holidays_legal_leave.tests.test_holidays_legal_leave: `     getattr(records, self.compute)()
2016-10-13 12:25:44,061 6338 ERROR openerp_test odoo.addons.hr_holidays_legal_leave.tests.test_holidays_legal_leave: `   File "/home/travis/build/OCA/hr/hr_holidays_compute_days/models/hr_holidays.py", line 77, in _compute_number_of_days
2016-10-13 12:25:44,061 6338 ERROR openerp_test odoo.addons.hr_holidays_legal_leave.tests.test_holidays_legal_leave: `     days = self._get_number_of_days(date_from, date_to, None)
2016-10-13 12:25:44,061 6338 ERROR openerp_test odoo.addons.hr_holidays_legal_leave.tests.test_holidays_legal_leave: `   File "/home/travis/odoo-10.0/addons/hr_holidays/models/hr_holidays.py", line 289, in _get_number_of_days
2016-10-13 12:25:44,061 6338 ERROR openerp_test odoo.addons.hr_holidays_legal_leave.tests.test_holidays_legal_leave: `     time_delta = to_dt - from_dt
2016-10-13 12:25:44,061 6338 ERROR openerp_test odoo.addons.hr_holidays_legal_leave.tests.test_holidays_legal_leave: ` TypeError: unsupported operand type(s) for -: 'NoneType' and 'NoneType'
2016-10-13 12:25:44,061 6338 INFO openerp_test odoo.addons.hr_holidays_legal_leave.tests.test_holidays_legal_leave: ======================================================================

I have made rebase on upstream and have added new commit: 40264a1

Reviewers of #261 are kindly invited to review this one too 🐱 @feketemihai

@yelizariev

This comment has been minimized.

Copy link
Member

yelizariev commented Oct 17, 2016

requested changes are done

@pedrobaeza
Copy link
Contributor

pedrobaeza left a comment

Although some tests would be good

@gurneyalex gurneyalex added this to the 10.0 milestone Oct 17, 2016

@pedrobaeza pedrobaeza merged commit 75edcf6 into OCA:10.0 Oct 17, 2016

2 of 4 checks passed

codecov/patch 63.15% of diff hit (target 88.30%)
Details
codecov/project 86.79% (-1.52%) compared to e1d6623
Details
ci/runbot runbot build 3269513-262-40264a (runtime 41s)
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

feketemihai pushed a commit to feketemihai/hr that referenced this pull request Nov 13, 2017

[10.0][MIG] port hr_holidays_legal_leave for 10.0 (OCA#262)
[MIG] port hr_holidays_legal_leave for 10.0

hr.config.settings is not inherited anymore, because one is not existed
in 10.0 and there is no anything similar. Only new menu can be added,
but I don't like this solution. I have added computes fields to
hr.holidays.status instead

res.company is not inherited anymore, because there is no HR section in
Company

feketemihai pushed a commit to feketemihai/hr that referenced this pull request Nov 16, 2017

[10.0][MIG] port hr_holidays_legal_leave for 10.0 (OCA#262)
[MIG] port hr_holidays_legal_leave for 10.0

hr.config.settings is not inherited anymore, because one is not existed
in 10.0 and there is no anything similar. Only new menu can be added,
but I don't like this solution. I have added computes fields to
hr.holidays.status instead

res.company is not inherited anymore, because there is no HR section in
Company

sambarros pushed a commit to sambarros/hr that referenced this pull request Jul 26, 2018

Merge pull request OCA#262 from leemannd/master
[FIX]account-financial-tool to branch -> 10.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment