Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
2333 Lượt xem

I am attempting to pull data from one Field named date_order (in Model sale.order) into Model sale.order.line.

Below is the current code from the view as it exists.

Is it possible to pull in the Field named date_order from Model sale.order into this view?


I have tried different ways to get my example code in here, but have been unsuccesful.

It is either blank when I save it or deemed Forbidden when I paste it in.

Ảnh đại diện
Huỷ bỏ
Tác giả

Cybrosys Techno Solutions...
Your solution solved my issue. But I don't have enough Karma to mark it as solved.

Câu trả lời hay nhất

Hi,

I think you are trying pass the sale.order date to another model sale.order.line to achieve this use related:

from odoo import models, fields

class SaleOrderLine(models.Model):
    _inherit = 'sale.order.line'

order_date = fields.Datetime(related='order_id.date_order', string='Order Date')


In the XML View:

<record model="ir.ui.view" id="sale_order_line_view_inherit">
<field name="name">sale.order.line.view.inherit</field>
<field name="model">sale.order.line</field>
<field name="inherit_id" ref="sale.view_order_line_tree"/>

    <field name="arch" type="xml">
<xpath expr="field[@name='price_unit']" position="after">
            <field name="order_date"/> </xpath>
    </field>
</record>



Hope it helps


Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 12 24
1294
1
thg 6 23
12335
0
thg 1 23
3023
2
thg 9 20
3992
6
thg 9 20
29427