تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
3276 أدوات العرض

Hello,


I have 2 fields in stock.production.lot ( partner_id, product_id ).

In a custom model I have  partner_id, product_id fields and  a Many2one field from stock.production.lot . 


From my custom model I want to create a new record from the Many2one field and pass the partner_id and product_id values to the Many2one model ( stock.production.lot ).


How can I achieve this ? Thank you.


الصورة الرمزية
إهمال

You can try passing on these values via the context when you press "create and edit". The way to do that is when you are defining the many2one field in your custom model then just add context part too, for ex: <field name='stock_prod_lot_field' context="{'default_partner_id': partner_id,'default_product_id':product_id}"/>. Please note that inside the context dict the keys are default_(FieldName in stock.production.lot) and the values are the fields from your custom model. Let me know if it works.

الكاتب

Worked like a charm ! Thank you !!

المنشورات ذات الصلة الردود أدوات العرض النشاط
3
ديسمبر 23
1802
2
مارس 15
7903
2
فبراير 25
5853
1
يناير 25
1311
1
ديسمبر 24
1413