Hi,
In Odoo v17, if the message_main_attachment_id field has been
removed, you can recreate it in a custom module. Below is the corrected
and complete code to add the message_main_attachment_id field to the
sale.order model and update the form view to include this field.
Python code:
# -- coding: utf-8 --
from odoo import _, fields, models
class SaleOrder(models.Model):
_inherit = ‘sale.order'
message_main_attachment_id = fields.Many2one(
string="Main Attachment",
comodel_name='ir.attachment',
copy=False)
XML code:
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="view_sale_order_form" model="ir.ui.view">
<field name="name">view.sale.order.form</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="arch" type="xml">
<xpath expr="//div[hasclass('oe_chatter')]" position="before">
<div class="o_attachment_preview"/>
</xpath>
</field>
</record>
</odoo>
Hope it helps.