mirror of
https://github.com/ForgeFlow/stock-rma.git
synced 2025-01-21 12:57:49 +02:00
30 lines
1.0 KiB
Python
30 lines
1.0 KiB
Python
# -*- coding: utf-8 -*-
|
|
# Copyright 2017-18 Eficent Business and IT Consulting Services S.L.
|
|
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
|
|
|
|
from openerp import api, fields, models
|
|
|
|
|
|
class PurchaseOrder(models.Model):
|
|
_inherit = "purchase.order"
|
|
|
|
@api.model
|
|
def new(self, vals):
|
|
"""Allows to propose a line based on the RMA information."""
|
|
res = super(PurchaseOrder, self).new(vals)
|
|
rma_line_id = self.env.context.get('rma_line_id')
|
|
if rma_line_id:
|
|
rma_line = self.env['rma.order.line'].browse(rma_line_id)
|
|
line = self.env['purchase.order.line'].new({
|
|
'product_id': rma_line.product_id.id,
|
|
})
|
|
line.onchange_product_id()
|
|
line.update({
|
|
'product_qty': rma_line.qty_to_purchase,
|
|
'product_uom': rma_line.uom_id.id,
|
|
})
|
|
res.order_line = line
|
|
# TODO: maybe this line is not needed in v10:
|
|
res.date_planned = res._compute_date_planned()
|
|
return res
|