Files
stock-rma/rma/models/procurement.py
Lois Rilo 37a4146c05 [9.0][IMP] rma: several fixes for dropshipping:
* propaget properly partner for picking and move allowing to print packing operations as a dropshiping operation.
 * main use case for create supplier rma wizard is dropshipping.
2018-05-16 17:52:46 +02:00

43 lines
1.3 KiB
Python

# -*- coding: utf-8 -*-
# © 2017 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 ProcurementOrder(models.Model):
_inherit = 'procurement.order'
rma_line_id = fields.Many2one(
comodel_name='rma.order.line', string='RMA line',
ondelete="set null",
)
@api.model
def _run_move_create(self, procurement):
res = super(ProcurementOrder, self)._run_move_create(procurement)
if procurement.rma_line_id:
line = procurement.rma_line_id
res['rma_line_id'] = line.id
# Propagate partner_dest_id for proper drop-shipment reports.
if procurement.partner_dest_id:
res['partner_id'] = procurement.partner_dest_id.id
dest_loc = self.env["stock.location"].browse([
res["location_dest_id"]])[0]
if dest_loc.usage == "internal":
res["price_unit"] = line.price_unit
return res
class ProcurementGroup(models.Model):
_inherit = 'procurement.group'
rma_id = fields.Many2one(
comodel_name='rma.order', string='RMA',
ondelete="set null",
)
rma_line_id = fields.Many2one(
comodel_name='rma.order.line', string='RMA line',
ondelete="set null",
)