Merge PR #1313 into 14.0

Signed-off-by sebalix
This commit is contained in:
OCA-git-bot
2021-11-30 14:42:10 +00:00
2 changed files with 20 additions and 1 deletions

View File

@@ -40,8 +40,19 @@ class StockWarehouseOrderpoint(models.Model):
@api.depends("product_min_qty", "product_id", "qty_multiple")
def _compute_procure_recommended(self):
op_qtys = self._quantity_in_progress()
# '_quantity_in_progress' override in 'purchase_stock' method has not
# been designed to work with NewIds (resulting in KeyError exceptions).
# To circumvent this, we knowingly skip such records here.
op_qtys = self.filtered(lambda x: x.id)._quantity_in_progress()
for op in self:
if not op.id:
op.update(
{
"procure_recommended_qty": False,
"procure_recommended_date": False,
}
)
continue
qty = 0.0
virtual_qty = op.with_context(
location=op.location_id.id

View File

@@ -170,3 +170,11 @@ class TestStockWarehouseOrderpoint(common.TransactionCase):
self.assertEquals(len(purchase_line), 1)
pol_date = fields.Date.from_string(purchase_line.date_planned)
self.assertEquals(pol_date, manual_date)
def test_compute_procure_recommended_with_newid(self):
"""'_compute_procure_recommended' method uses '_quantity_in_progress'
standard method which could trigger an issue in 'purchase_stock' when
dealing with NewID IDs.
"""
self.create_orderpoint_procurement()
self.reorder.new(origin=self.reorder)._compute_procure_recommended()