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

I'm trying to get a field "planned_qty" to the same value as "product_qty" when its created but I'm not having any luck. I thought all I needed to do was define the field like below and default = product_qty. But alas its not that easy. Can someone advise?

planned_qty = fields.Float( 'Planned Quantity', digits = dp.get_precision( 'Product Unit of Measure' ) )
อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

1) create fields like:

'product_qty': fields.float(string='Product Qty'),

'planned_qty': fields.float(string='Planned Quantity'),

2)define in xml

<field name="planned_qty" on_change="onchange_planned_qty(planned_qty)"/>
<field name="product_qty" on_change="onchange_product_qty(product_qty)"/>

3) call onchange function

def onchange_product_qty(self, cr, uid, ids, product_qty, context=None):
        if product_qty:
            return {'value': {''planned_qty': product_qty}}  

      else:
            return {'value':{''planned_qty': ''}}


    def onchange_'planned_qty(self, cr, uid, ids, 'planned_qty, context=None):
        if planned_qty:
            return {'value': {'product_qty': planned_qty}} 

       else:
            return {'value': {'product_qty': ''}}


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

In odoo 14, try "post_init_hook"

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
1
ส.ค. 23
3868
0
ธ.ค. 24
1323
Import Data From Another Model แก้ไขแล้ว
1
มี.ค. 24
2373
1
มิ.ย. 23
12379
0
ม.ค. 23
3098