Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
3 Odpowiedzi
185 Widoki

How can I add additional column that is not on the option list in the quotation display?

Let say I want to add-in Customer Reference? I'm only restricted to what Odoo can show me in the options when I click the 3 dots.

So in a sense, I'm looking for a way to customize that option list. 

I don't want to use the Studio as much as possible.


Any help will be greatly appreciated.

Awatar
Odrzuć
Najlepsza odpowiedź

Hi


To add a custom column like "Customer Reference" to the quotation display in Odoo without using Odoo Studio, you'll need to create a custom module. This approach allows you to implement customizations without directly altering Odoo's core code. The key is to inherit the quotation tree view, which is responsible for displaying quotations. You can identify this view and then, in your custom module's XML file, use <record> and <field> tags to inherit and modify it.


Next, define the custom field (e.g., x_customer_ref) in your module's Python file within the sale.order model. Then, in the inherited tree view, add a <field> tag to include your custom field, specifying the name attribute as the name of your custom field (e.g., x_customer_ref). Finally, ensure that the field is added to the view in a way that it becomes visible in the quotation display. Remember to update your module and the quotation view to reflect these changes.


Python


from odoo import models, fields


class SaleOrder(models.Model):

    _inherit = 'sale.order'


    customer_ref = fields.Char(string='Customer Reference')


XML


<odoo>

    <data>

        <!-- Inherit Sale Order Tree View -->

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

            <field name="name">sale.order.tree.inherit</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='name']" position="after">

                    <field name="customer_ref" optional="hide"/>

                </xpath>

            </field>

        </record>

    </data>

</odoo>


Hope it helps

Awatar
Odrzuć
Autor Najlepsza odpowiedź

Hi Fezan!

Thank you for this, but for some weird reason, I don't have the View Type: List.

But I managed to make it work! Pointing me the User Interface > Views gave me a clue where to edit it.

Kind regards,

John

Awatar
Odrzuć
Najlepsza odpowiedź

Navigate to Settings, then Technical.


From the User Interfaces dropdown, select Views.


Click the New button.


Enter the Name: Custom Quotation List with Customer Ref


Set the View Type to: List


Set the Model of the view to: Sale Order


Set the Inherited View to: sale.order.tree


Set the View Inherited Model to: base View


Set the Sequence to: 16


Toggle Active to Green.


In the Architecture editor, input the following code:


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


<field name="client_order_ref" optional="hide"/>


</xpath>


The form should now appear as shown.


Subsequently, return to the Quotations and select Customer Reference from the list by clicking on the three dots.


Hope It will help, Happy Odoo John!

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
1
sie 25
606
2
lip 25
975
1
cze 25
980
2
cze 25
1225
2
maj 25
1317