[FIX] mrp_subcontracting: allow to return to subcontractor
This commit is contained in:
committed by
Simon Lejeune
parent
69b3b4bcd6
commit
186b512023
@@ -1,14 +1,30 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import models
|
||||
|
||||
from odoo import api, models
|
||||
from odoo.osv.expression import OR
|
||||
|
||||
class ReturnPicking(models.TransientModel):
|
||||
_inherit = 'stock.return.picking'
|
||||
|
||||
@api.onchange('picking_id')
|
||||
def _onchange_picking_id(self):
|
||||
res = super(ReturnPicking, self)._onchange_picking_id()
|
||||
if not any(self.product_return_moves.filtered(lambda r: r.quantity > 0).move_id.mapped('is_subcontract')):
|
||||
return res
|
||||
subcontract_location = self.picking_id.partner_id.property_stock_subcontractor
|
||||
self.location_id = subcontract_location.id
|
||||
domain_location = OR([
|
||||
['|', ('id', '=', self.original_location_id.id), ('return_location', '=', True)],
|
||||
[('id', '=', subcontract_location.id)]
|
||||
])
|
||||
if not res:
|
||||
res = {'domain': {'location_id': domain_location}}
|
||||
else:
|
||||
res['domain'] = {'location_id': domain_location}
|
||||
return res
|
||||
|
||||
def _prepare_move_default_values(self, return_line, new_picking):
|
||||
vals = super(ReturnPicking, self)._prepare_move_default_values(return_line, new_picking)
|
||||
if return_line.move_id.is_subcontract:
|
||||
vals['location_dest_id'] = self.picking_id.partner_id.property_stock_subcontractor.id
|
||||
vals['is_subcontract'] = False
|
||||
return vals
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<field name="arch" type="xml">
|
||||
<form>
|
||||
<field name="move_dest_exists" invisible="1"/>
|
||||
<field name="picking_id" invisible="1"/>
|
||||
<field name="picking_id" invisible="1" force_save="1"/>
|
||||
<group attrs="{'invisible': [('move_dest_exists', '=', False)]}">
|
||||
<div class="oe_grey">
|
||||
<p>This picking appears to be chained with another operation. Later, if you receive the goods you are returning now, make sure to <b>reverse</b> the returned picking in order to avoid logistic rules to be applied again (which would create duplicated operations)</p>
|
||||
|
||||
Reference in New Issue
Block a user