summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsvs-odoo <svs@odoo.com>2019-02-28 08:02:33 +0000
committersvs-odoo <svs@odoo.com>2019-03-01 10:12:22 +0000
commit32186ad636d846ba069ec1fa50a5d979968d02c4 (patch)
treebb2588b5dbfbe9a632c1ade2458d55278f14ce62
parent569a498d360b99b2a1d8e64a6e6bcc259d0910e4 (diff)
[IMP] stock: keep scrap moves visible in movelines
When a scrap move is created, not with the scrap button but with a scraped operation, the move stay visible in movelines, by opposition of scrap moves created with the scrap button. Also, when you create a scrap from a delivery order, it'll try to prefill the location field with the location where the reserved product is stored. Task #1940511 closes odoo/odoo#31500
-rw-r--r--addons/stock/models/stock_picking.py2
-rw-r--r--addons/stock/models/stock_scrap.py8
2 files changed, 9 insertions, 1 deletions
diff --git a/addons/stock/models/stock_picking.py b/addons/stock/models/stock_picking.py
index 71bb46a3886..5fa4922d0b9 100644
--- a/addons/stock/models/stock_picking.py
+++ b/addons/stock/models/stock_picking.py
@@ -651,7 +651,7 @@ class Picking(models.Model):
move_ids_without_package |= move
else:
move_ids_without_package |= move
- picking.move_ids_without_package = move_ids_without_package.filtered(lambda ml: ml.scrapped == False)
+ picking.move_ids_without_package = move_ids_without_package.filtered(lambda move: move.picking_type_id == picking.picking_type_id)
def _set_move_without_package(self):
self.move_lines |= self.move_ids_without_package
diff --git a/addons/stock/models/stock_scrap.py b/addons/stock/models/stock_scrap.py
index 7c8eeefb57a..bf7026b5366 100644
--- a/addons/stock/models/stock_scrap.py
+++ b/addons/stock/models/stock_scrap.py
@@ -63,6 +63,14 @@ class StockScrap(models.Model):
def onchange_product_id(self):
if self.product_id:
self.product_uom_id = self.product_id.uom_id.id
+ # Check if we can get a more precise location instead of
+ # the default location (a location corresponding to where the
+ # reserved product is stored)
+ if self.picking_id:
+ for move_line in self.picking_id.move_line_ids:
+ if move_line.product_id == self.product_id:
+ self.location_id = move_line.location_id
+ break
@api.model
def create(self, vals):