Files
manufacture/mrp_attachment_mgmt/models/mrp_workorder.py
Pedro M. Baeza a23f1ed5b3 [REF] mrp_attachment_mgmt: Avoid code duplication for attachment view
- Put the method on product, and call it from all the places.
- Remove excessive method fragmentation w/o gain.
- Replace action read by proper `_for_xml_id` call.
2023-03-27 16:44:29 +02:00

24 lines
829 B
Python

# Copyright 2021 Tecnativa - Víctor Martínez
# Copyright 2023 Tecnativa - Pedro M. Baeza
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import _, models
from odoo.exceptions import UserError
class MrpWorkorder(models.Model):
_inherit = "mrp.workorder"
def action_see_workorder_attachments(self):
error = []
for product in self.mapped("product_id"):
if (
product.message_attachment_count == 0
and product.product_tmpl_id.message_attachment_count == 0
):
error.append(product.display_name)
if error:
raise UserError(
_("%d Product(s) without drawing:\n%s") % (len(error), "\n".join(error))
)
return self.product_id._action_show_attachments()