Ir al contenido
Menú
Se marcó esta pregunta
1 Responder
3542 Vistas

can't figure out how to add a line to sale.subscription using the create medal from another model 


   supsctiption_pak = self.env['product.template'].search([('name', '=', pak_name),('recurring_invoice', '=', True)], limit=1)
        supsctiption_info = {
            'partner_id': vals['name'],
        }    
        add_supsctiption = self.env['sale.subscription'].create(supsctiption_info)    

        print('ssssss',supsctiption_pak)
        #works
     add_supsctiption_pak = { 'product_id': supsctiption_pak.id, 'partner_id': add_supsctiption.id, } link_user_to_supsctiption = self.env['sale.subscription.line'].create(add_supsctiption_pak)


Avatar
Descartar
Autor Mejor respuesta

Thanks to odoo Mates on YouTube, this video his from odoo Mates channel [How To Update One2many Field From OnChange Of Field in Odoo][1] and @bigbear3001


this is what worked for me


        supsctiption_pak = self.env['product.product'].search([('name', '=', pak_name),('recurring_invoice', '=', True)], limit=1)
        supsctiption_info = {
            'partner_id': vals['name'],
        }    
        add_supsctiption = self.env['sale.subscription'].create(supsctiption_info)
        supsctiption_to_pak = self.env['sale.subscription'].search([('partner_id', '=', vals['name'])], limit=1)

        add_supsctiption_pak = {
                'product_id': supsctiption_pak.product_variant_id.id,
                'uom_id': supsctiption_pak.uom_id.id,
                'price_unit': supsctiption_pak.list_price,
            }    
        supsctiption_to_pak.write({'recurring_invoice_line_ids':[(5, 0, 0),(0,0,add_supsctiption_pak)]})
 



  [1]: https://youtu.be/LE7E2O4lBrQ

Avatar
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
0
jul 20
3435
1
ago 21
2333
2
jun 21
5936
2
jun 21
4937
1
abr 21
3765