-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD] new module : account_invoice_default_code_column
- Loading branch information
1 parent
6e3c82c
commit 48f87e7
Showing
13 changed files
with
101 additions
and
0 deletions.
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/grap/grap-odoo-incubator", | ||
"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, | ||
) |