-
-
Notifications
You must be signed in to change notification settings - Fork 700
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
[12.0] ADD account_invoice_default_code_column #1601
Merged
OCA-git-bot
merged 1 commit into
OCA:12.0
from
legalsylvain:12.0-ADD-account_invoice_default_code_column
Jan 27, 2024
+101
−0
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Empty file.
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,20 @@ | ||
# Copyright (C) 2023 - Today: GRAP (http://www.grap.coop) | ||
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain) | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
{ | ||
"name": "Account Invoices - Default Code Column", | ||
"summary": "Display Default code product in a dedicated column on invoice reports", | ||
"version": "12.0.1.0.1", | ||
"category": "Invoicing", | ||
"license": "AGPL-3", | ||
"author": "GRAP,Odoo Community Association (OCA)", | ||
"maintainers": ["legalsylvain"], | ||
"website": "https://github.com/OCA/account-invoicing", | ||
"depends": [ | ||
"account", | ||
], | ||
"data": [ | ||
"reports/report_account_invoice.xml", | ||
], | ||
"installable": True, | ||
} |
Empty file.
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 account_invoice_line |
22 changes: 22 additions & 0 deletions
22
account_invoice_default_code_column/models/account_invoice_line.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,22 @@ | ||
# Copyright (C) 2023 - Today: GRAP (http://www.grap.coop) | ||
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain) | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import api, fields, models | ||
|
||
|
||
class AccountInvoiceLine(models.Model): | ||
_inherit = "account.invoice.line" | ||
|
||
name_without_default_code = fields.Char( | ||
compute="_compute_name_without_default_code" | ||
) | ||
|
||
@api.depends("name", "product_id.default_code") | ||
def _compute_name_without_default_code(self): | ||
for line in self: | ||
line.name_without_default_code = line.name | ||
if line.product_id and line.product_id.default_code: | ||
line.name_without_default_code = line.name_without_default_code.replace( | ||
f"[{line.product_id.default_code}]", "" | ||
).strip() |
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 @@ | ||
* Sylvain LE GAL <https://twitter.com/legalsylvain> |
15 changes: 15 additions & 0 deletions
15
account_invoice_default_code_column/readme/DESCRIPTION.rst
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,15 @@ | ||
In odoo, user has the possibility to rename the "description" field of an invoice line, and at the same time delete / alter the product code. | ||
But in some situation, removing the product code is a problem, because it should be present on the invoice report. | ||
|
||
This module avoids this problem. | ||
|
||
For that purpose, this module adds a new dedicated column "Default code" | ||
in the account invoice report. | ||
As a side effect, it improves readability of the invoices. | ||
|
||
**Without this module** | ||
|
||
.. figure:: ../static/description/1_without_module.png | ||
|
||
**With this module** | ||
.. figure:: ../static/description/2_with_module.png |
34 changes: 34 additions & 0 deletions
34
account_invoice_default_code_column/reports/report_account_invoice.xml
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,34 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- | ||
Copyright (C) 2023 - Today: GRAP (http://www.grap.coop) | ||
@author: Sylvain LE GAL (https://twitter.com/legalsylvain) | ||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
--> | ||
|
||
<odoo> | ||
<template | ||
id="report_invoice_document" | ||
inherit_id="account.report_invoice_document" | ||
priority="1000" | ||
> | ||
<!-- Add 'default_code' Column in table header --> | ||
<xpath expr="//th[@name='th_description']" position="before"> | ||
<th name="default_code" class="text-start"><span>Code</span></th> | ||
</xpath> | ||
|
||
<!-- Add 'default_code' Column in table body --> | ||
<xpath expr="//td[@name='account_invoice_line_name']" position="before"> | ||
<td name="account_invoice_line_default_code"> | ||
<span t-if="line.product_id" t-field="line.product_id.default_code"/> | ||
</td> | ||
</xpath> | ||
|
||
<!-- Replace 'name' column by 'name_without_default_code' column --> | ||
<xpath expr="//td[@name='account_invoice_line_name']" position="replace"> | ||
<td name="account_invoice_line_name_without_default_code"> | ||
<span t-field="line.name_without_default_code" t-options="{'widget': 'text'}"/> | ||
</td> | ||
</xpath> | ||
|
||
</template> | ||
</odoo> |
Binary file added
BIN
+21.6 KB
account_invoice_default_code_column/static/description/1_without_module.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+21.7 KB
account_invoice_default_code_column/static/description/2_with_module.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions
1
setup/account_invoice_default_code_column/odoo/addons/account_invoice_default_code_column
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_default_code_column |
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, | ||
) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
very "habile"