-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[14.0][ADD] account_invoice_repair_info_section: In invoice new secti…
…on with repair info.
- Loading branch information
1 parent
e7b1d99
commit 4fdb2e7
Showing
11 changed files
with
335 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg | ||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html | ||
:alt: License: AGPL-3 | ||
|
||
=================================== | ||
Account invoice repair info section | ||
=================================== | ||
|
||
* When creating an invoice from repairs, create a section on the invoice with | ||
the repair information, another section for the parts, and another section | ||
for the operations. | ||
|
||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues | ||
<https://github.com/avanzosc/odoo-addons/issues>`_. In case of trouble, | ||
please check there if your issue has already been reported. If you spotted | ||
it first, help us smash it by providing detailed and welcomed feedback. | ||
|
||
Do not contact contributors directly about support or help with technical issues. | ||
|
||
Credits | ||
======= | ||
|
||
Contributors | ||
------------ | ||
|
||
* Ana Juaristi <[email protected]> | ||
* Alfredo de la Fuente <[email protected]> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Copyright 2025 Alfredo de la Fuente - AvanzOSC | ||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html | ||
{ | ||
"name": "Account Invoice Repair Info Section", | ||
"author": "AvanzOSC", | ||
"website": "https://github.com/avanzosc/mrp-repair-addons", | ||
"category": "Invoices & Payments", | ||
"version": "14.0.1.0.0", | ||
"license": "AGPL-3", | ||
"depends": ["repair", "account"], | ||
"data": [], | ||
"installable": True, | ||
} |
64 changes: 64 additions & 0 deletions
64
account_invoice_repair_info_section/i18n/account_invoice_repair_info_section.pot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * account_invoice_repair_info_section | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 14.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2025-01-31 06:56+0000\n" | ||
"PO-Revision-Date: 2025-01-31 06:56+0000\n" | ||
"Last-Translator: \n" | ||
"Language-Team: \n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: \n" | ||
"Plural-Forms: \n" | ||
|
||
#. module: account_invoice_repair_info_section | ||
#: model:ir.model.fields,field_description:account_invoice_repair_info_section.field_account_move__display_name | ||
#: model:ir.model.fields,field_description:account_invoice_repair_info_section.field_repair_order__display_name | ||
msgid "Display Name" | ||
msgstr "" | ||
|
||
#. module: account_invoice_repair_info_section | ||
#: model:ir.model.fields,field_description:account_invoice_repair_info_section.field_account_move__id | ||
#: model:ir.model.fields,field_description:account_invoice_repair_info_section.field_repair_order__id | ||
msgid "ID" | ||
msgstr "" | ||
|
||
#. module: account_invoice_repair_info_section | ||
#: model:ir.model,name:account_invoice_repair_info_section.model_account_move | ||
msgid "Journal Entry" | ||
msgstr "" | ||
|
||
#. module: account_invoice_repair_info_section | ||
#: model:ir.model.fields,field_description:account_invoice_repair_info_section.field_account_move____last_update | ||
#: model:ir.model.fields,field_description:account_invoice_repair_info_section.field_repair_order____last_update | ||
msgid "Last Modified on" | ||
msgstr "" | ||
|
||
#. module: account_invoice_repair_info_section | ||
#: code:addons/account_invoice_repair_info_section/models/account_move.py:0 | ||
#, python-format | ||
msgid "OPERATIONS" | ||
msgstr "" | ||
|
||
#. module: account_invoice_repair_info_section | ||
#: code:addons/account_invoice_repair_info_section/models/account_move.py:0 | ||
#, python-format | ||
msgid "PARTS" | ||
msgstr "" | ||
|
||
#. module: account_invoice_repair_info_section | ||
#: model:ir.model,name:account_invoice_repair_info_section.model_repair_order | ||
msgid "Repair Order" | ||
msgstr "" | ||
|
||
#. module: account_invoice_repair_info_section | ||
#: code:addons/account_invoice_repair_info_section/models/account_move.py:0 | ||
#, python-format | ||
msgid "" | ||
"Repair: %(repair)s, VAT: %(vat)s, Product to repair: %(product)s, lot: " | ||
"%(lot)s" | ||
msgstr "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * account_invoice_repair_info_section | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 14.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2025-01-31 06:57+0000\n" | ||
"PO-Revision-Date: 2025-01-31 06:57+0000\n" | ||
"Last-Translator: \n" | ||
"Language-Team: \n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: \n" | ||
"Plural-Forms: \n" | ||
|
||
#. module: account_invoice_repair_info_section | ||
#: model:ir.model.fields,field_description:account_invoice_repair_info_section.field_account_move__display_name | ||
#: model:ir.model.fields,field_description:account_invoice_repair_info_section.field_repair_order__display_name | ||
msgid "Display Name" | ||
msgstr "" | ||
|
||
#. module: account_invoice_repair_info_section | ||
#: model:ir.model.fields,field_description:account_invoice_repair_info_section.field_account_move__id | ||
#: model:ir.model.fields,field_description:account_invoice_repair_info_section.field_repair_order__id | ||
msgid "ID" | ||
msgstr "" | ||
|
||
#. module: account_invoice_repair_info_section | ||
#: model:ir.model,name:account_invoice_repair_info_section.model_account_move | ||
msgid "Journal Entry" | ||
msgstr "" | ||
|
||
#. module: account_invoice_repair_info_section | ||
#: model:ir.model.fields,field_description:account_invoice_repair_info_section.field_account_move____last_update | ||
#: model:ir.model.fields,field_description:account_invoice_repair_info_section.field_repair_order____last_update | ||
msgid "Last Modified on" | ||
msgstr "" | ||
|
||
#. module: account_invoice_repair_info_section | ||
#: code:addons/account_invoice_repair_info_section/models/account_move.py:0 | ||
#, python-format | ||
msgid "OPERATIONS" | ||
msgstr "" | ||
|
||
#. module: account_invoice_repair_info_section | ||
#: code:addons/account_invoice_repair_info_section/models/account_move.py:0 | ||
#, python-format | ||
msgid "PARTS" | ||
msgstr "" | ||
|
||
#. module: account_invoice_repair_info_section | ||
#: model:ir.model,name:account_invoice_repair_info_section.model_repair_order | ||
msgid "Repair Order" | ||
msgstr "" | ||
|
||
#. module: account_invoice_repair_info_section | ||
#: code:addons/account_invoice_repair_info_section/models/account_move.py:0 | ||
#, python-format | ||
msgid "" | ||
"Repair: %(repair)s, VAT: %(vat)s, Product to repair: %(product)s, lot: " | ||
"%(lot)s" | ||
msgstr "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * account_invoice_repair_info_section | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 14.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2025-01-31 06:57+0000\n" | ||
"PO-Revision-Date: 2025-01-31 06:57+0000\n" | ||
"Last-Translator: \n" | ||
"Language-Team: \n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: \n" | ||
"Plural-Forms: \n" | ||
|
||
#. module: account_invoice_repair_info_section | ||
#: model:ir.model.fields,field_description:account_invoice_repair_info_section.field_account_move__display_name | ||
#: model:ir.model.fields,field_description:account_invoice_repair_info_section.field_repair_order__display_name | ||
msgid "Display Name" | ||
msgstr "Nombre mostrado" | ||
|
||
#. module: account_invoice_repair_info_section | ||
#: model:ir.model.fields,field_description:account_invoice_repair_info_section.field_account_move__id | ||
#: model:ir.model.fields,field_description:account_invoice_repair_info_section.field_repair_order__id | ||
msgid "ID" | ||
msgstr "" | ||
|
||
#. module: account_invoice_repair_info_section | ||
#: model:ir.model,name:account_invoice_repair_info_section.model_account_move | ||
msgid "Journal Entry" | ||
msgstr "Asiento contable" | ||
|
||
#. module: account_invoice_repair_info_section | ||
#: model:ir.model.fields,field_description:account_invoice_repair_info_section.field_account_move____last_update | ||
#: model:ir.model.fields,field_description:account_invoice_repair_info_section.field_repair_order____last_update | ||
msgid "Last Modified on" | ||
msgstr "Última modificación en" | ||
|
||
#. module: account_invoice_repair_info_section | ||
#: code:addons/account_invoice_repair_info_section/models/account_move.py:0 | ||
#, python-format | ||
msgid "OPERATIONS" | ||
msgstr "OPERACIONES" | ||
|
||
#. module: account_invoice_repair_info_section | ||
#: code:addons/account_invoice_repair_info_section/models/account_move.py:0 | ||
#, python-format | ||
msgid "PARTS" | ||
msgstr "PIEZAS" | ||
|
||
#. module: account_invoice_repair_info_section | ||
#: model:ir.model,name:account_invoice_repair_info_section.model_repair_order | ||
msgid "Repair Order" | ||
msgstr "Orden de reparación" | ||
|
||
#. module: account_invoice_repair_info_section | ||
#: code:addons/account_invoice_repair_info_section/models/account_move.py:0 | ||
#, python-format | ||
msgid "" | ||
"Repair: %(repair)s, VAT: %(vat)s, Product to repair: %(product)s, lot: " | ||
"%(lot)s" | ||
msgstr "" | ||
"Reparación: %(repair)s, CIF: %(vat)s, Producto a reparar: %(product)s, lote: " | ||
"%(lot)s" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from . import repair_order | ||
from . import account_move |
74 changes: 74 additions & 0 deletions
74
account_invoice_repair_info_section/models/account_move.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
# Copyright 2025 Alfredo de la Fuente - AvanzOSC | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
from odoo import _, api, models | ||
|
||
|
||
class AccountMove(models.Model): | ||
_inherit = "account.move" | ||
|
||
@api.model_create_multi | ||
def create(self, vals_list): | ||
if "from_repair_order" not in self.env.context: | ||
return super().create(vals_list) | ||
my_invoice_line_ids = [] | ||
repairs_treated = self.env["repair.order"] | ||
fee_pending = True | ||
for vals in vals_list: | ||
lines_vals = vals.get("invoice_line_ids") | ||
for line_vals in lines_vals: | ||
if "repair_line_ids" in line_vals[2]: | ||
repair_line = self.env["repair.line"].browse( | ||
line_vals[2].get("repair_line_ids")[0][1] | ||
) | ||
if repair_line.repair_id not in repairs_treated: | ||
fee_pending = True | ||
repairs_treated += repair_line.repair_id | ||
my_invoice_line_ids = self._prepare_repair_info_section( | ||
repair_line.repair_id, my_invoice_line_ids, False | ||
) | ||
elif "repair_fee_ids" in line_vals[2]: | ||
repair_fee = self.env["repair.fee"].browse( | ||
line_vals[2].get("repair_fee_ids")[0][1] | ||
) | ||
if (repair_fee.repair_id not in repairs_treated) or fee_pending: | ||
repairs_treated += repair_fee.repair_id | ||
fee_pending = False | ||
my_invoice_line_ids = self._prepare_repair_info_section( | ||
repair_fee.repair_id, my_invoice_line_ids, True | ||
) | ||
my_invoice_line_ids.append(line_vals) | ||
vals["invoice_line_ids"] = my_invoice_line_ids | ||
return super().create(vals_list) | ||
|
||
def _prepare_repair_info_section(self, repair, line_ids, is_operation): | ||
if not is_operation: | ||
vals = self._prepare_values_for_repair(repair) | ||
line_ids.append((0, 0, vals)) | ||
my_name = _("OPERATIONS") if is_operation else _("PARTS") | ||
my_name = _("{} - {}").format(my_name, repair.name) | ||
vals = { | ||
"name": my_name, | ||
"display_type": "line_section", | ||
} | ||
line_ids.append((0, 0, vals)) | ||
return line_ids | ||
|
||
def _prepare_values_for_repair(self, repair): | ||
repair_name = self._get_repair_name_for_values(repair) | ||
vals = { | ||
"name": repair_name, | ||
"display_type": "line_section", | ||
} | ||
return vals | ||
|
||
def _get_repair_name_for_values(self, repair): | ||
repair_name = _( | ||
"Repair: %(repair)s, VAT: %(vat)s, Product to repair: " | ||
"%(product)s, lot: %(lot)s" | ||
) % { | ||
"repair": repair.name, | ||
"vat": repair.partner_id.vat or "", | ||
"product": repair.product_id.name, | ||
"lot": repair.lot_id.name or "", | ||
} | ||
return repair_name |
12 changes: 12 additions & 0 deletions
12
account_invoice_repair_info_section/models/repair_order.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Copyright 2025 Alfredo de la Fuente - AvanzOSC | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
from odoo import models | ||
|
||
|
||
class RepairOrder(models.Model): | ||
_inherit = "repair.order" | ||
|
||
def _create_invoices(self, group=False): | ||
return super( | ||
RepairOrder, self.with_context(from_repair_order=True) | ||
)._create_invoices(group=group) |
1 change: 1 addition & 0 deletions
1
setup/account_invoice_repair_info_section/odoo/addons/account_invoice_repair_info_section
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../../account_invoice_repair_info_section |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import setuptools | ||
|
||
setuptools.setup( | ||
setup_requires=['setuptools-odoo'], | ||
odoo_addon=True, | ||
) |