diff --git a/account_invoice_report_service/i18n/es.po b/account_invoice_report_service/i18n/es.po index 19811a46b..c6f58565b 100644 --- a/account_invoice_report_service/i18n/es.po +++ b/account_invoice_report_service/i18n/es.po @@ -301,6 +301,12 @@ msgstr "" "Caso no implementado: La misma línea de factura pertenece a diferentes " "pedidos" +#. module: account_invoice_report_service +#: code:addons/account_invoice_report_service/models/account_invoice.py:0 +#, python-format +msgid "Not implemented case: The same invoice line %(line)s belongs to different orders %(orders)s" +msgstr "Caso no implementado: La misma línea de factura %(line)s pertenece a diferentes pedidos %(orders)s" + #. module: account_invoice_report_service #: model:ir.model.fields,field_description:account_invoice_report_service.field_sale_order__date_order_tz msgid "Order Date TZ" diff --git a/account_invoice_report_service/models/__init__.py b/account_invoice_report_service/models/__init__.py index 0a4254a4d..9dc235d8c 100644 --- a/account_invoice_report_service/models/__init__.py +++ b/account_invoice_report_service/models/__init__.py @@ -1,5 +1,3 @@ -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) - from . import res_company from . import account_invoice from . import res_config_settings diff --git a/account_invoice_report_service/models/account_invoice.py b/account_invoice_report_service/models/account_invoice.py index 05592ff0a..a5b68c640 100644 --- a/account_invoice_report_service/models/account_invoice.py +++ b/account_invoice_report_service/models/account_invoice.py @@ -25,23 +25,34 @@ def print_report_invoice_service(self): ) return self.company_id.report_service_id.report_action(self) - def _group_by_order(self): + def _group_invoice_lines_by_order(self): order_d, no_order = {}, self.env["account.move.line"] for iline in self.invoice_line_ids: - if iline.sale_line_ids: - for oline in iline.sale_line_ids: - order = oline.order_id - if order not in order_d: - order_d[order] = self.env["account.move.line"] - order_d[order] |= iline - else: + orders = list(filter(None, iline._get_orders())) + if len(orders) == 1: + order = orders[0] + if order not in order_d: + order_d[order] = self.env["account.move.line"] + order_d[order] |= iline + elif not orders: no_order += iline - + else: + raise ValidationError( + _( + "Not implemented case: " + "The same invoice line %(line)s " + "belongs to different orders %(orders)s" + ) + % { + "line": iline.name, + "orders": ", ".join([x.name for x in orders]), + } + ) return order_d, no_order def get_service_lines_by_order(self): # group by order - order_d, no_order = self._group_by_order() + order_d, no_order = self._group_invoice_lines_by_order() # grouping by round trip code order_rt_date_l = [] @@ -89,7 +100,7 @@ def get_service_lines_by_order(self): def get_delivery_lines_by_order(self): # group by order - order_d, no_order = self._group_by_order() + order_d, no_order = self._group_invoice_lines_by_order() # sort and join with lines w/o orders order_sorted_l = [] @@ -114,6 +125,10 @@ def get_delivery_lines_by_order(self): class AccountMoveLine(models.Model): _inherit = "account.move.line" + def _get_orders(self): + # we use a list to allow different types of orders, sale, repair, etc + return [x for x in self.sale_line_ids.order_id] + def get_line_lots(self): return ( self.move_line_ids.mapped("lot_id").sorted(lambda x: x.name).mapped("name") diff --git a/account_invoice_report_service_repair/README.rst b/account_invoice_report_service_repair/README.rst new file mode 100644 index 000000000..213e6cef3 --- /dev/null +++ b/account_invoice_report_service_repair/README.rst @@ -0,0 +1,63 @@ +============================= +Service invoice report repair +============================= + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:077fc208bce6c55eaf2aee8ca4a08be195c7918016044acdac0cf770484173e6 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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-NuoBiT%2Fodoo--addons-lightgray.png?logo=github + :target: https://github.com/NuoBiT/odoo-addons/tree/14.0/account_invoice_report_service_repair + :alt: NuoBiT/odoo-addons + +|badge1| |badge2| |badge3| + +The "Account Invoice Report Service Repair" module enhances the invoice delivery report by including information about the associated repair order. When a service repair is performed and invoiced, this module ensures that the repair order reference is visible on the invoice delivery report. This feature improves traceability and transparency for both internal users and customers, making it easier to track which repair operations are linked to each invoice. The module is especially useful for companies that manage repair services and need to provide detailed documentation to their clients. + +**Table of contents** + +.. contents:: + :local: + +Bug Tracker +=========== + +Bugs are tracked on `GitHub 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 `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* NuoBiT Solutions +* S.L. + +Contributors +~~~~~~~~~~~~ + +* `NuoBiT `_: + + * Eric Antones + +Maintainers +~~~~~~~~~~~ + +This module is part of the `NuoBiT/odoo-addons `_ project on GitHub. + +You are welcome to contribute. diff --git a/account_invoice_report_service_repair/__init__.py b/account_invoice_report_service_repair/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/account_invoice_report_service_repair/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/account_invoice_report_service_repair/__manifest__.py b/account_invoice_report_service_repair/__manifest__.py new file mode 100644 index 000000000..cc04320a7 --- /dev/null +++ b/account_invoice_report_service_repair/__manifest__.py @@ -0,0 +1,16 @@ +# Copyright 2025 NuoBiT - Eric Antones +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) + +{ + "name": "Service invoice report repair", + "summary": "This module displays the related repair order on the " + "invoice delivery report, providing a clear link between " + "service repairs and their corresponding invoices.", + "version": "14.0.1.0.0", + "author": "NuoBiT Solutions, S.L.", + "license": "AGPL-3", + "category": "Accounting", + "website": "https://github.com/nuobit/odoo-addons", + "depends": ["account_invoice_report_service", "repair"], + "auto_install": True, +} diff --git a/account_invoice_report_service_repair/models/__init__.py b/account_invoice_report_service_repair/models/__init__.py new file mode 100644 index 000000000..1aabaa391 --- /dev/null +++ b/account_invoice_report_service_repair/models/__init__.py @@ -0,0 +1,2 @@ +from . import account_move_line +from . import repair_order diff --git a/account_invoice_report_service_repair/models/account_move_line.py b/account_invoice_report_service_repair/models/account_move_line.py new file mode 100644 index 000000000..8d047e5ae --- /dev/null +++ b/account_invoice_report_service_repair/models/account_move_line.py @@ -0,0 +1,15 @@ +# Copyright 2025 NuoBiT - Eric Antones +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) + + +from odoo import models + + +class AccountMoveLine(models.Model): + _inherit = "account.move.line" + + def _get_orders(self): + # we use a list to allow different types of orders, sale, repair, etc + return super()._get_orders() + [ + x for x in self.repair_fee_ids.repair_id | self.repair_line_ids.repair_id + ] diff --git a/account_invoice_report_service_repair/models/repair_order.py b/account_invoice_report_service_repair/models/repair_order.py new file mode 100644 index 000000000..78d8620aa --- /dev/null +++ b/account_invoice_report_service_repair/models/repair_order.py @@ -0,0 +1,30 @@ +# Copyright 2025 NuoBiT - Eric Antones +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) + +from odoo import fields, models + + +class Repair(models.Model): + _inherit = "repair.order" + + date_order = fields.Datetime(related="move_id.date", readonly=True) + + client_order_ref = fields.Char(compute="_compute_client_order_ref") + + def _compute_client_order_ref(self): + for order in self: + order.client_order_ref = False + + service_number = fields.Integer(compute="_compute_service_number") + + def _compute_service_number(self): + for order in self: + order.service_number = 0 + + date_order_tz = fields.Date( + string="Order Date TZ", readonly=True, compute="_compute_date_order_tz" + ) + + def _compute_date_order_tz(self): + for rec in self: + rec.date_order_tz = fields.Date.context_today(rec, rec.date_order) diff --git a/account_invoice_report_service_repair/readme/CONTRIBUTORS.rst b/account_invoice_report_service_repair/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..77acb88da --- /dev/null +++ b/account_invoice_report_service_repair/readme/CONTRIBUTORS.rst @@ -0,0 +1,3 @@ +* `NuoBiT `_: + + * Eric Antones diff --git a/account_invoice_report_service_repair/readme/DESCRIPTION.rst b/account_invoice_report_service_repair/readme/DESCRIPTION.rst new file mode 100644 index 000000000..e7fcb8b8c --- /dev/null +++ b/account_invoice_report_service_repair/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +The "Account Invoice Report Service Repair" module enhances the invoice delivery report by including information about the associated repair order. When a service repair is performed and invoiced, this module ensures that the repair order reference is visible on the invoice delivery report. This feature improves traceability and transparency for both internal users and customers, making it easier to track which repair operations are linked to each invoice. The module is especially useful for companies that manage repair services and need to provide detailed documentation to their clients. diff --git a/account_invoice_report_service_repair/static/description/icon.png b/account_invoice_report_service_repair/static/description/icon.png new file mode 100644 index 000000000..1cd641e79 Binary files /dev/null and b/account_invoice_report_service_repair/static/description/icon.png differ diff --git a/account_invoice_report_service_repair/static/description/index.html b/account_invoice_report_service_repair/static/description/index.html new file mode 100644 index 000000000..2d403cb6f --- /dev/null +++ b/account_invoice_report_service_repair/static/description/index.html @@ -0,0 +1,420 @@ + + + + + +Service invoice report repair + + + +
+

Service invoice report repair

+ + +

Beta License: AGPL-3 NuoBiT/odoo-addons

+

The “Account Invoice Report Service Repair” module enhances the invoice delivery report by including information about the associated repair order. When a service repair is performed and invoiced, this module ensures that the repair order reference is visible on the invoice delivery report. This feature improves traceability and transparency for both internal users and customers, making it easier to track which repair operations are linked to each invoice. The module is especially useful for companies that manage repair services and need to provide detailed documentation to their clients.

+

Table of contents

+ +
+

Bug Tracker

+

Bugs are tracked on GitHub 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.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • NuoBiT Solutions
  • +
  • S.L.
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is part of the NuoBiT/odoo-addons project on GitHub.

+

You are welcome to contribute.

+
+
+
+ + diff --git a/setup/account_invoice_report_service_repair/odoo/addons/account_invoice_report_service_repair b/setup/account_invoice_report_service_repair/odoo/addons/account_invoice_report_service_repair new file mode 120000 index 000000000..80d1f557e --- /dev/null +++ b/setup/account_invoice_report_service_repair/odoo/addons/account_invoice_report_service_repair @@ -0,0 +1 @@ +../../../../account_invoice_report_service_repair \ No newline at end of file diff --git a/setup/account_invoice_report_service_repair/setup.py b/setup/account_invoice_report_service_repair/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/account_invoice_report_service_repair/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)