Merge lp:~the-clone-master/ocb-addons/6.1-lp1132963-hr_payroll_missing_AND_on_get_contract into lp:ocb-addons/6.1

Proposed by Mario Arias
Status: Merged
Merged at revision: 6730
Proposed branch: lp:~the-clone-master/ocb-addons/6.1-lp1132963-hr_payroll_missing_AND_on_get_contract
Merge into: lp:ocb-addons/6.1
Diff against target: 12 lines (+1/-1)
1 file modified
hr_payroll/hr_payroll.py (+1/-1)
To merge this branch: bzr merge lp:~the-clone-master/ocb-addons/6.1-lp1132963-hr_payroll_missing_AND_on_get_contract
Reviewer Review Type Date Requested Status
Holger Brunn (Therp) Approve
Stefan Rijnhart (Opener) Approve
Review via email: mp+159557@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Holger Brunn (Therp) (hbrunn) wrote :

can you explain how this does anything? '&' is the default operator, so both lines should be equivalent.

review: Needs Information
Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) wrote :

The default operator is deceptive in combined expressions (not fully shown in the diff):

Here is the full expression before the fix:

('employee_id', '=', employee.id),
'|',
    '|'
        '&',
            ('date_end', '<=', date_to),('date_end','>=', date_from)
        '&',
            ('date_start', '<=', date_to),('date_start','>=', date_from)
    ('date_start','<=', date_from),
'|',
    ('date_end', '=', False),
    ('date_end','>=', date_to)

The highest level, including the two '|' operators are governed by two implicit '&' operators, if I understand correctly.

After Mario's fix, the expression looks different:

('employee_id', '=', employee.id),
'|',
    '|'
        '&',
            ('date_end', '<=', date_to),('date_end','>=', date_from)
        '&',
            ('date_start', '<=', date_to),('date_start','>=', date_from)
    '&',
        ('date_start','<=', date_from),
        '|',
            ('date_end', '=', False),
            ('date_end','>=', date_to)

Although it makes my brain hurt, this does validate contracts with an end date within the date range, so that it solves the bug.

review: Approve
Revision history for this message
Mario Arias (the-clone-master) wrote :

Hi Holger,

As Stefan perfectly described, when generating the complete expression, the lack of the '&' in the third condition effectively changed the meaning as
       ('date_start','<=', date_from)

was required for "ALL" searches instead of only for the third condition...

Regards,
-Mario

Revision history for this message
Holger Brunn (Therp) (hbrunn) wrote :

Ah, now I see. Sorry for not looking at the whole expression in the first place, it was early in the morning...

review: Approve
Revision history for this message
Mario Arias (the-clone-master) wrote :

My fault Holger, as I should have explained what this was about...

Thanks for your time and support !!

What is next now? Is there any other step on my side or are we done?

Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) wrote :

BTW I did not transcribe the expression to show you how clever I am but to understand it myself in the first place ;-)

Mario, we will leave this MP open for a couple of days to give other people a chance to look at it. It will be merged afterwards. As the problem presumably still exists on 7.0 (OpenERP fix was against current trunk), could you push a branch against ocb-addons/7.0 as well? That way we won't suffer the regression when we update.

Revision history for this message
Mario Arias (the-clone-master) wrote :

Definitely will do MP for 7.0,

I just wanted to be sure I completed the whole process fine, before
going on with other fixes, (and I had to get 7.0 series from OCB...)

Regards,
-Mario

On 04/18/2013 11:16 AM, Stefan Rijnhart (Therp) wrote:
> BTW I did not transcribe the expression to show you how clever I am but to understand it myself in the first place ;-)
>
> Mario, we will leave this MP open for a couple of days to give other people a chance to look at it. It will be merged afterwards. As the problem presumably still exists on 7.0 (OpenERP fix was against current trunk), could you push a branch against ocb-addons/7.0 as well? That way we won't suffer the regression when we update.
>

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hr_payroll/hr_payroll.py'
2--- hr_payroll/hr_payroll.py 2012-01-31 13:36:57 +0000
3+++ hr_payroll/hr_payroll.py 2013-04-18 06:26:28 +0000
4@@ -375,7 +375,7 @@
5 #OR if it starts between the given dates
6 clause_2 = ['&',('date_start', '<=', date_to),('date_start','>=', date_from)]
7 #OR if it starts before the date_from and finish after the date_end (or never finish)
8- clause_3 = [('date_start','<=', date_from),'|',('date_end', '=', False),('date_end','>=', date_to)]
9+ clause_3 = ['&',('date_start','<=', date_from),'|',('date_end', '=', False),('date_end','>=', date_to)]
10 clause_final = [('employee_id', '=', employee.id),'|','|'] + clause_1 + clause_2 + clause_3
11 contract_ids = contract_obj.search(cr, uid, clause_final, context=context)
12 return contract_ids

Subscribers

People subscribed via source and target branches