Search code examples
pythonxmlodoo-10firefox-developer-editionbrave-browser

SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data (odoo10)


I work on hr.payslip, i want to perform multi-cancel from treeview. I would like fill a popup with some datas from hr.payslip and then cancel concerned records but i got this error. The following screenshoots shows it action comes from here scripts errors from firefox dev Datas not loaded

I use Brave Browser,also i tried firefox-dev that shows me more script errors. I checked my log file everything seems correct with 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')

Solution

  • After several days, i found the problem in XML file.
    Before i try to fill the treeView by the One2Many field hr_payslip_ids and in the same time i forbid to create record. This stuff generates conflict in frontend with the following

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

    The right syntax is

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