[MIG] stock_request_analytic: Migration to 13.0

Co-authored-by: Pimolnat Suntian <pimolnats@ecosoft.co.th>

TT28896
This commit is contained in:
João Marques
2021-04-09 14:55:44 +01:00
committed by Denis Roussel
parent 23d243ff42
commit 53e4b356c6
12 changed files with 182 additions and 72 deletions

View File

@@ -1,30 +1,17 @@
# Copyright 2017 Eficent Business and IT Consulting Services, S.L.
# Copyright 2017-2020 ForgeFlow, S.L. (https://www.forgeflow.com)
# Copyright 2021 Tecnativa - João Marques
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from odoo import _, api, fields, models
from odoo.exceptions import ValidationError
from odoo import fields, models
class StockRequest(models.Model):
_inherit = "stock.request"
_check_company_auto = True
analytic_account_id = fields.Many2one(
"account.analytic.account", string="Analytic Account"
"account.analytic.account", string="Analytic Account", check_company=True,
)
analytic_tag_ids = fields.Many2many(
"account.analytic.tag", string="Analytic Tags", check_company=True,
)
analytic_tag_ids = fields.Many2many("account.analytic.tag", string="Analytic Tags")
@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."
)
)