0
次のコードを新しいAPIに変換します。default_getで新しいAPIを使用するには?
from odoo import api, fields, models
...
def default_get(self, cr, uid, fields, context=None):
product_pricelist = self.pool.get('product.pricelist')
if context is None:
context = {}
res = super(back_to_back_order, self).default_get(cr, uid, fields, context=context)
order = self.pool.get('sale.order').browse(cr, uid, context['active_id'], context=context)
items = [(6, 0, [])]
date_order = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
for line in order.order_line:
price = 0.0
if 'pricelist_id' in res:
if res['pricelist_id']:
date_order_str = datetime.strptime(date_order, DEFAULT_SERVER_DATETIME_FORMAT).strftime(DEFAULT_SERVER_DATE_FORMAT)
price = product_pricelist.price_get(cr, uid, [res['pricelist_id']],
line.product_id.id, line.product_uom_qty or 1.0, line.partner_id.id or False, {'uom': line.product_id.uom_po_id.id, 'date': date_order_str})[res['pricelist_id']]
else:
price = line.product_id.standard_price
else:
price = line.product_id.standard_price
item = 0,0,{
'product_id': line.product_id.id,
'qty': line.product_uom_qty,
'price': price,
'subtotal': price * line.product_uom_qty
}
if line.product_id:
items.append(item)
res.update(line_ids=items)
return res
あなたの質問を編集して追加してください:1.あなたのコード/あなたの試み2.あなたの入力、現在の出力と期待される出力 –