تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
1 الرد
3791 أدوات العرض

In sale.py there is the following method:

def _amount_line_tax(self, cr, uid, line, context=None):
val = 0.0
for c in self.pool.get('account.tax').compute_all(cr, uid, line.tax_id, line.price_unit * (1-(line.discount or 0.0)/100.0), line.product_uom_qty, line.product
_id, line.order_id.partner_id)['taxes']:
val += c.get('amount', 0.0)
return val

If I want to retrieve the sale.order name field in this method?

What do I do?

I have tried self.name without success despite print self prints sale.order.


الصورة الرمزية
إهمال
أفضل إجابة

Hello,

It seems that line sent as a browse record; so you can get the order's name as:

order_name = line.order_id.name
الصورة الرمزية
إهمال

Solution from Ahmed is correct. And for your question. self in old api = self.pool['sale.order'] so you need to do a self.browse

الكاتب

Thanks both, it works and now I understand I have to use fields passed explicitly as arguments in the old API. Regarding Jérémy comment, let's see if I was able to understand it right: going with self should be something like: order = self.pool.get('sale.order').browse(cr, uid, line.order_id.id), -as I still need to refer the order's id- and then I could use order.name. Thanks for helping, this post clarifies a lot to me.

Yep, you can access the order as the same as you suggested. You're doing good E.M keep it up :)

المنشورات ذات الصلة الردود أدوات العرض النشاط
3
أبريل 17
8222
1
فبراير 16
7892
2
فبراير 16
5309
2
يناير 24
5340
0
يونيو 23
1948