From 9c46e2ba950211fe5216ac203aa76072208af051 Mon Sep 17 00:00:00 2001 From: "Ahmed Khalaf(ahkh)" Date: Fri, 13 May 2022 08:45:45 +0000 Subject: [PATCH] [IMP] stock, stock_account: dates added to stock move name Scheduled date and accounting date added to stock move name Task: 2764771 Part-of: odoo/odoo#91640 --- addons/stock/models/stock_quant.py | 4 ++++ addons/stock_account/models/stock_quant.py | 10 +++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/addons/stock/models/stock_quant.py b/addons/stock/models/stock_quant.py index f389f25ae75..12e61ab27ad 100644 --- a/addons/stock/models/stock_quant.py +++ b/addons/stock/models/stock_quant.py @@ -877,6 +877,10 @@ class StockQuant(models.Model): name = _('Product Quantity Confirmed') else: name = _('Product Quantity Updated') + + if self.inventory_date: + name += _(' [Scheduled on %s]', self.inventory_date) + return { 'name': self.env.context.get('inventory_name') or name, 'product_id': self.product_id.id, diff --git a/addons/stock_account/models/stock_quant.py b/addons/stock_account/models/stock_quant.py index affad430395..3cc0d524e84 100644 --- a/addons/stock_account/models/stock_quant.py +++ b/addons/stock_account/models/stock_quant.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. -from odoo import api, fields, models +from odoo import api, fields, models, _ from odoo.tools.float_utils import float_is_zero from odoo.tools.misc import groupby @@ -71,6 +71,14 @@ class StockQuant(models.Model): else: super(StockQuant, inventories)._apply_inventory() + def _get_inventory_move_values(self, qty, location_id, location_dest_id, out=False): + res_move = super()._get_inventory_move_values(qty, location_id, location_dest_id, out) + if not self.env.context.get('inventory_name'): + force_period_date = self.env.context.get('force_period_date', False) + if force_period_date: + res_move['name'] += _(' [Accounted on %s]', force_period_date) + return res_move + @api.model def _get_inventory_fields_write(self): """ Returns a list of fields user can edit when editing a quant in `inventory_mode`."""