Odoo:OpenERP7 _prepare_purchase_order_line 方法等同于 Odoo 12

Odoo : OpenERP7 _prepare_purchase_order_line method equivalent in Odoo 12


我正在努力将一个旧模块从 OpenERP 7 迁移到 Odoo 12。我被困在这个名为 _prepare_purchase_order_line 的方法中,你可以在模型 purchase.requisition.
中找到它 这是它的代码:

def make_purchase_order(self, cr, uid, ids, partner_id, context=None):
    """
    Create New RFQ for Supplier
    """
    context = dict(context or {})
    assert partner_id, 'Supplier should be specified'
    purchase_order = self.pool.get('purchase.order')
    purchase_order_line = self.pool.get('purchase.order.line')
    res_partner = self.pool.get('res.partner')
    supplier = res_partner.browse(cr, uid, partner_id, context=context)
    res = {}
    for requisition in self.browse(cr, uid, ids, context=context):
        if not requisition.multiple_rfq_per_supplier and supplier.id in filter(lambda x: x, [rfq.state != 'cancel' and rfq.partner_id.id or None for rfq in requisition.purchase_ids]):
            raise osv.except_osv(_('Warning!'), _('You have already one %s purchase order for this partner, you must cancel this purchase order to create a new quotation.') % rfq.state)
        context.update({'mail_create_nolog': True})
        purchase_id = purchase_order.create(cr, uid, self._prepare_purchase_order(cr, uid, requisition, supplier, context=context), context=context)
        purchase_order.message_post(cr, uid, [purchase_id], body=_("RFQ created"), context=context)
        res[requisition.id] = purchase_id
        for line in requisition.line_ids:
            purchase_order_line.create(cr, uid, self._prepare_purchase_order_line(cr, uid, requisition, line, purchase_id, supplier, context=context), context=context)
    return res

我想知道这个方法在 Odoo 12 中的等价物是什么。
你能帮帮我吗?

我可以看到这个方法在 odoo 12 中以相同的名称存在,但它在 purchase.requisition.line 模型中。

    @api.multi
    def _prepare_purchase_order_line(self, name, product_qty=0.0, price_unit=0.0, taxes_ids=False):
        self.ensure_one()
        requisition = self.requisition_id
        if requisition.schedule_date:
            date_planned = datetime.combine(requisition.schedule_date, time.min)
        else:
            date_planned = datetime.now()
        return {
            'name': name,
            'product_id': self.product_id.id,
            'product_uom': self.product_id.uom_po_id.id,
            'product_qty': product_qty,
            'price_unit': price_unit,
            'taxes_id': [(6, 0, taxes_ids)],
            'date_planned': date_planned,
            'account_analytic_id': self.account_analytic_id.id,
            'analytic_tag_ids': self.analytic_tag_ids.ids,
            'move_dest_ids': self.move_dest_id and [(4, self.move_dest_id.id)] or []
        }