Skip to Content
Menu
This question has been flagged
1 Reply
5882 Views

I am trying to migrate my custom module from v9 to v10. Here is a part of code : 

 

class hr_payslip(models.Model):

    _inherit = 'hr.payslip'

 

    seniority_rate = fields.Float(compute=lambda self, *args, **kwargs:

                                                     self._calculate_seniority_rate(*args, **kwargs),

                                                     type='float',

                                                     string='Seniority rate',

                                                     store=True),

              

    def _calculate_seniority_rate(self, cr, uid, ids, field_name, args, context=None):

        res = dict.fromkeys(ids, 0.0)

        for slip_id in ids:

            payslip = self.browse(cr, uid, slip_id, context=None)

            employee = payslip.employee_id

            # Yes, assuming all years have 365 days.

            # Also assuming the seniority is calculated w.r.t. the start date for the payslip, not the end date.

            years = (datetime.strptime(payslip.date_from, DEFAULT_SERVER_DATE_FORMAT) - \

                datetime.strptime(employee.start_date, DEFAULT_SERVER_DATE_FORMAT)).days / 365

            rate = 0.03 if years >= 3 else 0.02 if years >= 2 else 0.0

            res.update({slip_id: rate})

        return res


And I get this error : 

Traceback (most recent call last):
  File "C:\Program Files (x86)\Odoo 10.0\server\odoo\http.py", line 640, in _handle_exception
  File "C:\Program Files (x86)\Odoo 10.0\server\odoo\http.py", line 677, in dispatch
  File "C:\Program Files (x86)\Odoo 10.0\server\odoo\http.py", line 333, in _call_function
  File "C:\Program Files (x86)\Odoo 10.0\server\odoo\service\model.py", line 101, in wrapper
  File "C:\Program Files (x86)\Odoo 10.0\server\odoo\http.py", line 326, in checked_call
  File "C:\Program Files (x86)\Odoo 10.0\server\odoo\http.py", line 935, in __call__
  File "C:\Program Files (x86)\Odoo 10.0\server\odoo\http.py", line 506, in response_wrap
  File "C:\Program Files (x86)\Odoo 10.0\server\odoo\addons\web\controllers\main.py", line 889, in call_button
  File "C:\Program Files (x86)\Odoo 10.0\server\odoo\addons\web\controllers\main.py", line 877, in _call_kw
  File "C:\Program Files (x86)\Odoo 10.0\server\odoo\api.py", line 689, in call_kw
  File "C:\Program Files (x86)\Odoo 10.0\server\odoo\api.py", line 680, in call_kw_multi
  File "C:\Program Files (x86)\Odoo 10.0\server\odoo\addons\base\module\module.py", line 411, in button_immediate_install
  File "C:\Program Files (x86)\Odoo 10.0\server\odoo\addons\base\module\module.py", line 485, in _button_immediate_function
  File "C:\Program Files (x86)\Odoo 10.0\server\odoo\modules\registry.py", line 82, in new
  File "C:\Program Files (x86)\Odoo 10.0\server\odoo\modules\loading.py", line 339, in load_modules
  File "C:\Program Files (x86)\Odoo 10.0\server\odoo\modules\loading.py", line 237, in load_marked_modules
  File "C:\Program Files (x86)\Odoo 10.0\server\odoo\modules\loading.py", line 136, in load_module_graph
  File "C:\Program Files (x86)\Odoo 10.0\server\odoo\modules\registry.py", line 313, in init_models
  File "C:\Program Files (x86)\Odoo 10.0\server\odoo\models.py", line 2508, in _auto_init
  File "C:\Program Files (x86)\Odoo 10.0\server\odoo\models.py", line 2278, in _init_column
TypeError: <lambda>() takes exactly 4 arguments (1 given)

Please i need a help.

Avatar
Discard
Best Answer

hello Koffi KPONOUGLO, 

Try this.

seniority_rate = fields.Float(compute=lambda self : self._calculate_seniority_rate(), type='float', 
                                    string='Seniority rate',  store=True),



Avatar
Discard
Author

Hi Palkesh,

thanks for your answer but it isn't working.

Related Posts Replies Views Activity
1
Jul 18
5016
1
Mar 15
5628
1
Nov 24
56
0
Mar 23
1693
3
Jan 21
23798