Files
stock-logistics-warehouse/stock_request_analytic/models/stock_request.py
Lois Rilo 8fa48adb8f [11.0] stock_request_analytic:
* clean views.
 * allow to create a stock.request with no analytic account.
 * remove copy attribute in non-stored field.
 * remove non-existing field from compute method.
2021-11-27 16:06:11 +01:00

22 lines
830 B
Python

# 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(r.company_id and r.analytic_account_id and
r.analytic_account_id.company_id != r.company_id for r in self):
raise ValidationError(
_('You cannot link a analytic account '
'to a stock request that belongs to '
'another company.'))