Hi,
Please refer to the Following Example.
For adding a field in the product form you can try the code below in your function.
inherit_id = self.env.ref('product.product_template_only_form_view')
arch_base = _('<?xml version="1.0"?>'
'<data>'
'<field name="barcode" position="after">'
'<field name="new_field"/>'
'</field>'
'</data>')
self.env['ir.ui.view'].sudo().create({'name': 'product.inherit.fields',
'type': 'form',
'model': 'product.template',
'mode': 'extension',
'inherit_id': inherit_id.id,
'arch_base': arch_base,
'active': True})
Regards