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

I have a custom field in product.template.

class ProductTemplate(models.Model):

    _inherit = "product.template"

   serial_no = fields.Char(string="Serial#")

i add the same field in move for added in move_lines

class ProductTemplate(models.Model):

    _inherit = "product.template"

   serial_no = fields.Char(string="Serial#")

notes

 I click "search more" on the moveline. I got the field to appear but there doesn't seem to be any data in it.The search window using product.product view
I am using an onchange function in stock.moves

function

@api.onchange('product_id')

def on_change_product(self):

        self.serial_no = self.product_id.serial_no

i get the serial no when i use create and edit  option. i use this the product.product window is opend.

how to get the values of product.template in onchage function?

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

If the field is set in product.template, you should access to it from product_id

self.serial_no = self.product_id.product_tmpl_id.serial_no

الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
2
مارس 24
6214
2
أغسطس 23
4132
0
أكتوبر 21
1722
1
سبتمبر 19
5146
1
يونيو 25
770