Advertisement
ninofelino

converting

Jan 12th, 2019
499
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.70 KB | None | 0 0
  1. @http.route('/felino/product', auth='public')
  2.       def inv(self, **kw):
  3.           http.request.cr.execute('select * from h_dbinv where count>1 ')
  4.           data = http.request.cr.fetchall()
  5.           objects= http.request.env['product.template']
  6.           #product= http.request.env['product.template']
  7.           attr_test= http.request.env['product.attribute'].browse([389])
  8.           print(attr_test.value_ids.ids)
  9.           for record in data:
  10.               print(attr_test.value_ids.ids)
  11.               px=[]
  12.               attx=[]
  13.              
  14.               attx=list(map(int,record[6]))
  15.               for data in record[5]:
  16.                   px.append((0,0,data))
  17.                  
  18.               print(attx)
  19.              
  20.               print("****************************")
  21.               productlist = {'id':record[0],'name':record[1],'list_price':record[3],'standard_price':record[2],
  22.               'lst_price':record[3],
  23.               'product_variant_ids':px,
  24.               'attribute_line_ids': [(0, 0, {
  25.               'attribute_id': 1,
  26.               'value_ids':[(6, 0,attx)],
  27.                }),
  28.               ]
  29.              
  30.              
  31.              
  32.               #attribute_value_ids,
  33.               #'qty_availab
  34.               }
  35.               #productlist.update(pv)
  36.               #print("==================================")
  37.               #print(productlist)
  38.               #print("==================================")
  39.               try:
  40.                   objects.sudo().create(productlist)
  41.                   http.request.cr.commit()
  42.               except:
  43.                   print("error")    
  44.              
  45.           return http.request.render('felino.listing')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement