mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
[ADD]stock_request_analytic
This commit is contained in:
22
stock_request_analytic/models/stock_request.py
Normal file
22
stock_request_analytic/models/stock_request.py
Normal file
@@ -0,0 +1,22 @@
|
||||
# Copyright 2017 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, fields, models
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
|
||||
class StockRequest(models.Model):
|
||||
_inherit = "stock.request"
|
||||
|
||||
analytic_account_id = fields.Many2one(
|
||||
'account.analytic.account', string='Analytic Account')
|
||||
|
||||
@api.constrains('analytic_account_id')
|
||||
def _check_analytic_company_constrains(self):
|
||||
if any(request.company_id and
|
||||
request.analytic_account_id.company_id !=
|
||||
request.company_id for request in self):
|
||||
raise ValidationError(
|
||||
_('You cannot link a analytic account '
|
||||
'to a stock request that belongs to '
|
||||
'another company.'))
|
||||
Reference in New Issue
Block a user