Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
d441f0e
[9.0][WIP] account_invoice_margin: New module
sergio-teruel Jul 11, 2017
db69e3c
[MIG] account_invoice_margin: Migration to v11
sergio-teruel Oct 9, 2018
6b5f025
[FIX] account_invoice_margin: Avoid error on empty invoice_id
pedrobaeza Nov 27, 2018
e4362d1
[11.0][IMP] account_invoice_margin: Minor fix in the same PR
sergio-teruel Apr 17, 2019
050a499
[FIX] account_invoice_margin: Set purchase_price when user has not se…
sergio-teruel Dec 3, 2019
97dd484
account_invoice_margin 11.0.1.1.0
OCA-git-bot Dec 4, 2019
02aedcd
[MIG] account_invoice_margin: Migration to v12.0
sergio-teruel Dec 4, 2019
aa991f4
[UPD] Update account_invoice_margin.pot
oca-travis Dec 9, 2019
c878d1d
[IMP] make purchase price computation overloadable
legalsylvain Dec 11, 2019
f7962a1
[IMP] account_invoice_margin: margins computed with read_group + virt…
pedrobaeza Dec 13, 2019
ff42b6f
[IMP] move demo data for group, in data folder
legalsylvain Jan 7, 2020
f201992
[UPD] Update account_invoice_margin.pot
oca-travis Jan 7, 2020
b590282
account_invoice_margin 12.0.2.0.0
OCA-git-bot Jan 7, 2020
5db7637
Update translation files
oca-transbot Jan 7, 2020
47dbbae
[IMP] account_invoice_margin: black, isort
sergio-teruel Feb 22, 2020
f3f16ae
[MIG] account_invoice_margin: Migration to v13.0
sergio-teruel Feb 22, 2020
4dae328
[IMP] account_invoice_margin: Take on account invoice lines with down…
sergio-teruel Mar 26, 2020
5627b9a
[UPD] Update account_invoice_margin.pot
oca-travis Jul 17, 2020
abfa3bd
Update translation files
oca-transbot Jul 17, 2020
11ea109
Update translation files
oca-transbot Aug 16, 2020
12cfa84
Translated using Weblate (Spanish)
HaraldPanten Dec 16, 2020
2deaebd
[ADD] generic method for better inheritance
Feb 1, 2021
c17a983
[IMP] skip margin calculation for Down Payment invoice
Feb 1, 2021
b1155a7
[UPD] README.rst
OCA-git-bot Feb 2, 2021
5cc6c00
account_invoice_margin 13.0.1.0.1
OCA-git-bot Feb 2, 2021
ca86665
[13.0][IMP] account_invoice_margin: black, isort, prettier
Reyes4711-S73 Mar 9, 2021
a883575
[14.0][MIG] account_invoice_margin: Migration to 14.0
Reyes4711-S73 Mar 9, 2021
54762f0
[IMP] account_invoice_margin: Do optional fields in tree view
sergio-teruel May 3, 2021
600830a
[UPD] Update account_invoice_margin.pot
oca-travis Jul 30, 2021
0df9d99
[UPD] README.rst
OCA-git-bot Jul 30, 2021
f9972c3
[IMP] account_invoice_margin: Avoid error when trying to install modu…
Sep 21, 2021
dbe0ef6
account_invoice_margin 14.0.1.0.1
OCA-git-bot Sep 29, 2021
2a64961
[MIG] account_invoice_margin: Migration to 15.0
nedaszilinskas Jun 21, 2022
13a036a
[UPD] Update account_invoice_margin.pot
Jun 29, 2022
7147d1f
[UPD] README.rst
OCA-git-bot Jun 29, 2022
e78197f
[FIX] account_invoice_margin: Take currency into account
pedrobaeza Aug 9, 2022
29fff4c
account_invoice_margin 15.0.1.0.1
OCA-git-bot Aug 15, 2022
4b468cd
[MIG] account_invoice_margin: Migration to 16.0
ljsalvatierra-factorlibre Mar 10, 2023
5e210be
[UPD] Update account_invoice_margin.pot
Jun 2, 2023
7729192
[UPD] README.rst
OCA-git-bot Jun 2, 2023
b39321d
Added translation using Weblate (French (France) (fr_FR))
sanrav Jun 5, 2023
a7adc15
Translated using Weblate (French)
sanrav Jun 5, 2023
980194a
Translated using Weblate (French (France) (fr_FR))
sanrav Jun 5, 2023
cb58d64
[UPD] README.rst
OCA-git-bot Sep 3, 2023
7c80800
Update translation files
weblate Oct 10, 2023
7569d87
Translated using Weblate (Spanish)
Ivorra78 Oct 12, 2023
9ed29ff
[IMP] account_invoice_margin: test performance improvement
josep-tecnativa Oct 20, 2023
e558beb
[BOT] post-merge updates
OCA-git-bot Oct 23, 2023
118d2df
[IMP] account_invoice_margin: pre-commit auto fixes
jcdrubay Dec 22, 2023
b179796
[MIG] account_invoice_margin: Migration to 17.0
jcdrubay Dec 22, 2023
c08a381
[UPD] Update account_invoice_margin.pot
Dec 25, 2023
2b5c2b6
[BOT] post-merge updates
OCA-git-bot Dec 25, 2023
2997ccd
Added translation using Weblate (Italian)
mymage Feb 4, 2024
7eaf92a
Translated using Weblate (Italian)
mymage Feb 6, 2024
ae5ee87
[IMP] account_invoice_margin: pre-commit auto fixes
BhaveshHeliconia Feb 14, 2025
6bce4c5
[MIG] account_invoice_margin: Migration to 18.0
BhaveshHeliconia Feb 14, 2025
d75b937
[UPD] Update account_invoice_margin.pot
Apr 9, 2025
4a09012
[BOT] post-merge updates
OCA-git-bot Apr 9, 2025
eb3dd3d
[MIG] account_invoice_margin: Migration to 19.0
Debora7 Jan 8, 2026
f2ba90b
Fixed pre-commit issues.
Debora7 Jan 15, 2026
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
9 changes: 0 additions & 9 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -92,20 +92,11 @@ enable=anomalous-backslash-in-string,
no-write-in-compute,
# messages that do not cause the lint step to fail
consider-merging-classes-inherited,
create-user-wo-reset-password,
dangerous-filter-wo-user,
deprecated-module,
file-not-used,
invalid-commit,
missing-manifest-dependency,
missing-newline-extrafiles,
missing-readme,
no-utf8-coding-comment,
odoo-addons-relative-import,
old-api7-method-defined,
redefined-builtin,
too-complex,
unnecessary-utf8-coding-comment,
manifest-external-assets


Expand Down
136 changes: 136 additions & 0 deletions account_invoice_margin/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
.. image:: https://odoo-community.org/readme-banner-image
:target: https://odoo-community.org/get-involved?utm_source=readme
:alt: Odoo Community Association

======================
Account Invoice Margin
======================

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

.. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png
:target: https://odoo-community.org/page/development-status
:alt: Production/Stable
.. |badge2| image:: https://img.shields.io/badge/license-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-OCA%2Fmargin--analysis-lightgray.png?logo=github
:target: https://github.com/OCA/margin-analysis/tree/19.0/account_invoice_margin
:alt: OCA/margin-analysis
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/margin-analysis-19-0/margin-analysis-19-0-account_invoice_margin
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/margin-analysis&target_branch=19.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module allows to show sales margin in invoices.

The new information is available:

- on the invoice form view

|image1|

- and on the invoice tree view

|image2|

.. |image1| image:: https://raw.githubusercontent.com/OCA/margin-analysis/19.0/account_invoice_margin/static/description/account_invoice_form.png
.. |image2| image:: https://raw.githubusercontent.com/OCA/margin-analysis/19.0/account_invoice_margin/static/description/account_invoice_tree.png

**Table of contents**

.. contents::
:local:

Usage
=====

This module also adds a security group.

1. To activate it go to user and active "Show Invoice Margin" in
security options.

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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/margin-analysis/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/OCA/margin-analysis/issues/new?body=module:%20account_invoice_margin%0Aversion:%2019.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
-------

* Tecnativa
* GRAP

Contributors
------------

- `Tecnativa <https://www.tecnativa.com>`__:

- Sergio Teruel

- `GRAP <http://www.grap.coop>`__:

- Sylvain LE GAL (https://twitter.com/legalsylvain)

- `Open Source Integrators <https://www.opensourceintegrators.com>`__:

- Bhavesh Odedra

- `Avoin.Systems <https://www.avoin.systems>`__:

- Nedas Žilinskas

- `Factor Libre <https://factorlibre.com>`__:

- Luis J. Salvatierra

- `Komit <https://komit-consulting.com>`__:

- Jean-Charles Drubay

- `Heliconia Solutions Pvt. Ltd. <https://www.heliconia.io>`__

- Bhavesh Heliconia

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

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

.. |maintainer-sergio-teruel| image:: https://github.com/sergio-teruel.png?size=40px
:target: https://github.com/sergio-teruel
:alt: sergio-teruel

Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-sergio-teruel|

This module is part of the `OCA/margin-analysis <https://github.com/OCA/margin-analysis/tree/19.0/account_invoice_margin>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
6 changes: 6 additions & 0 deletions account_invoice_margin/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# © 2017 Sergio Teruel <sergio.teruel@tecnativa.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from .hooks import pre_init_hook
from . import models
from . import report
22 changes: 22 additions & 0 deletions account_invoice_margin/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright 2017 Sergio Teruel <sergio.teruel@tecnativa.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
"name": "Account Invoice Margin",
"summary": "Show margin in invoices",
"version": "19.0.1.0.0",
"category": "Account",
"website": "https://github.com/OCA/margin-analysis",
"author": "Tecnativa, GRAP, Odoo Community Association (OCA)",
"license": "AGPL-3",
"development_status": "Production/Stable",
"maintainers": ["sergio-teruel"],
"application": False,
"installable": True,
"depends": ["account"],
"data": [
"security/account_invoice_margin_security.xml",
"views/account_invoice_margin_view.xml",
],
"pre_init_hook": "pre_init_hook",
}
57 changes: 57 additions & 0 deletions account_invoice_margin/hooks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import logging

from odoo.tools.sql import column_exists, create_column

_logger = logging.getLogger(__name__)

COLUMNS = (
("account_move", "margin"),
("account_move", "margin_signed"),
("account_move", "margin_percent"),
("account_move_line", "margin"),
("account_move_line", "margin_signed"),
("account_move_line", "margin_percent"),
("account_move_line", "purchase_price"),
)


def pre_init_hook(env):
cr = env.cr
for table, column in COLUMNS:
if not column_exists(cr, table, column):
_logger.info("Create column %s in database", column)
create_column(cr, table, column, "numeric")
cr.execute(
"""
WITH am AS(
SELECT id FROM account_move WHERE move_type NOT ILIKE 'in_%'
)
UPDATE account_move_line
SET margin = price_subtotal, margin_signed = price_subtotal,
margin_percent = 100
FROM am
WHERE am.id = account_move_line.move_id
AND price_subtotal > 0.0;
"""
)
cr.execute(
"""
WITH aml AS(
SELECT
account_move_line.move_id,
SUM(account_move_line.margin) AS sum_margin,
SUM(account_move_line.margin_signed) AS sum_margin_signed
FROM account_move_line
INNER JOIN account_move
ON account_move.id = account_move_line.move_id
GROUP BY account_move_line.move_id
)
UPDATE account_move
SET margin = aml.sum_margin,
margin_signed = aml.sum_margin_signed,
margin_percent = aml.sum_margin_signed / amount_untaxed * 100
FROM aml
WHERE account_move.id = aml.move_id
AND account_move.amount_untaxed > 0.0
"""
)
70 changes: 70 additions & 0 deletions account_invoice_margin/i18n/account_invoice_margin.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * account_invoice_margin
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 18.0\n"
"Report-Msgid-Bugs-To: \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_margin
#: model:ir.model.fields,field_description:account_invoice_margin.field_account_move_line__purchase_price
msgid "Cost"
msgstr ""

#. module: account_invoice_margin
#: model:ir.model,name:account_invoice_margin.model_account_invoice_report
msgid "Invoices Statistics"
msgstr ""

#. module: account_invoice_margin
#: model:ir.model,name:account_invoice_margin.model_account_move
msgid "Journal Entry"
msgstr ""

#. module: account_invoice_margin
#: model:ir.model,name:account_invoice_margin.model_account_move_line
msgid "Journal Item"
msgstr ""

#. module: account_invoice_margin
#: model:ir.model.fields,field_description:account_invoice_margin.field_account_bank_statement_line__margin
#: model:ir.model.fields,field_description:account_invoice_margin.field_account_move__margin
#: model:ir.model.fields,field_description:account_invoice_margin.field_account_move_line__margin
msgid "Margin"
msgstr ""

#. module: account_invoice_margin
#: model:ir.model.fields,field_description:account_invoice_margin.field_account_bank_statement_line__margin_percent
#: model:ir.model.fields,field_description:account_invoice_margin.field_account_move__margin_percent
#: model:ir.model.fields,field_description:account_invoice_margin.field_account_move_line__margin_percent
msgid "Margin (%)"
msgstr ""

#. module: account_invoice_margin
#: model:ir.model.fields,field_description:account_invoice_margin.field_account_invoice_report__margin
msgid "Margin Analysis"
msgstr ""

#. module: account_invoice_margin
#: model:ir.model.fields,field_description:account_invoice_margin.field_account_bank_statement_line__margin_signed
#: model:ir.model.fields,field_description:account_invoice_margin.field_account_move__margin_signed
#: model:ir.model.fields,field_description:account_invoice_margin.field_account_move_line__margin_signed
msgid "Margin Signed"
msgstr ""

#. module: account_invoice_margin
#: model:res.groups,name:account_invoice_margin.group_account_invoice_margin_security
msgid "Show Invoice Margin"
msgstr ""

#. module: account_invoice_margin
#: model_terms:ir.ui.view,arch_db:account_invoice_margin.view_account_invoice_tree
msgid "Total"
msgstr ""
Loading