我想获得销售订单中,产品列表中 单个产品的id,写了一个方法,但是一直没法实现?求大神给出方法!
-
方法:
def print_order(self, cr, uid, ids,product_id): | print_pct [sale_order]
872 product_obj = self.pool.get('product.product') | manual_invoice [sale_order
873 if not product_id: | action_view_invoice [sale_
874 raise osv.except_osv(_('The product is not Defined!'), _('The product is not Defined!')) | test_no_product [sale_orde
875 product = product_obj.browse(cr, uid, product_id) | action_invoice_create [sal
876 print "" | action_invoice_cancel [sal
877 print cr | action_invoice_end [sale_o
878 print uid | action_cancel [sale_order]
879 print product_id | action_button_confirm [sal
880 print product_obj | action_wait [sale_order]
881 print product | action_quotation_send [sal
882 print "" | action_done [sale_order]
883 return product
打印的信息:
<openerp.sql_db.Cursor object at 0xb574da2c>
1
{'lang': 'zh_CN', 'tz': 'Asia/Shanghai', 'uid': 1}
<openerp.osv.orm.product.product object at 0xb1271eac>
我想获得产品id 该怎么改呢?求大神给出方法? -
修改: product = product_obj.browse(cr, uid,ids, product_id)
打印信息:
[1]
<openerp.sql_db.Cursor object at 0xb1c4f6cc>
1
{'lang': 'zh_CN', 'tz': 'Asia/Shanghai', 'uid': 1}
<openerp.osv.orm.product.product object at 0xb32ccecc>
[browse_record(product.product, 1)]
2014-05-22 04:59:40,054 6318 INFO odoo werkzeug: 192.168.213.1 - - [22/May/2014 04:59:40] "POST /web/dataset/call_button HTTP/1.1" 200 -
2014-05-22 04:59:40,160 6318 INFO odoo werkzeug: 192.168.213.1 - - [22/May/2014 04:59:40] "POST /web/menu/load_needaction HTTP/1.1" 200 -
2014-05-22 04:59:40,164 6318 INFO odoo werkzeug: 192.168.213.1 - - [22/May/2014 04:59:40] "POST /web/dataset/call_kw HTTP/1.1" 200 -
[2]
<openerp.sql_db.Cursor object at 0xb1b1f2cc>
1
{'lang': 'zh_CN', 'tz': 'Asia/Shanghai', 'uid': 1}
<openerp.osv.orm.product.product object at 0xb32ccecc>
[browse_record(product.product, 2)] -
[quote author=yfjelley link=topic=16403.msg28065#msg28065 date=1400736819]
[browse_record(product.product, 2)] 这样得到的是一个函数browse_record(product.product, 2) 怎样得到这个函数的返回的值呢
[/quote]
[browse_record(product.product, 2)]这个是一个browse object的列表。
browse object是OpenERP ORM里的一个重要的对象。例如你这里的browse_record(product.product, 2)意思就是我可以通过这个browse object来访问product.product这个model,id为2的记录。例如我们要取出这个产品的名字,可以browse_record(product.product, 2).name -
修改: product = product_obj.browse(cr,uid,ids, product_id)[0].name
打印信息:
[1]
<openerp.sql_db.Cursor object at 0xb08e950c>
1
{'lang': 'zh_CN', 'tz': 'Asia/Shanghai', 'uid': 1}
<openerp.osv.orm.product.product object at 0xb39cf9cc>
服务
2014-05-22 06:47:37,748 9334 INFO odoo werkzeug: 192.168.213.1 - - [22/May/2014 06:47:37] "POST /web/dataset/call_button HTTP/1.1" 200 -
2014-05-22 06:47:37,830 9334 INFO odoo werkzeug: 192.168.213.1 - - [22/May/2014 06:47:37] "POST /web/menu/load_needaction HTTP/1.1" 200 -
2014-05-22 06:47:37,838 9334 INFO odoo werkzeug: 192.168.213.1 - - [22/May/2014 06:47:37] "POST /web/dataset/call_kw HTTP/1.1" 200 -
[2]
<openerp.sql_db.Cursor object at 0xb084d06c>
1
{'lang': 'zh_CN', 'tz': 'Asia/Shanghai', 'uid': 1}
<openerp.osv.orm.product.product object at 0xb39cf9cc>
iphone
但是打印信息第一个为什么是服务呢,应该是iphone呀