Ayuda

0

field not found

Avatar
Orveau

Hello, i'm working on the module project, i was trying to add a field, so in project.py in the class project.task i add: 

class Task(models.Model):
    _name =
"project.task"
    _description = "Task"
    _date_name = "date_start"
    _inherit = ['mail.thread', 'mail.activity.mixin', 'portal.mixin']
    _mail_post_access =
'read'
    _order = "priority desc, sequence, id desc"

    Num_Contract = fields.Char(string='number 5')

And then i add in the project_views, this:

<page name="Information_page" string="Information">
    <field
name="Num_Contract" type="Char"/>
</page>

In this record : <record id="view_task_form2" model="ir.ui.view">
But i have the following error:

Erreur:

Odoo Server Error


Traceback (most recent call last):

  File "C:\Program Files (x86)\Odoo 11.0\server\odoo\models.py", line 1036, in _validate_fields

    check(self)

  File "C:\Program Files (x86)\Odoo 11.0\server\odoo\addons\base\ir\ir_ui_view.py", line 335, in _check_xml

    self.postprocess_and_fields(view.model, view_doc, view.id)

  File "C:\Program Files (x86)\Odoo 11.0\server\odoo\addons\base\ir\ir_ui_view.py", line 1042, in postprocess_and_fields

    self.raise_view_error(message, view_id)

  File "C:\Program Files (x86)\Odoo 11.0\server\odoo\addons\base\ir\ir_ui_view.py", line 503, in raise_view_error

    raise ValueError(message)

ValueError: Le champ `Num_Contract` n'existe pas


Contexte de l'erreur :

Vue `project.task.form`

[view_id: 703, xml_id: project.view_task_form2, model: project.task, parent_id: n/a]


During handling of the above exception, another exception occurred:


Traceback (most recent call last):

  File "C:\Program Files (x86)\Odoo 11.0\server\odoo\tools\convert.py", line 744, in parse

    self._tags[rec.tag](rec, de, mode=mode)

  File "C:\Program Files (x86)\Odoo 11.0\server\odoo\tools\convert.py", line 654, in _tag_record

    id = self.env(context=rec_context)['ir.model.data']._update(rec_model, self.module, res, rec_id or False, not self.isnoupdate(data_node), noupdate=self.isnoupdate(data_node), mode=self.mode)

  File "C:\Program Files (x86)\Odoo 11.0\server\odoo\addons\base\ir\ir_model.py", line 1437, in _update

    record.write(values)

  File "C:\Program Files (x86)\Odoo 11.0\server\odoo\addons\base\ir\ir_ui_view.py", line 414, in write

    return super(View, self).write(self._compute_defaults(vals))

  File "C:\Program Files (x86)\Odoo 11.0\server\odoo\models.py", line 3108, in write

    field.determine_inverse(records)

  File "C:\Program Files (x86)\Odoo 11.0\server\odoo\fields.py", line 1071, in determine_inverse

    getattr(records, self.inverse)()

  File "C:\Program Files (x86)\Odoo 11.0\server\odoo\addons\base\ir\ir_ui_view.py", line 266, in _inverse_arch

    view.write(data)

  File "C:\Program Files (x86)\Odoo 11.0\server\odoo\addons\base\ir\ir_ui_view.py", line 414, in write

    return super(View, self).write(self._compute_defaults(vals))

  File "C:\Program Files (x86)\Odoo 11.0\server\odoo\models.py", line 3090, in write

    self._write(old_vals)

  File "C:\Program Files (x86)\Odoo 11.0\server\odoo\models.py", line 3256, in _write

    self._validate_fields(vals)

  File "C:\Program Files (x86)\Odoo 11.0\server\odoo\models.py", line 1040, in _validate_fields

    raise ValidationError("%s\n\n%s" % (_("Error while validating constraint"), tools.ustr(e)))

odoo.exceptions.ValidationError: ("Erreur lors de la validation de la contrainte\n\nLe champ `Num_Contract` n'existe pas\n\nContexte de l'erreur :\nVue `project.task.form`\n[view_id: 703, xml_id: project.view_task_form2, model: project.task, parent_id: n/a]", None)


During handling of the above exception, another exception occurred:


Traceback (most recent call last):

  File "C:\Program Files (x86)\Odoo 11.0\server\odoo\http.py", line 650, in _handle_exception

    return super(JsonRequest, self)._handle_exception(exception)

  File "C:\Program Files (x86)\Odoo 11.0\server\odoo\http.py", line 310, in _handle_exception

    raise pycompat.reraise(type(exception), exception, sys.exc_info()[2])

  File "C:\Program Files (x86)\Odoo 11.0\server\odoo\tools\pycompat.py", line 87, in reraise

    raise value

  File "C:\Program Files (x86)\Odoo 11.0\server\odoo\http.py", line 692, in dispatch

    result = self._call_function(**self.params)

  File "C:\Program Files (x86)\Odoo 11.0\server\odoo\http.py", line 342, in _call_function

    return checked_call(self.db, *args, **kwargs)

  File "C:\Program Files (x86)\Odoo 11.0\server\odoo\service\model.py", line 97, in wrapper

    return f(dbname, *args, **kwargs)

  File "C:\Program Files (x86)\Odoo 11.0\server\odoo\http.py", line 335, in checked_call

    result = self.endpoint(*a, **kw)

  File "C:\Program Files (x86)\Odoo 11.0\server\odoo\http.py", line 936, in __call__

    return self.method(*args, **kw)

  File "C:\Program Files (x86)\Odoo 11.0\server\odoo\http.py", line 515, in response_wrap

    response = f(*args, **kw)

  File "C:\Program Files (x86)\Odoo 11.0\server\odoo\addons\web\controllers\main.py", line 935, in call_button

    action = self._call_kw(model, method, args, {})

  File "C:\Program Files (x86)\Odoo 11.0\server\odoo\addons\web\controllers\main.py", line 923, in _call_kw

    return call_kw(request.env[model], method, args, kwargs)

  File "C:\Program Files (x86)\Odoo 11.0\server\odoo\api.py", line 689, in call_kw

    return call_kw_multi(method, model, args, kwargs)

  File "C:\Program Files (x86)\Odoo 11.0\server\odoo\api.py", line 680, in call_kw_multi

    result = method(recs, *args, **kwargs)

  File "<decorator-gen-46>", line 2, in button_immediate_upgrade

  File "C:\Program Files (x86)\Odoo 11.0\server\odoo\addons\base\module\module.py", line 71, in check_and_log

    return method(self, *args, **kwargs)

  File "C:\Program Files (x86)\Odoo 11.0\server\odoo\addons\base\module\module.py", line 602, in button_immediate_upgrade

    return self._button_immediate_function(type(self).button_upgrade)

  File "C:\Program Files (x86)\Odoo 11.0\server\odoo\addons\base\module\module.py", line 541, in _button_immediate_function

    modules.registry.Registry.new(self._cr.dbname, update_module=True)

  File "C:\Program Files (x86)\Odoo 11.0\server\odoo\modules\registry.py", line 85, in new

    odoo.modules.load_modules(registry._db, force_demo, status, update_module)

  File "C:\Program Files (x86)\Odoo 11.0\server\odoo\modules\loading.py", line 339, in load_modules

    force, status, report, loaded_modules, update_module)

  File "C:\Program Files (x86)\Odoo 11.0\server\odoo\modules\loading.py", line 242, in load_marked_modules

    loaded, processed = load_module_graph(cr, graph, progressdict, report=report, skip_modules=loaded_modules, perform_checks=perform_checks)

  File "C:\Program Files (x86)\Odoo 11.0\server\odoo\modules\loading.py", line 156, in load_module_graph

    _load_data(cr, module_name, idref, mode, kind='data')

  File "C:\Program Files (x86)\Odoo 11.0\server\odoo\modules\loading.py", line 94, in _load_data

    tools.convert_file(cr, module_name, filename, idref, mode, noupdate, kind, report)

  File "C:\Program Files (x86)\Odoo 11.0\server\odoo\tools\convert.py", line 791, in convert_file

    convert_xml_import(cr, module, fp, idref, mode, noupdate, report)

  File "C:\Program Files (x86)\Odoo 11.0\server\odoo\tools\convert.py", line 852, in convert_xml_import

    obj.parse(doc.getroot(), mode=mode)

  File "C:\Program Files (x86)\Odoo 11.0\server\odoo\tools\convert.py", line 751, in parse

    exc_info[2]

  File "C:\Program Files (x86)\Odoo 11.0\server\odoo\tools\pycompat.py", line 86, in reraise

    raise value.with_traceback(tb)

  File "C:\Program Files (x86)\Odoo 11.0\server\odoo\tools\convert.py", line 744, in parse

    self._tags[rec.tag](rec, de, mode=mode)

  File "C:\Program Files (x86)\Odoo 11.0\server\odoo\tools\convert.py", line 654, in _tag_record

    id = self.env(context=rec_context)['ir.model.data']._update(rec_model, self.module, res, rec_id or False, not self.isnoupdate(data_node), noupdate=self.isnoupdate(data_node), mode=self.mode)

  File "C:\Program Files (x86)\Odoo 11.0\server\odoo\addons\base\ir\ir_model.py", line 1437, in _update

    record.write(values)

  File "C:\Program Files (x86)\Odoo 11.0\server\odoo\addons\base\ir\ir_ui_view.py", line 414, in write

    return super(View, self).write(self._compute_defaults(vals))

  File "C:\Program Files (x86)\Odoo 11.0\server\odoo\models.py", line 3108, in write

    field.determine_inverse(records)

  File "C:\Program Files (x86)\Odoo 11.0\server\odoo\fields.py", line 1071, in determine_inverse

    getattr(records, self.inverse)()

  File "C:\Program Files (x86)\Odoo 11.0\server\odoo\addons\base\ir\ir_ui_view.py", line 266, in _inverse_arch

    view.write(data)

  File "C:\Program Files (x86)\Odoo 11.0\server\odoo\addons\base\ir\ir_ui_view.py", line 414, in write

    return super(View, self).write(self._compute_defaults(vals))

  File "C:\Program Files (x86)\Odoo 11.0\server\odoo\models.py", line 3090, in write

    self._write(old_vals)

  File "C:\Program Files (x86)\Odoo 11.0\server\odoo\models.py", line 3256, in _write

    self._validate_fields(vals)

  File "C:\Program Files (x86)\Odoo 11.0\server\odoo\models.py", line 1040, in _validate_fields

    raise ValidationError("%s\n\n%s" % (_("Error while validating constraint"), tools.ustr(e)))

odoo.tools.convert.ParseError: "Erreur lors de la validation de la contrainte


Le champ `Num_Contract` n'existe pas


Contexte de l'erreur :

Vue `project.task.form`

[view_id: 703, xml_id: project.view_task_form2, model: project.task, parent_id: n/a]

None" while parsing file:/c:/program files (x86)/odoo 11.0/server/odoo/addons/project/views/project_views.xml:380, near

<record id="view_task_form2" model="ir.ui.view">

            <field name="name">project.task.form</field>

            <field name="model">project.task</field>

            <field eval="2" name="priority"/>

            <field name="arch" type="xml">

                <form string="Task" class="o_form_project_tasks">

                    <header>

                        <button name="action_assign_to_me" string="Assign to Me" type="object" class="oe_highlight" attrs="{'invisible' : [('user_id', '!=', False)]}"/>


                        <field name="stage_id" widget="statusbar" clickable="True" options="{'fold_field': 'fold'}"/>

                    </header>

                    <sheet string="Task">

                    <div class="oe_button_box" name="button_box">

                        <button class="oe_stat_button" icon="fa-tasks" type="object" name="action_open_parent_task" string="Parent Task" attrs="{'invisible' : [('parent_id', '=', False)]}" groups="project.group_subtask_project"/>

                        <button name="action_subtask" type="object" class="oe_stat_button" icon="fa-tasks" attrs="{'invisible' : [('parent_id', '!=', False)]}" context="{'project_id': subtask_project_id, 'name': name, 'partner_id': partner_id}" groups="project.group_subtask_project">

                            <field string="Sub-tasks" name="subtask_count" widget="statinfo"/>

                        </button>

                        <button name="toggle_active" type="object" groups="base.group_user" class="oe_stat_button" icon="fa-archive">

                            <field name="active" widget="boolean_button" options="{&quot;terminology&quot;: &quot;archive&quot;}"/>

                        </button>

                    </div>

                    <field name="kanban_state" widget="state_selection"/>

                    <div class="oe_title">

                        <h1 class="o_row">

                            <field name="priority" widget="priority"/>

                            <field name="name" placeholder="Task Title..."/>

                        </h1>

                    </div>

                    <group>

                        <group>

                            <field name="project_id" domain="[('active', '=', True)]"/>

                            <field name="user_id" class="o_task_user_field" options="{&quot;no_open&quot;: True}"/>

                            <field name="legend_blocked" invisible="1"/>

                            <field name="legend_normal" invisible="1"/>

                            <field name="legend_done" invisible="1"/>

                        </group>

                        <group>

                            <field name="date_deadline"/>

                            <field name="tag_ids" widget="many2many_tags" options="{'color_field': 'color', 'no_create_edit': True}"/>

                        </group>

                    </group>

                    <notebook>

                        <page name="Information_page" string="Information">

                            <field name="Num_Contract" type="Char"/>

                        </page>

                        <page name="Stakeholder_Management_page" string="Stakeholder Management">

                            <field name="description" type="html"/>

                            <div class="oe_clear"/>

                        </page>

                        <page name="Communication_page" string="Communication">

                            <field name="description" type="html"/>

                            <div class="oe_clear"/>

                        </page>

                        <page name="Contract_page" string="Contract">

                            <field name="description" type="html"/>

                            <div class="oe_clear"/>

                        </page>

                        <page name="Management_Documents_page" string="Management of Documents">

                            <field name="description" type="html"/>

                            <div class="oe_clear"/>

                        </page>

                        <page name="List_of_tasks_page" string="List of tasks to be done">

                            <field name="description" type="html"/>

                            <div class="oe_clear"/>

                        </page>

                        <page name="extra_info" string="Extra Info">

                            <group>

                                <group>

                                    <field name="sequence" groups="base.group_no_one"/>

                                    <field name="partner_id"/>

                                    <field name="email_from"/>

                                    <field name="email_cc" groups="base.group_no_one"/>

                                    <field name="parent_id" groups="project.group_subtask_project"/>

                                    <field name="child_ids" invisible="1"/>

                                    <field name="subtask_project_id" invisible="1"/>

                                    <field name="company_id" groups="base.group_multi_company" options="{'no_create': True}"/>

                                    <field name="displayed_image_id" groups="base.group_no_one"/>

                                </group>

                                <group>

                                    <field name="date_assign" groups="base.group_no_one"/>

                                    <field name="date_last_stage_update" groups="base.group_no_one"/>

                                </group>

                                <group string="Working Time to Assign" attrs="{'invisible': [('working_hours_open', '=', 0.0)]}">

                                    <field name="working_hours_open" string="Hours"/>

                                    <field name="working_days_open" string="Days"/>

                                </group>

                                <group string="Working Time to Close" attrs="{'invisible': [('working_hours_close', '=', 0.0)]}">

                                    <field name="working_hours_close" string="Hours"/>

                                    <field name="working_days_close" string="Days"/>

                                </group>

                            </group>

                        </page>

                    </notebook>

                    </sheet>

                    <div class="oe_chatter">

                        <field name="message_follower_ids" widget="mail_followers" groups="base.group_user"/>

                        <field name="activity_ids" widget="mail_activity"/>

                        <field name="message_ids" widget="mail_thread"/>

                    </div>

                </form>

            </field>

        </record>

Someone know what is the preoblem?

1 Comentario
Avatar
Descartar

Please restart the odoo service and see whether you have the issue or not.

Also while posting the error message, only post the last few lines of it.

5 Respuestas
7
Avatar
Ashish Singh
Best Answer

Hi, Orveau


As per traceback it seems that field is not present at your Odoo that's why you are getting this issue. So please follow below steps in order to fix this issue,

Solution 1:

  • Restart your Odoo server

  • Then go the applist.

  • And if you made changes (related to the field) directly in project module then search project extension inside applist else search your custom module where you made changes.

  • Then click on the upgrade button.

  • After that field will be successfully created at Odoo end.

Solution 2:

In case due to the server error you are not able to access your Odoo then you can upgrade module via command line.

odoo-bin -d database -u <modules>
  • You can find odoo-bin file inside Odoo directory

  • Database: If you have multiple database then you can pass database name where you made these changes.

  • Module: Which you want to upgrade like in your case project or custom module.

Thanks,
Ashish Singh (Team Lead)
Webkul Software Private Limited

Avatar
Descartar
0
Best Answer

Dear Ashish Singh

I'm using solution 2 and if I modify an xml file it works without problem. but if I try to add a new field (in the two files py and xml) I get the same exception 

ValueError: Le champ `autre_info` n'existe pas Contexte de l'erreur : Vue `Tanit Land Lot Form View` [view_id: 500, xml_id: tanit_land_contract.tanit_land_lot_view_form, model: tanit.land.lot, parent_id: n/a]

can you help me ?
Avatar
Descartar
0
Best Answer

Please have any one solve this issue, i have been having same issues all time i restart my odoo12 service. but after some hour the problem is fixed automatically..PLEASE i need permanent solutions 

Error line code:

  File "/opt/odoo/odoo/odoo/addons/base/models/ir_ui_view.py", line 1096, in postprocess_and_fields
    self.raise_view_error(message, view_id)
  File "/opt/odoo/odoo/odoo/addons/base/models/ir_ui_view.py", line 548, in raise_view_error
    raise ValueError(message)
ValueError: Le champ `report_template_id` n'existe pas

Contexte de l'erreur :
Vue `res.partner.form`
[view_id: 113, xml_id: base.view_partner_form, model: res.partner, parent_id: n/a]
2 Comentarios
Avatar
Descartar
Avatar
Ashish Singh
-

Hi,

Kindly share the view file in order to check this issue.

As per the issue it seems "report_template_id" field is not present inside the "res.partner" model.

Thanks,

Ashish Singh

please here is my res_partner_view

<?xml version="1.0" encoding="utf-8"?>

<odoo>

<data>

<!-- Inherited Customer For add Reporting Field -->

<record id="view_report_partner_sale_order" model="ir.ui.view">

<field name="name">res.partner.invoice.template.form.inherit</field>

<field name="inherit_id" ref="base.view_partner_form"/>

<field name="model">res.partner</field>

<field name="arch" type="xml">

<xpath expr="//page[@name='sales_purchases']" position="after">

<page name="report" string="Report Configuration">

<group string="Default Report Settings">

<group>

<field domain="[('report_name', 'ilike', '%invoice_template%')]" name="report_template_id" options="{'no_create': True}"/>

<field invisible="1" name="report_template_id1"/>

<field domain="[('report_name', 'ilike', '%sale_order%')]" name="report_sale_template_id" options="{'no_create': True}"/>

<field invisible="1" name="report_sale_template_id1"/>

<field invisible="1" name="report_delivery_template_id1"/>

<field domain="[('report_name', 'ilike', '%delivery_c%')]" name="report_delivery_template_id" options="{'no_create': True}"/>

</group>

<group>

<field invisible="1" name="report_po_template_id1"/>

<field domain="[('report_name', 'ilike', '%purchase_c%')]" name="report_po_template_id" options="{'no_create': True}"/>

<field domain="[('report_name', 'ilike', '%purchase_c%')]" name="report_rfq_template_id" options="{'no_create': True}"/>

<field domain="[('report_name', 'ilike', '%delivery_c%')]" name="report_picking_template_id" options="{'no_create': True}"/>

</group>

</group>

</page>

</xpath>

</field>

</record>

</data>

</odoo>

0
Avatar
Orveau
Best Answer

I have found that it is because the field num_contract isn't in the database project.task, so i have to install it manually, but how can i install directly with the code ?

Avatar
Descartar
-1
Best Answer

Dear Orveau


Try to change your letters of  field name to small case


I hope I helped you...

Avatar
Descartar