mirror of
https://github.com/OCA/manufacture.git
synced 2025-01-28 16:37:15 +02:00
- 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.
24 lines
829 B
Python
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()
|