[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
This commit is contained in:
committed by
Arnold Moyaux
parent
1c28ba8c47
commit
ba9b5ce12b
@@ -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(
|
||||
|
||||
@@ -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,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user