hr payroll rules python code

Bug #1101909 reported by Federico Manuel Echeverri Choux
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Odoo Addons (MOVED TO GITHUB)
Fix Committed
Low
OpenERP R&D Addons Team 3

Bug Description

1) Steps to reproduce the issue you have observed

I create two Rule and one Category.
first rule is like:

Code: TEST2
Name: TEST2
Fixed Amount = 100

Second Rule:

Code: TEST
Name: TEST
Python Code: result = rules.TEST2

2) The result you observed

File ".../addons_v6.1/addons/hr_payroll/hr_payroll.py", line 399, in compute_sheet
    lines = [(0,0,line) for line in self.pool.get('hr.payslip').get_payslip_lines(cr, uid, contract_ids, payslip.id, context=context)]
File ".../addons_v6.1/addons/hr_payroll/hr_payroll.py", line 592, in get_payslip_lines
    tot_rule = amount * qty * rate / 100.0
TypeError: unsupported operand type(s) for *: 'browse_record' and 'float'
2013-01-19 21:21:16,736 11013 ERROR ? openerp.netsvc: unsupported operand type(s) for *: 'browse_record' and 'float'

3) The result you expected

I expected that rule TEST give me a result = 100 and when i use rules: object containing the rules code (previously computed)
it's doesnt work well

4) The platform you are using (and browser version, if relevant)

Ubuntu 12.04 LTS

5) The OpenERP version you are using

Openerp Server 6.1 REV.: 4333
Openerp Client 6.1 REV.: 2085
Openerp Addons 6.1 REV.: 7132

Related branches

Revision history for this message
Federico Manuel Echeverri Choux (echeverrifm) wrote :

It's very important

Revision history for this message
Khushboo Bhatt(openerp) (kbh-openerp) wrote :

Hello Federico,

I have checked your issue with 6.1,7.0 and trunk also.If you want to use code of any rules then you just simply write code of particular rule.

Lets take your own example:
first rule is like:

Code: TEST2
Name: TEST2
Fixed Amount = 100

Second Rule:

Code: TEST
Name: TEST
Python Code: result = TEST2

So in this way you can create rules.

And yes there is a problem of usability where we have defined help for user like "result = rules.NET > categories.NET * 0.10" "
Here help is changed to "result = NET > categories.NET * 0.10" "

So I m confirming this issue as usability issue.

Thank you,
Khushboo.

tags: added: usability
Changed in openobject-addons:
status: New → Confirmed
Amit Parik (amit-parik)
Changed in openobject-addons:
assignee: nobody → OpenERP R&D Addons Team 3 (openerp-dev-addons3)
importance: Undecided → Low
Revision history for this message
Federico Manuel Echeverri Choux (echeverrifm) wrote : Re: [Bug 1101909] Re: hr payroll rules python code

Hello!! Khushboo Bhatt
I change my rule and It's work very well

Thanks a lot
*Echeverrifm*

2013/1/23 Khushboo Bhatt(openerp) <email address hidden>

> Hello Federico,
>
> I have checked your issue with 6.1,7.0 and trunk also.If you want to use
> code of any rules then you just simply write code of particular rule.
>
> Lets take your own example:
> first rule is like:
>
> Code: TEST2
> Name: TEST2
> Fixed Amount = 100
>
> Second Rule:
>
> Code: TEST
> Name: TEST
> Python Code: result = TEST2
>
> So in this way you can create rules.
>
> And yes there is a problem of usability where we have defined help for
> user like "result = rules.NET > categories.NET * 0.10" "
> Here help is changed to "result = NET > categories.NET * 0.10" "
>
> So I m confirming this issue as usability issue.
>
> Thank you,
> Khushboo.
>
> ** Tags added: usability
>
> ** Changed in: openobject-addons
> Status: New => Confirmed
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1101909
>
> Title:
> hr payroll rules python code
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/openobject-addons/+bug/1101909/+subscriptions
>

Revision history for this message
Federico Manuel Echeverri Choux (echeverrifm) wrote :

Hi Khushboo Bhatt, but it's a bug, because when i select python code
openerp told me that:
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
*# Available variables:*
*#----------------------*
*# payslip: object containing the payslips*
*# employee: hr.employee object*
*# contract: hr.contract object*
*# rules: object containing the rules code (previously computed)*
*# categories: object containing the computed salary rule categories (sum
of amount of all rules belonging to that category).*
*# worked_days: object containing the computed worked days*
*# inputs: object containing the computed inputs*
*
*
*# Note: returned value have to be set in the variable 'result'*
*
*
*result = rules.NET > categories.NET * 0.10*
*
*
*
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
*
*
*
*# rules: object containing the rules code (previously computed)
---->>> **this
is wrong??
*
*
*
*regards
*
*
*
*
*

2013/1/23 Federico Manuel Echeverri Choux <email address hidden>

> Hello!! Khushboo Bhatt
> I change my rule and It's work very well
>
> Thanks a lot
> *Echeverrifm*
>
>
> 2013/1/23 Khushboo Bhatt(openerp) <email address hidden>
>
> Hello Federico,
>>
>> I have checked your issue with 6.1,7.0 and trunk also.If you want to use
>> code of any rules then you just simply write code of particular rule.
>>
>> Lets take your own example:
>> first rule is like:
>>
>> Code: TEST2
>> Name: TEST2
>> Fixed Amount = 100
>>
>> Second Rule:
>>
>> Code: TEST
>> Name: TEST
>> Python Code: result = TEST2
>>
>> So in this way you can create rules.
>>
>> And yes there is a problem of usability where we have defined help for
>> user like "result = rules.NET > categories.NET * 0.10" "
>> Here help is changed to "result = NET > categories.NET * 0.10" "
>>
>> So I m confirming this issue as usability issue.
>>
>> Thank you,
>> Khushboo.
>>
>> ** Tags added: usability
>>
>> ** Changed in: openobject-addons
>> Status: New => Confirmed
>>
>> --
>> You received this bug notification because you are subscribed to the bug
>> report.
>> https://bugs.launchpad.net/bugs/1101909
>>
>> Title:
>> hr payroll rules python code
>>
>> To manage notifications about this bug go to:
>> https://bugs.launchpad.net/openobject-addons/+bug/1101909/+subscriptions
>>
>
>

Revision history for this message
Khushboo Bhatt(openerp) (kbh-openerp) wrote :

Hello Federico,

  Yes, i have confirmed this bud for the help which is showing you "result = rules.NET > categories.NET * 0.10*" instead of
  result = NET > categories.NET * 0.10*". not for the trackback you getting.

Thank you..

Changed in openobject-addons:
status: Confirmed → In Progress
Revision history for this message
Randhir Mayatra (OpenERP) (rma-openerp) wrote :

Hello,

This issue has been fixed on https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-bug-1103408-rma branch with following rev no and rev ID

Rev No : 8517
Revision ID: <email address hidden>

Thanks,
Randhir (RMA).

Changed in openobject-addons:
status: In Progress → Fix Committed
Revision history for this message
Randhir Mayatra (OpenERP) (rma-openerp) wrote :

Hello,
 ignore my comment no #6. sorry for inconvenience, please consider the following branch that fixes the issue.

issue has been fixed on https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-bug-1101909-rma branch with following rev no and rev ID

Rev No : 8517
Revision ID: <email address hidden>

Thanks,
Randhir (RMA).

tags: added: hr payroll
Revision history for this message
Bass (bass) wrote :

Hello,

sorry for having ot recall this topic. But this bug is still present even in Odoo 8
If i enter rules.xxx where xxx is a specific rule code, i get the same bug in Odoo 8. Could you help please?

Many Thanks
Bass

Revision history for this message
Fav (interfave1) wrote :

Hello,

I just wanna ask, how to retrieve python 'result' value from child rules to its parent or other main rules?
According to this example:

Code: TEST2
Name: TEST2
Fixed Amount = 100

Second Rule:

Code: TEST
Name: TEST
Python Code: result = TEST2

It's only working on parent or between main rules only,
if I call code of child rules, it warns me that parent rules invalid. Is there another variable should I put before the code?

sorry for my suck grammar I've used. Thank you, hope someone respond toward my problem.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.