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

I have a problem: I need to manually enter 2 fields' requested_document 'on sale.order and on sale.order.line, I want to enter the value for' 'requested_document' on each line of sale.order.line itself I have related them but the problem is related for not edit, I tried

         def _default_requested_document (self):

             if self.context.get ('active_model') == 'sale.order':

                 return self.context.get ('active_id', False)

         requested_document = fields.Text ('Requested Document', default = _default_requested_document) but failed.

الصورة الرمزية
إهمال
أفضل إجابة

Hi Paul,

i think there is a problem in context getting,

You can get context using:

self.env.context or self._context 

To get context value:

self.env.context.get('active_model') or self._context.get('active_model')

other code are perfect.

Accept and upvote answer if helpful..

Thank you


الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
2
يناير 23
2435
1
أغسطس 22
5352
0
ديسمبر 18
5375
1
مارس 15
5006
1
فبراير 23
1901