Files
stock-logistics-warehouse/stock_request_analytic/models/analytic.py
João Marques 53e4b356c6 [MIG] stock_request_analytic: Migration to 13.0
Co-authored-by: Pimolnat Suntian <pimolnats@ecosoft.co.th>

TT28896
2021-11-27 16:06:11 +01:00

29 lines
950 B
Python

# Copyright 2017-2020 ForgeFlow, S.L. (https://www.forgeflow.com)
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from odoo import fields, models
class AccountAnalyticAccount(models.Model):
_inherit = "account.analytic.account"
stock_request_ids = fields.One2many(
comodel_name="stock.request",
inverse_name="analytic_account_id",
string="Stock Requests",
copy=False,
)
def action_view_stock_request(self):
self.ensure_one()
action = self.env.ref("stock_request.action_stock_request_form").read()[0]
requests = self.mapped("stock_request_ids")
if len(requests) > 1:
action["domain"] = [("id", "in", requests.ids)]
elif requests:
action["views"] = [
(self.env.ref("stock_request.view_stock_request_form").id, "form")
]
action["res_id"] = requests.id
return action