Skip to Content
Menu
This question has been flagged

I'm trying to set a salary rule in my "Salesman" salary structure that computes a bonus based on the sales amount that the salesman made during the last month.


I found a similar question (https://www.odoo.com/forum/help-1/question/is-there-anything-like-salesman-sales-amount-function-9566), but unfortunately the code doesn't work. I'll copy it here:

total_sale_amount = 0.0
sale_order_ids = sale_order_obj.search(cr, uid, [('user_id', '=', employee.id)], context=context)
for sale_order in sale_order_obj.browse(cr, uid, sale_order_ids, context=context):
    total_sale_amount += sale_order.amount_total
result = total_sale_amount * 0.10

Can you help me?

Avatar
Discard

I don't think you can use ORM methods inside salary rule. May be you can use this code to write to a field in payroll form and access that field from salary rule.

Author

Thanks for the comment. Could you explain how should I do it? I'm quite new to Odoo and Python.

Related Posts Replies Views Activity
2
Dec 24
10140
3
Sep 19
5667
1
Sep 17
4823
4
Apr 24
170706
0
Dec 23
593