Merge pull request #1635 from expsa/pla-454919-inventory-return-auto-fill
inventory return autofill
This commit is contained in:
commit
796df0c3ef
|
|
@ -0,0 +1,2 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from . import wizard
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
{
|
||||
'name': "Return Autofill",
|
||||
'summary': """auto fill return picking""",
|
||||
'category': 'Inventory',
|
||||
'description': """
|
||||
Inventory auto fill return picking
|
||||
""",
|
||||
'version': '0.1',
|
||||
'depends': ['stock'],
|
||||
}
|
||||
Binary file not shown.
|
|
@ -0,0 +1 @@
|
|||
from . import stock_picking_return
|
||||
Binary file not shown.
Binary file not shown.
|
|
@ -0,0 +1,40 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from odoo import api, models
|
||||
from odoo.exceptions import UserError
|
||||
from odoo.tools.translate import _
|
||||
|
||||
|
||||
class ReturnPicking(models.TransientModel):
|
||||
_inherit = 'stock.return.picking'
|
||||
|
||||
@api.onchange('picking_id')
|
||||
def _onchange_picking_id(self):
|
||||
move_dest_exists = False
|
||||
product_return_moves = [(5,)]
|
||||
if self.picking_id and self.picking_id.state != 'done':
|
||||
raise UserError(_("You may only return Done pickings."))
|
||||
# In case we want to set specific default values (e.g. 'to_refund'), we must fetch the
|
||||
# default values for creation.
|
||||
line_fields = [f for f in self.env['stock.return.picking.line']._fields.keys()]
|
||||
product_return_moves_data_tmpl = self.env['stock.return.picking.line'].default_get(line_fields)
|
||||
for move in self.picking_id.move_lines:
|
||||
if move.state == 'cancel':
|
||||
continue
|
||||
if move.move_dest_ids:
|
||||
move_dest_exists = True
|
||||
product_return_moves_data = dict(product_return_moves_data_tmpl)
|
||||
product_return_moves_data.update(self._prepare_stock_return_picking_line_vals_from_move(move))
|
||||
product_return_moves.append((0, 0, product_return_moves_data))
|
||||
if self.picking_id and not product_return_moves:
|
||||
raise UserError(
|
||||
_("No products to return (only lines in Done state and not fully returned yet can be returned)."))
|
||||
if self.picking_id:
|
||||
self.product_return_moves = product_return_moves
|
||||
self.move_dest_exists = move_dest_exists
|
||||
self.parent_location_id = self.picking_id.picking_type_id.warehouse_id and self.picking_id.picking_type_id.warehouse_id.view_location_id.id or self.picking_id.location_id.location_id.id
|
||||
self.original_location_id = self.picking_id.location_id.id
|
||||
location_id = self.picking_id.location_id.id
|
||||
if self.picking_id.picking_type_id.return_picking_type_id.default_location_dest_id.return_location:
|
||||
location_id = self.picking_id.picking_type_id.return_picking_type_id.default_location_dest_id.id
|
||||
self.location_id = location_id
|
||||
Loading…
Reference in New Issue