获取TypeError:无法使用fields_view_get()ODOO 11读取null的属性“ documentElement”

时间:2018-09-11 14:09:00

标签: odoo-11 m2m

这是我的代码-

@api.multi

def fields_view_get(self, cr, uid, view_id=None, view_type=False, context=None, toolbar=False, submenu=False):

        payslips = self.env['hr.payslip']

#        [data] = self.read()

        active_id = self.env.context.get('active_id')

        if active_id:

            [run_data] = self.env['hr.payslip.run'].browse(active_id).read(['date_start', 'date_end', 'credit_note'])

        from_date = run_data.get('date_start')

        to_date = run_data.get('date_end')

        if not from_date or from_date == False:

            today = datetime.today()

            to_date = datetime.date(today.year, today.month, 1) - 1

            from_date = datetime.date(to_date.year, to_date.month, 1)



        if not to_date or to_date == False:

            today = datetime.today()

            to_date = datetime.date(today.year, today.month, 1) - 1

            from_date = datetime.date(to_date.year, to_date.month, 1)



        query = """select id from hr_employee where id not in 

            (select distinct employee_id from hr_payslip where date_from = '%s' and date_to = '%s')""" % (from_date, to_date)

        query_res = self.env.cr.execute(query)

        query_res = self.env.cr.fetchall()



        emp_ids = []

        for each_id in query_res:

            emp_ids.append(each_id[0])



        return {'domain': {'employee_ids':[('id','in',emp_ids)]}}

我尝试通过将此代码粘贴到hr_payroll_payslips_by_employees.py中来尝试筛选要选择薪水单的员工,以筛选出员工列表。目的是避免在同一工资核算期间创建重复的工资单。但是出现错误,如“ TypeError:无法读取null的属性'documentElement'”

对此的任何帮助将是一个巨大的帮助,并在此先感谢您。

编辑:

想在这里添加:那,我的代码可以完美地运行到最后一行,并且在将域返回到我的m2m字段(employee_ids)时,错误仅在最后一行抛出。

  

http://:8069 / web / content / 3598-e2a938e / web.assets_backend.js:585   追溯:TypeError:无法读取null的属性'documentElement'       在Class._postprocess_fvg(http://103.215.164.67:8069/web/content/3598-e2a938e/web.assets_backend.js:585:239)       在Function ._。mapObject(http://103.215.164.67:8069/web/content/3455-057e365/web.assets_common.js:50:233)       在对象。 (http://103.215.164.67:8069/web/content/3598-e2a938e/web.assets_backend.js:580:189)       在对象。 (http://103.215.164.67:8069/web/content/3455-057e365/web.assets_common.js:802:681)       起火(http://103.215.164.67:8069/web/content/3455-057e365/web.assets_common.js:796:299)       在Object.fireWith [as resolveWith](http://103.215.164.67:8069/web/content/3455-057e365/web.assets_common.js:801:198)       在对象。 (http://103.215.164.67:8069/web/content/3455-057e365/web.assets_common.js:802:874)       起火(http://103.215.164.67:8069/web/content/3455-057e365/web.assets_common.js:796:299)       在Object.fireWith [as resolveWith](http://103.215.164.67:8069/web/content/3455-057e365/web.assets_common.js:801:198)       在对象。 (http://103.215.164.67:8069/web/content/3455-057e365/web.assets_common.js:802:874

0 个答案:

没有答案