i am trying to add a simple field to the odoo sale.order model (Odoo 14) but it doesn't work.
this is what my py model looks like
from odoo import models, fields
class SaleOrder(models.Model): _inherit = 'sale.order'
additional_field = fields.Text(string="weitere Notizen (Debug only)")and this is what my xml file looks like
sale.order.form
sale.order
Odoo Server ErrorTraceback (most recent call last): File "/usr/lib/python3/dist-packages/odoo/tools/convert.py", line 677, in _tag_root f(rec) File "/usr/lib/python3/dist-packages/odoo/tools/convert.py", line 580, in _tag_record record = model._load_records([data], self.mode == 'update') File "/usr/lib/python3/dist-packages/odoo/models.py", line 4213, in _load_records records = self._load_records_create([data['values'] for data in to_create]) File "/usr/lib/python3/dist-packages/odoo/models.py", line 4142, in _load_records_create return self.create(values) File "", line 2, in create File "/usr/lib/python3/dist-packages/odoo/api.py", line 345, in _model_create_multi return create(self, arg) File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_ui_view.py", line 482, in create return super(View, self).create(vals_list) File "", line 2, in create File "/usr/lib/python3/dist-packages/odoo/api.py", line 345, in _model_create_multi return create(self, arg) File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_fields.py", line 534, in create recs = super().create(vals_list) File "", line 2, in create File "/usr/lib/python3/dist-packages/odoo/api.py", line 345, in _model_create_multi return create(self, arg) File "/usr/lib/python3/dist-packages/odoo/models.py", line 3903, in create fields[0].determine_inverse(batch_recs) File "/usr/lib/python3/dist-packages/odoo/fields.py", line 1185, in determine_inverse getattr(records, self.inverse)() File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_ui_view.py", line 300, in _inverse_arch view.write(data) File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_ui_view.py", line 500, in write res = super(View, self).write(self._compute_defaults(vals)) File "/usr/lib/python3/dist-packages/odoo/models.py", line 3687, in write real_recs._validate_fields(vals, inverse_fields) File "/usr/lib/python3/dist-packages/odoo/models.py", line 1266, in _validate_fields check(self) File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_ui_view.py", line 411, in _check_xml )).with_traceback(e.__traceback__) from None File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_ui_view.py", line 391, in _check_xml view.postprocess_and_fields(view_doc, validate=True) File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_ui_view.py", line 851, in postprocess_and_fields arch, name_manager = self._postprocess_view(node, model, validate=validate) File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_ui_view.py", line 858, in _postprocess_view self.handle_view_error(_('Model not found: %(model)s', model=model)) File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_ui_view.py", line 673, in handle_view_error raise ValueError(formatted_message).with_traceback(from_traceback) from from_exception odoo.exceptions.ValidationError: Error while validating view: Konnte Modell nicht finden: sale.order View name: sale.order.form Error context: view: ir.ui.view(3629,) xmlid: view_order_form_inherit view.model: sale.order view.parent: ir.ui.view(994,) file: /mnt/extra-addons/rectanglemaps/views/saleorder.xml The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_http.py", line 237, in _dispatch result = request.dispatch() File "/usr/lib/python3/dist-packages/odoo/http.py", line 684, in dispatch result = self._call_function(**self.params) File "/usr/lib/python3/dist-packages/odoo/http.py", line 360, in _call_function return checked_call(self.db, *args, **kwargs) File "/usr/lib/python3/dist-packages/odoo/service/model.py", line 94, in wrapper return f(dbname, *args, **kwargs) File "/usr/lib/python3/dist-packages/odoo/http.py", line 348, in checked_call result = self.endpoint(*a, **kw) File "/usr/lib/python3/dist-packages/odoo/http.py", line 913, in __call__ return self.method(*args, **kw) File "/usr/lib/python3/dist-packages/odoo/http.py", line 532, in response_wrap response = f(*args, **kw) File "/usr/lib/python3/dist-packages/odoo/addons/web/controllers/main.py", line 1393, in call_button action = self._call_kw(model, method, args, kwargs) File "/usr/lib/python3/dist-packages/odoo/addons/web/controllers/main.py", line 1381, in _call_kw return call_kw(request.env[model], method, args, kwargs) File "/usr/lib/python3/dist-packages/odoo/api.py", line 396, in call_kw result = _call_kw_multi(method, model, args, kwargs) File "/usr/lib/python3/dist-packages/odoo/api.py", line 383, in _call_kw_multi result = method(recs, *args, **kwargs) File "", line 2, in button_immediate_upgrade File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_module.py", line 74, in check_and_log return method(self, *args, **kwargs) File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_module.py", line 654, in button_immediate_upgrade return self._button_immediate_function(type(self).button_upgrade) File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_module.py", line 593, in _button_immediate_function modules.registry.Registry.new(self._cr.dbname, update_module=True) File "/usr/lib/python3/dist-packages/odoo/modules/registry.py", line 89, in new odoo.modules.load_modules(registry._db, force_demo, status, update_module) File "/usr/lib/python3/dist-packages/odoo/modules/loading.py", line 456, in load_modules force, status, report, loaded_modules, update_module, models_to_check) File "/usr/lib/python3/dist-packages/odoo/modules/loading.py", line 348, in load_marked_modules perform_checks=perform_checks, models_to_check=models_to_check File "/usr/lib/python3/dist-packages/odoo/modules/loading.py", line 221, in load_module_graph load_data(cr, idref, mode, kind='data', package=package) File "/usr/lib/python3/dist-packages/odoo/modules/loading.py", line 69, in load_data tools.convert_file(cr, package.name, filename, idref, mode, noupdate, kind) File "/usr/lib/python3/dist-packages/odoo/tools/convert.py", line 733, in convert_file convert_xml_import(cr, module, fp, idref, mode, noupdate) File "/usr/lib/python3/dist-packages/odoo/tools/convert.py", line 799, in convert_xml_import obj.parse(doc.getroot()) File "/usr/lib/python3/dist-packages/odoo/tools/convert.py", line 719, in parse self._tag_root(de) File "/usr/lib/python3/dist-packages/odoo/tools/convert.py", line 677, in _tag_root f(rec) File "/usr/lib/python3/dist-packages/odoo/tools/convert.py", line 685, in _tag_root )) from e Exception The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/usr/lib/python3/dist-packages/odoo/http.py", line 640, in _handle_exception return super(JsonRequest, self)._handle_exception(exception) File "/usr/lib/python3/dist-packages/odoo/http.py", line 316, in _handle_exception raise exception.with_traceback(None) from new_cause odoo.tools.convert.ParseError: while parsing /mnt/extra-addons/rectanglemaps/views/saleorder.xml:4, near sale.order.form sale.order
what am I doing wrong? thank you.
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Accounting
- Inventory
- PoS
- Project management
- MRP
This question has been flagged
In Python
class SaleOrder(models.Model):
_inherit = "sale.order"
description_sale = fields.Text('Sales Description')
and the views in a comment
<record id="view_sale_order_custom" model="ir.ui.view">
<field name="name">view.sale.order.custom</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="description_sale" filter_domain="[('description_sale', 'ilike',self)]"/>
</xpath>
</field>
</record>
Hi,
In PY
class SaleOrder(models.Model):
"""Adds the fields for options of the customer order delivery"""
_inherit = "sale.order"
_description = 'Sale Order'
latitude = fields.Char(
string='Latitude',
required=False)
longitude = fields.Char(
string='Longitude',
required=False)
In XML
<record id="view_customer_order_delivery_lat_long_inherited" model="ir.ui.view">
<field name="name">view.customer.order.delivery.sale.order.form.view.inherited</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="latitude" force_save="1" invisible="1"/>
<field name="longitude" force_save="1" invisible="1"/>
</xpath>
</field>
</record>
</odoo>
hello how to limit number of records per page on qweb
Please check the below link:
https://www.odoo.com/forum/help-1/add-custom-fields-to-sales-order-45074
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign up