Q:

Odoo: how to show fields of a many2one fields which is inside a one2many field

I don't know how to put it but here's what i want, i want to show the fields of a custom.product model in the tree view of a one2many field my code is as follows
class CustomSale(models.Model):
    _name = 'custom.sale'
    _description = 'Sale Record'

    name = fields.Char(string='Order Reference', required=True, copy=False, readonly=True,
                       default=lambda self: _('New'))
    order_line = fields.One2many('custom.sale.line', 'order_id', string='Order Lines', copy=True,
                                 auto_join=True)

class CustomSaleLine(models.Model):
    _name = 'custom.sale.line'
    _description = 'Sales Line'

    order_id = fields.Many2one('custom.sale', string='Order Reference', required=True,)

    product_id = fields.Many2one('custom.product', string='Product', change_default=True, ondelete='restrict')
    product_uom_qty = fields.Integer(string='Ordered Quantity', required=True, )

<record id="form_custom_sale" model="ir.ui.view">
        <field name="name">custom.sale.form</field>
        <field name="model">custom.sale</field>
        <field name="arch" type="xml">
            <form string="Sales">
                <sheet>
                    <group>
                        <group>
                            <field name="name"/>
                        </group>
                    </group>
                    <notebook>
                        <page string="Order Lines" name="order_lines">
                            <field name="order_line" widget="section_and_note_one2many" mode="tree">
                                <tree editable="bottom">
                                    <control>
                                        <create string="Add a product"/>
                                    </control>
                                    <field name="product_id">
                                        <tree>
                                            <field name="brand_id"/>
                                            <field name="country_id"/>
                                            <field name="sell_price"/>
                                        </tree>
                                    </field>
                                    <field name="product_uom_qty" string="Ordered Qty"/>
                                </tree>
                            </field>
                        </page>
                    </notebook>
                </sheet>
            </form>
        </field>
    </record>

yet i still can't get "brand_id", "country_id" and "sell_price" shown

A:

Add related field for fields you want to display in the tree view.
class CustomSaleLine(models.Model):
    _name = 'custom.sale.line'
    _description = 'Sales Line'

    order_id = fields.Many2one('custom.sale', string='Order Reference', required=True,)

    product_id = fields.Many2one('custom.product', string='Product', change_default=True, ondelete='restrict')
    product_uom_qty = fields.Integer(string='Ordered Quantity', required=True, )
    brand_id = fields.Many2one('BRAND_MODEL_HERE',related='product_id.brand_id')
    country_id = fields.Many2one('COUNTRY_MODEL_HERE',related='product_id.country_id')
    sell_price = fields.Float(related='product_id.sell_price')

<record id="form_custom_sale" model="ir.ui.view">
    <field name="name">custom.sale.form</field>
    <field name="model">custom.sale</field>
    <field name="arch" type="xml">
        <form string="Sales">
            <sheet>
                <group>
                    <group>
                        <field name="name"/>
                    </group>
                </group>
                <notebook>
                    <page string="Order Lines" name="order_lines">
                        <field name="order_line" widget="section_and_note_one2many" mode="tree">
                            <tree editable="bottom">
                                <control>
                                    <create string="Add a product"/>
                                </control>
                                <field name="product_id">
                                <field name="brand_id"/>
                                <field name="country_id"/>
                                <field name="sell_price"/>
                                <field name="product_uom_qty" string="Ordered Qty"/>
                            </tree>
                        </field>
                    </page>
                </notebook>
            </sheet>
        </form>
    </field>
</record>

