Files
odoo_source/addons/stock/wizard/stock_picking_responsible.py
T
Simon Lejeune b6f053b25e [REF] stock: multi company
Ensure proper domains are applied and enforced on relation fields thanks
to the `check_company` attributes.

product.template
- make responsible a property field in order to ensure proper next activities when a product
  is used between multiple companies
stock.putaway.rule
- added a company_id field
stock.move.line
- company_id is not related anymore since a move line can exist without a move until its validation
stock.package_level
- added a company_id field
stock.picking.type
- company_id is now required
stock.production.lot
- added a company_id field, adapted the constraint accordingly
stock.quant
- check the consistency only in inventory mode
stock.quant.package
- company_id is now empty if the package is empty
stock.picking
- company_id is now related to the one of its picking type

Added some tests.
Moved stock_traceability in the `report` directory.
Removed useless /tests/tours/route.js.

task-1985992
2019-09-03 15:05:03 +00:00

24 lines
954 B
Python

# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import _, fields, models
from odoo.exceptions import UserError
class StockPickingResponsible(models.TransientModel):
_name = 'stock.picking.responsible'
_description = 'Assign Responsible'
user_id = fields.Many2one(
'res.users', 'Responsible',
domain=lambda self: [('groups_id', 'in', self.env.ref('stock.group_stock_user').id)],
default=lambda self: self.env.user)
def assign_responsible(self):
self.ensure_one()
pickings = self.env['stock.picking'].browse(self.env.context.get('active_ids'))
restricted_companies = pickings.company_id - self.user_id.company_ids
if restricted_companies:
raise UserError(_('%s has a restricted access to %s') % (self.user_id.name, restricted_companies.mapped('name')))
pickings.write({'user_id': self.user_id.id})