首页 > 解决方案 > SyntaxError: JSON.parse: JSON 数据 (odoo10) 的第 1 行第 1 列的意外字符

问题描述

我在 hr.payslip 上工作,我想从树视图中执行多次取消。我想用 hr.payslip 中的一些数据填充一个弹出窗口,然后取消相关记录,但我收到了这个错误。以下屏幕截图显示了它 行动来自这里 来自 firefox dev 的脚本错误 未加载数据

我使用 Brave Browser,我也尝试了 firefox-dev,它显示了更多的脚本错误。我检查了我的日志文件,一切似乎都正确,HTTP/1.1" 200。

<!--XML-->
<record id="view_annulationmasse_form" model="ir.ui.view">
    <field name="name">hr.annulation.masse.form</field>
    <field name="model">hr.annulation.masse</field>
    <field name="arch" type="xml">
      <form string="Fiche de paie a annuler">
        <sheet>
          <button name="load_hr_payslip_ids" type="object" string="charger"
          class="oe_right oe_highlight" />
          <notebook>
            <page string="Fiche de Paie" accesskey="F">
              <field name="hr_payslip_ids" widget="one2many_list" mode="tree">
                <tree string="Les fiches de paie a annuler" create="False">
                  <field name="number" />
                  <field name="employee_id" />
                  <field name="matricule" />
                  <field name="name" />
                  <field name="date_from" />
                  <field name="date_to" />
                  <field name="state" />
                </tree>
              </field>
              <footer>
                <button name="action_annulation_masse" type="object" string="Executer" icon="fa-cog" class="oe_right oe_highlight" />
                ou
                <button name="cancel" type="object" string="Fermer"
                icon="fa-close" special="cancel" />
              </footer>
            </page>
          </notebook>
        </sheet>
      </form>
    </field>
  </record>

  <act_window id="action_cancel_payslips"
      view_id="view_annulationmasse_form"
      name="Annulation de masse"
      res_model="hr.annulation.masse"
      src_model="hr.payslip"
      key2="client_action_multi"
      view_type="form"
      view_mode="form"
      target="new"
      multi="True" />

<!--Python-->
 class AnnulationMasse(models.Model):
        _name = 'hr.annulation.masse'

        @api.multi
        def action_annulation_masse(self):
            for hr_pslp in self.env['hr.payslip'].sudo().search([('id', 'in', self._context.get('active_ids', [])), ('state', 'not in', ['draft'])]):
                hr_pslp.sudo().write({
                 'state': 'draft'
                 })
             return True

        hr_payslip_ids = fields.One2many(
        comodel_name='hr.payslip', inverse_name='hr_annulation_id')

    class AnnulationMasse_lines(models.Model):
        _inherit = 'hr.payslip'

        hr_annulation_id = fields.Many2one(comodel_name='hr.annulation.masse')

标签: pythonxmlodoo-10firefox-developer-editionbrave-browser

解决方案


几天后,我在XML 文件中发现了问题。
在我尝试通过 One2Many 字段hr_payslip_ids填充 treeView 之前,同时我禁止创建记录。这些东西在前端与以下内容产生冲突

<tree string="Les fiches de paie a annuler" create="False">

正确的语法是

<tree string="Les fiches de paie a annuler">

推荐阅读