Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5191][ADD] product_attachment_name_update #157

Open
wants to merge 4 commits into
base: 15.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions product_attachment_name_update/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
==============================
Product Attachment Name Update
==============================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:54d9f5722cdc8a6131e2c063580adb3a04c3a37b03b5e3dbbb728565a3279321
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-qrtl%2Frmm--custom-lightgray.png?logo=github
:target: https://github.com/qrtl/rmm-custom/tree/15.0/product_attachment_name_update
:alt: qrtl/rmm-custom

|badge1| |badge2| |badge3|

This module concatenates the product name and product ID with the actual
attachment name when a user uploads an attachment in a product.

**Table of contents**

.. contents::
:local:

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/qrtl/rmm-custom/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/qrtl/rmm-custom/issues/new?body=module:%20product_attachment_name_update%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
-------

* Quartile

Maintainers
-----------

This module is part of the `qrtl/rmm-custom <https://github.com/qrtl/rmm-custom/tree/15.0/product_attachment_name_update>`_ project on GitHub.

You are welcome to contribute.
1 change: 1 addition & 0 deletions product_attachment_name_update/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
12 changes: 12 additions & 0 deletions product_attachment_name_update/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Copyright 2025 Quartile (https://www.quartile.co)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
"name": "Product Attachment Name Update",
"version": "15.0.1.0.0",
"author": "Quartile",
"website": "https://www.quartile.co",
"category": "Tools",
"license": "AGPL-3",
"depends": ["product"],
"installable": True,
}
1 change: 1 addition & 0 deletions product_attachment_name_update/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import ir_attachment
28 changes: 28 additions & 0 deletions product_attachment_name_update/models/ir_attachment.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Copyright 2025 Quartile (https://www.quartile.co)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import api, models


class IrAttachment(models.Model):
_inherit = "ir.attachment"

@api.model_create_multi
def create(self, vals_list):
attachments = super(IrAttachment, self).create(vals_list)
for attachment in attachments:
if (
attachment.res_model
in [
"product.template",
"product.product",
]
and not attachment.res_field
):
if attachment.res_model == "product.template":
res_model = "product.template"
else:
res_model = "product.product"
self.env[res_model].browse(attachment.res_id)
attachment.name = f"{attachment.id}{attachment.name}"
return attachments
2 changes: 2 additions & 0 deletions product_attachment_name_update/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This module concatenates the product name and product ID with the actual
attachment name when a user uploads an attachment in a product.
Loading