Skip to Content
Menu
This question has been flagged

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
Discard
Author Best Answer

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
Discard
Related Posts Replies Views Activity
0
Jul 20
2558
1
Aug 21
1233
2
Jun 21
4662
2
Jun 21
3877
1
Apr 21
2415