Search code examples
odooodoo-12

ir.cron: "ERREUR: une valeur NULL viole la contrainte NOT NULL de la colonne « model_id »


I am trying to install a module in odoo 12 that contains a view with ir.cron module type. but it shows me this error:
I do not know how to rectify it. Can anyone help me, please?

odoo.tools.convert.ParseError: "ERREUR:  une valeur NULL viole la contrainte NOT NULL de la colonne « model_id »
DETAIL:  La ligne en échec contient (434, Annuler la remise mensuelle du client, ir.actions.server, null, null, action, 1, 2019-03-13 14:48:25.710923, 1, 2019-03-13 14:48:25.710923, ir_cron, object_write, 5, null, null, # Available variables:
#  - env: Odoo Environment on which the a..., null, null, null, null, null, null, null, days, specific, null, user_id)
" while parsing /home/*/PycharmProjects/Odoo12/*/sale_discount_total/views/cron.xml:5, near
<record model="ir.cron" id="deactivate_partner_discount_cron">
            <field name="name">Annuler la remise mensuelle du client</field>
            <field name="interval_number">1</field>
            <field name="interval_type">months</field>
            <field name="numbercall">-1</field>
            <field eval="False" name="doall"/>
            <field eval="'res.partner'" name="model"/>
            <field eval="'deactivate_partner_discount'" name="function"/>
            <field eval="'()'" name="args"/>
        </record>

Solution

  • The issue is with the line <field eval="'res.partner'" name="model"/>, the actual field name is model_id. you have to set the field as following

    <field name="model_id" ref="model_res_partner"/>
    

    As model_id is a Many2one relation with ir.model you can use ref with model xml id, for res.partner model xml id is model_res_partner.