From ba9b5ce12b617ca9fcc99533f613468a0987ac58 Mon Sep 17 00:00:00 2001 From: Kirti Choudhary Date: Thu, 29 Nov 2018 05:30:05 +0000 Subject: [PATCH] [IMP] stock: default responsible + activity responsible Traceback when the responsible is not set on an activity since it's a required field. In this case we will use the odoo system responsible for the activity. Also reintroduce the default value for the responsible as the user that create the product. The purpose is to avoid to log all the activity for the odoo system but to dispatch the exception between user, if a user create the product he will probably be responsible for it. It is always possible to remove the responsible or to modify it. Task ID - 1913168 closes odoo/odoo#29138 --- addons/stock/models/product.py | 2 +- addons/stock/models/stock_picking.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/stock/models/product.py b/addons/stock/models/product.py index 1065250df49..c25bc582445 100644 --- a/addons/stock/models/product.py +++ b/addons/stock/models/product.py @@ -396,7 +396,7 @@ class ProductTemplate(models.Model): _inherit = 'product.template' responsible_id = fields.Many2one( - 'res.users', string='Responsible', + 'res.users', string='Responsible', default=lambda self: self.env.uid, help="This user will be responsible of the next activities related to logistic operations for this product.") type = fields.Selection(selection_add=[('product', 'Storable Product')]) property_stock_production = fields.Many2one( diff --git a/addons/stock/models/stock_picking.py b/addons/stock/models/stock_picking.py index 1157559ead6..5a924cff2a1 100644 --- a/addons/stock/models/stock_picking.py +++ b/addons/stock/models/stock_picking.py @@ -6,7 +6,7 @@ import json import time from itertools import groupby -from odoo import api, fields, models, _ +from odoo import api, fields, models, SUPERUSER_ID, _ from odoo.tools import DEFAULT_SERVER_DATETIME_FORMAT from odoo.tools.float_utils import float_compare, float_is_zero, float_round from odoo.exceptions import UserError @@ -943,7 +943,7 @@ class Picking(models.Model): self.env['mail.activity'].create({ 'activity_type_id': self.env.ref('mail.mail_activity_data_warning').id, 'note': note, - 'user_id': responsible.id, + 'user_id': responsible.id or SUPERUSER_ID, 'res_id': parent.id, 'res_model_id': self.env['ir.model'].search([('model', '=', parent._name)], limit=1).id, })