Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
3614 มุมมอง

Guys,

I developed a simple module to create relation between ebay listing and product in Odoo. It works perfectly fine but if I want un-bind (remove relation) it won't update record.

# Unbind def

@api.one

def unbind(self, idlist_id):

context = ''

item_id = self.env['idlist'].search([('name','=',self.name)])

if item_id:

print '== Unbind ID from product ======================================================'

print ' item found'

for item in item_id:

print '== Unbind item_number =========================================================='

print ' ', item.id

print ' ', self.name

print ' ', self.item_number

self.env['product.template'].write({'ebay_item_id': '000000000000', 'assigned': False, 'ebay_listed': False})

#self.env.cr.execute(""" UPDATE product_template SET ebay_item_id = '%s', assigned = '%s', ebay_listed = '%s' WHERE ebay_item_id = '%s' """ %(' ',False,False,self.item_number))

self.env.cr.execute(""" UPDATE idlist SET isused = '%s' WHERE id = '%s' """ %(False,item.id))

self.write({'state':False})

print '================================================================================'

raise Warning('Ebay ID successfully UN-BIND`ed')

else:

print '== item not found =============================================================='

I tried direct SQL query and API, none of those method works ;(

WHY ?!?!?!

WHERE is the problem ?!??!

WHAT I'm doing wrong ?!?!?


อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Rob,

On which product_template record(object) are u executing below line?

self.env['product.template'].write({'ebay_item_id': '000000000000', 'assigned': False, 'ebay_listed': False})

here you are just taking product_template class but not any object(record) of it....

so, first get the object of product template record and the apply write on it.. like:

<product_template_object>.write({'ebay_item_id': '000000000000', 'assigned': False, 'ebay_listed': False})

Hope it helps!

อวตาร
ละทิ้ง
ผู้เขียน

Don't get it :) However, I tried also direct SQL and it also won't work :( .... don't get it :(

ผู้เขียน

Hi Pawan, I think I finally got it :)

Related Posts ตอบกลับ มุมมอง กิจกรรม
How can I create a Popup Message? แก้ไขแล้ว
3
พ.ค. 24
15237
Error passing data between three classes แก้ไขแล้ว
1
ก.ย. 15
3579
1
มี.ค. 16
22382
1
ต.ค. 15
6272
1
มิ.ย. 16
3536