mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
- Error with the sequence number. - Visible texts that should be in uppercases. - order_id should only be visible if group_stock_request_order option is enabled. - adds more tests - adds consistency between models company-wise
29 lines
1.2 KiB
Python
29 lines
1.2 KiB
Python
# Copyright 2018 Eficent Business and IT Consulting Services, S.L.
|
|
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
|
|
|
|
from odoo import api, models, _
|
|
from odoo.exceptions import ValidationError
|
|
|
|
|
|
class StockWarehouse(models.Model):
|
|
_inherit = 'stock.warehouse'
|
|
|
|
@api.constrains('company_id')
|
|
def _check_company_stock_request(self):
|
|
if any(self.env['stock.request'].search(
|
|
[('company_id', '!=', rec.company_id.id),
|
|
('warehouse_id', '=', rec.id)], limit=1)
|
|
for rec in self):
|
|
raise ValidationError(
|
|
_('You cannot change the company of the warehouse, as it is '
|
|
'already assigned to stock requests that belong to '
|
|
'another company.'))
|
|
if any(self.env['stock.request.order'].search(
|
|
[('company_id', '!=', rec.company_id.id),
|
|
('warehouse_id', '=', rec.id)], limit=1)
|
|
for rec in self):
|
|
raise ValidationError(
|
|
_('You cannot change the company of the warehouse, as it is '
|
|
'already assigned to stock request orders that belong to '
|
|
'another company.'))
|