【问题标题】:SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data (odoo10)SyntaxError: JSON.parse: JSON 数据 (odoo10) 的第 1 行第 1 列的意外字符
【发布时间】:2019-12-27 23:43:54
【问题描述】:

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

我使用 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')

【问题讨论】:

    标签: python xml odoo-10 firefox-developer-edition brave-browser


    【解决方案1】:

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

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

    正确的语法是

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

    【讨论】:

      猜你喜欢
      • 2017-04-28
      • 2023-02-08
      • 1970-01-01
      • 2015-03-04
      • 2020-09-03
      • 2016-05-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多