[FIX] mrp: Wrong replenishment order notification

On the commit 69dcdd4, the order='create_date desc'
 was removed and the way of getting the MO for the notification changed. Now, the context is used, it should be written_after instead of written_date.
In addition, the now declaration should be at the beginning of the method action_replenish.
(The MO created is correct, only the notification is wrong)

Should be forwarded
OPW-2877457

closes odoo/odoo#96986

X-original-commit: 029da238a2baaf59bdf9ae828a4739ee4a9f3ede
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
This commit is contained in:
PNO
2022-07-28 18:01:25 +02:00
parent 072756d9b1
commit 72ea4d57d2
+1 -1
View File
@@ -213,6 +213,7 @@ class StockWarehouseOrderpoint(models.Model):
return action
def action_replenish(self):
now = datetime.now()
try:
self._procure_orderpoint_confirm(company_id=self.env.company)
except UserError as e:
@@ -226,7 +227,6 @@ class StockWarehouseOrderpoint(models.Model):
'views': [(self.env.ref('product.product_normal_form_view').id, 'form')],
'context': {'form_view_initial_mode': 'edit'}
}, _('Edit Product'))
now = datetime.now()
notification = False
if len(self) == 1:
notification = self.with_context(written_after=now)._get_replenishment_order_notification()