Hello,
I am currently having a problem with Odoo. I have created a module to add a "title" field to the quotes and purchase order of the sales module, when I install my module everything works but now I can no longer update the sales module and the sales management module. When I try to update them I have the following error: "the field` title_id` does not exist ". Moreover when I uninstall my custom module I can no longer access the Odoo modules, I get the same error as during the update.
Here is my code :
my model:
from odoo import fields, models, api
class SaleTitre(models.Model):
_inherit='sale.order'
_name='sale.order'
titre_id=fields.Char('Titre', size=250, store=True)
@api.multi
def _prepare_invoice(self):
values = super(SaleTitre, self)._prepare_invoice()
values.update({
'titre_rel': self.titre_id,
})
return values
class InvoiceTitre(models.Model):
_inherit='account.invoice'
_name='account.invoice'
titre_rel=fields.Char('Titre',size=250, store=True)
My views :
<?xml version="1.0"?>
<odoo>
<data>
<record id="sale.view_quotation_tree_extend" model="ir.ui.view">
<field name="name"> sale.order.quotation.tree.titre</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_quotation_tree"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='partner_id']" position="after">
<field name="titre_id" groups="base.group_user"/>
</xpath>
</field>
</record>
<record id="sale.view_tree_extend" model="ir.ui.view">
<field name="name"> sale.order.tree.titre</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_tree"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='partner_id']" position="after">
<field name="titre_id" groups="base.group_user"/>
</xpath>
</field>
</record>
<record id="sale.view_invoice_tree_extend" model="ir.ui.view">
<field name="name"> sale.order.invoice.tree.titre</field>
<field name="model">account.invoice</field>
<field name="inherit_id" ref="account.invoice_tree"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='partner_id']" position="after">
<field name="titre_rel" groups="base.group_user"/>
</xpath>
</field>
</record>
<record id="sale.view_invoice_form_extend" model="ir.ui.view">
<field name="name"> sale.order.invoice.form.titre</field>
<field name="model">account.invoice</field>
<field name="inherit_id" ref="account.invoice_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='partner_id']" position="after">
<field name="titre_rel" groups="base.group_user"/>
</xpath>
</field>
</record>
<record id="sale.view_order_form_extend" model="ir.ui.view">
<field name="name"> sale.order.form.titre</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='payment_term_id']" position="after">
<field name="titre_id"/>
</xpath>
</field>
</record>
<record id="sale.view_quotation_titre_search" model="ir.ui.view">
<field name="name"> sale.order.tree.titre.search</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_sales_order_filter"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='name']" position="after">
<field name="titre_id"/>
</xpath>
</field>
</record>
<record id="account.view_invoice_titre_search" model="ir.ui.view">
<field name="name"> sale.order.tree.titre.search</field>
<field name="model">account.invoice</field>
<field name="inherit_id" ref="account.view_account_invoice_filter"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='number']" position="after">
<field name="titre_rel"/>
</xpath>
</field>
</record>
</data>
</odoo>
My manifest:
# -*- coding: utf-8 -*-
{
'name': ' Gestion des ventes-Ajout du champs Titre',
'description': """
Pouvoir définir un titre aux devis/Bon de commande et factures
+
Transmission du titre lors de la génération de la facture à partir d'un devis/Bon de commande
""",
'author': 'Rockyozen',
'depends': ['sale'],
'data': ['views/sale_titre.xml'],
'application': False,
}
The error :
Traceback (most recent call last): File "/opt/odoo/odoo11/odoo/models.py", line 1057, in _validate_fields check(self) File "/opt/odoo/odoo11/odoo/addons/base/ir/ir_ui_view.py", line 342, in _check_xml self.postprocess_and_fields(view.model, view_doc, view.id) File "/opt/odoo/odoo11/odoo/addons/base/ir/ir_ui_view.py", line 1083, in postprocess_and_fields self.raise_view_error(message, view_id) File "/opt/odoo/odoo11/odoo/addons/base/ir/ir_ui_view.py", line 533, in raise_view_error raise ValueError(message) ValueError: Le champ `titre_id` n'existe pas Contexte de l'erreur : Vue `sale.order.tree` [view_id: 652, xml_id: sale.view_order_tree, model: sale.order, parent_id: n/a] During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/opt/odoo/odoo11/odoo/tools/convert.py", line 745, in parse self._tags[rec.tag](rec, de, mode=mode) File "/opt/odoo/odoo11/odoo/tools/convert.py", line 655, 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 "/opt/odoo/odoo11/odoo/addons/base/ir/ir_model.py", line 1488, in _update record.write(values) File "/opt/odoo/odoo11/odoo/addons/base/ir/ir_ui_view.py", line 425, in write res = super(View, self).write(self._compute_defaults(vals)) File "/opt/odoo/odoo11/odoo/models.py", line 3184, in write field.determine_inverse(records) File "/opt/odoo/odoo11/odoo/fields.py", line 1092, in determine_inverse getattr(records, self.inverse)() File "/opt/odoo/odoo11/odoo/addons/base/ir/ir_ui_view.py", line 273, in _inverse_arch view.write(data) File "/opt/odoo/odoo11/odoo/addons/base/ir/ir_ui_view.py", line 425, in write res = super(View, self).write(self._compute_defaults(vals)) File "/opt/odoo/odoo11/odoo/models.py", line 3164, in write self._write(old_vals) File "/opt/odoo/odoo11/odoo/models.py", line 3335, in _write self._validate_fields(vals) File "/opt/odoo/odoo11/odoo/models.py", line 1061, 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 `titre_id` n'existe pas\n\nContexte de l'erreur :\nVue `sale.order.tree`\n[view_id: 652, xml_id: sale.view_order_tree, model: sale.order, parent_id: n/a]", None) During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/opt/odoo/odoo11/odoo/http.py", line 653, in _handle_exception return super(JsonRequest, self)._handle_exception(exception) File "/opt/odoo/odoo11/odoo/http.py", line 312, in _handle_exception raise pycompat.reraise(type(exception), exception, sys.exc_info()[2]) File "/opt/odoo/odoo11/odoo/tools/pycompat.py", line 87, in reraise raise value File "/opt/odoo/odoo11/odoo/http.py", line 695, in dispatch result = self._call_function(**self.params) File "/opt/odoo/odoo11/odoo/http.py", line 344, in _call_function return checked_call(self.db, *args, **kwargs) File "/opt/odoo/odoo11/odoo/service/model.py", line 97, in wrapper return f(dbname, *args, **kwargs) File "/opt/odoo/odoo11/odoo/http.py", line 337, in checked_call result = self.endpoint(*a, **kw) File "/opt/odoo/odoo11/odoo/http.py", line 939, in __call__ return self.method(*args, **kw) File "/opt/odoo/odoo11/odoo/http.py", line 517, in response_wrap response = f(*args, **kw) File "/opt/odoo/odoo11/addons/web/controllers/main.py", line 939, in call_button action = self._call_kw(model, method, args, {}) File "/opt/odoo/odoo11/addons/web/controllers/main.py", line 927, in _call_kw return call_kw(request.env[model], method, args, kwargs) File "/opt/odoo/odoo11/odoo/api.py", line 699, in call_kw return call_kw_multi(method, model, args, kwargs) File "/opt/odoo/odoo11/odoo/api.py", line 690, in call_kw_multi result = method(recs, *args, **kwargs) File "<decorator-gen-51>", line 2, in button_immediate_upgrade File "/opt/odoo/odoo11/odoo/addons/base/module/module.py", line 72, in check_and_log return method(self, *args, **kwargs) File "/opt/odoo/odoo11/odoo/addons/base/module/module.py", line 618, in button_immediate_upgrade return self._button_immediate_function(type(self).button_upgrade) File "/opt/odoo/odoo11/odoo/addons/base/module/module.py", line 552, in _button_immediate_function modules.registry.Registry.new(self._cr.dbname, update_module=True) File "/opt/odoo/odoo11/odoo/modules/registry.py", line 85, in new odoo.modules.load_modules(registry._db, force_demo, status, update_module) File "/opt/odoo/odoo11/odoo/modules/loading.py", line 379, in load_modules force, status, report, loaded_modules, update_module, models_to_check) File "/opt/odoo/odoo11/odoo/modules/loading.py", line 274, in load_marked_modules perform_checks=perform_checks, models_to_check=models_to_check File "/opt/odoo/odoo11/odoo/modules/loading.py", line 181, in load_module_graph _load_data(cr, module_name, idref, mode, kind='data') File "/opt/odoo/odoo11/odoo/modules/loading.py", line 95, in _load_data tools.convert_file(cr, module_name, filename, idref, mode, noupdate, kind, report) File "/opt/odoo/odoo11/odoo/tools/convert.py", line 792, in convert_file convert_xml_import(cr, module, fp, idref, mode, noupdate, report) File "/opt/odoo/odoo11/odoo/tools/convert.py", line 853, in convert_xml_import obj.parse(doc.getroot(), mode=mode) File "/opt/odoo/odoo11/odoo/tools/convert.py", line 752, in parse exc_info[2] File "/opt/odoo/odoo11/odoo/tools/pycompat.py", line 86, in reraise raise value.with_traceback(tb) File "/opt/odoo/odoo11/odoo/tools/convert.py", line 745, in parse self._tags[rec.tag](rec, de, mode=mode) File "/opt/odoo/odoo11/odoo/tools/convert.py", line 655, 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 "/opt/odoo/odoo11/odoo/addons/base/ir/ir_model.py", line 1488, in _update record.write(values) File "/opt/odoo/odoo11/odoo/addons/base/ir/ir_ui_view.py", line 425, in write res = super(View, self).write(self._compute_defaults(vals)) File "/opt/odoo/odoo11/odoo/models.py", line 3184, in write field.determine_inverse(records) File "/opt/odoo/odoo11/odoo/fields.py", line 1092, in determine_inverse getattr(records, self.inverse)() File "/opt/odoo/odoo11/odoo/addons/base/ir/ir_ui_view.py", line 273, in _inverse_arch view.write(data) File "/opt/odoo/odoo11/odoo/addons/base/ir/ir_ui_view.py", line 425, in write res = super(View, self).write(self._compute_defaults(vals)) File "/opt/odoo/odoo11/odoo/models.py", line 3164, in write self._write(old_vals) File "/opt/odoo/odoo11/odoo/models.py", line 3335, in _write self._validate_fields(vals) File "/opt/odoo/odoo11/odoo/models.py", line 1061, 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 `titre_id` n'existe pas Contexte de l'erreur : Vue `sale.order.tree` [view_id: 652, xml_id: sale.view_order_tree, model: sale.order, parent_id: n/a] None" while parsing /opt/odoo/odoo11/addons/sale/views/sale_views.xml:148, near <record id="view_order_tree" model="ir.ui.view"> <field name="name">sale.order.tree</field> <field name="model">sale.order</field> <field name="priority">2</field> <field name="arch" type="xml"> <tree string="Sales Orders" decoration-bf="message_needaction==True" decoration-muted="state=='cancel'"> <field name="message_needaction" invisible="1"/> <field name="name" string="Order Number"/> <field name="confirmation_date" string="Confirmation Date"/> <field name="partner_id"/> <field name="user_id"/> <field name="amount_total" sum="Total Tax Included" widget="monetary"/> <field name="currency_id" invisible="1"/> <field name="invoice_status" invisible="1"/> <field name="state" invisible="1"/> </tree> </field> </record>