コンテンツへスキップ
メニュー
この質問にフラグが付けられました
1 返信
3691 ビュー

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)


アバター
破棄
著作者 最善の回答

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

アバター
破棄
関連投稿 返信 ビュー 活動
0
7月 20
3644
1
8月 21
2486
2
6月 21
6116
2
6月 21
5045
1
4月 21
3940