Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
2 ตอบกลับ
10091 มุมมอง

I want a datetime value to be inherited by default from other datetime value in the same view, but from other model.

Sale order lines will have a datetime field that, by default, take their value from a datetime field at sale_order model.

Anybody helping me?

I try adding _defaults when adding extra field as in:

class new_sale_order_line(osv.Model):

  
    _inherit = 'sale.order.line'
    _columns = {
        'date_finish': fields.datetime('Fecha fin'),
    }
    _defaults = {
        'date_finish' : 'inherited value????'

   }

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hello David,

You can do it with help of XML by assigning parent model field value to child as default value with the help of context.

Example:

<record id="view_order_form" model="ir.ui.view">
    <field name="name">sale.order.form</field>
    <field name="model">sale.order</field>
    <field name="arch" type="xml">
        <form string="Sales Order" version="7.0">
            <field name="name" />
            <field name="date_finish" />
            <field name="order_line" context="{'default_date_finish' : date_finish}">
                <form string="Sales Order Lines">
                    <field name="product_id" />
                    <field name="date_finish" />
                </form>
            </field>
        </form>
    </field>
</record>

Thanks.

 

อวตาร
ละทิ้ง
ผู้เขียน คำตอบที่ดีที่สุด

Thanks Nishant, It works!!! Thank you very much!

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
2
พ.ค. 23
1989
2
พ.ย. 21
7760
Sale - Override action_button_confirm() แก้ไขแล้ว
1
มี.ค. 17
8060
0
มี.ค. 15
5055
1
พ.ย. 24
3573