Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
8e47401
[9.0][WIP] account_invoice_margin: New module
sergio-teruel Jul 11, 2017
8629a83
[MIG] account_invoice_margin: Migration to v11
sergio-teruel Oct 9, 2018
6ece4ec
[FIX] account_invoice_margin: Avoid error on empty invoice_id
pedrobaeza Nov 27, 2018
b270b44
[11.0][IMP] account_invoice_margin: Minor fix in the same PR
sergio-teruel Apr 17, 2019
05cebbc
[FIX] account_invoice_margin: Set purchase_price when user has not se…
sergio-teruel Dec 3, 2019
de84534
account_invoice_margin 11.0.1.1.0
OCA-git-bot Dec 4, 2019
1cc3df3
[MIG] account_invoice_margin: Migration to v12.0
sergio-teruel Dec 4, 2019
227a63f
[UPD] Update account_invoice_margin.pot
oca-travis Dec 9, 2019
a3c5503
[IMP] make purchase price computation overloadable
legalsylvain Dec 11, 2019
c0c5701
[IMP] account_invoice_margin: margins computed with read_group + virt…
pedrobaeza Dec 13, 2019
32d9b93
[IMP] move demo data for group, in data folder
legalsylvain Jan 7, 2020
bdd8e4d
[UPD] Update account_invoice_margin.pot
oca-travis Jan 7, 2020
68e7901
account_invoice_margin 12.0.2.0.0
OCA-git-bot Jan 7, 2020
a765cd3
Update translation files
oca-transbot Jan 7, 2020
7b4c003
[IMP] account_invoice_margin: black, isort
sergio-teruel Feb 22, 2020
7c4b2c0
[MIG] account_invoice_margin: Migration to v13.0
sergio-teruel Feb 22, 2020
4fa8d0d
[IMP] account_invoice_margin: Take on account invoice lines with down…
sergio-teruel Mar 26, 2020
0a7d65f
[UPD] Update account_invoice_margin.pot
oca-travis Jul 17, 2020
d4fc2bc
Update translation files
oca-transbot Jul 17, 2020
e7ff771
Update translation files
oca-transbot Aug 16, 2020
f8c7c25
Translated using Weblate (Spanish)
HaraldPanten Dec 16, 2020
65210c9
[ADD] generic method for better inheritance
Feb 1, 2021
7a41e9b
[IMP] skip margin calculation for Down Payment invoice
Feb 1, 2021
da22778
[UPD] README.rst
OCA-git-bot Feb 2, 2021
9fa9fb7
account_invoice_margin 13.0.1.0.1
OCA-git-bot Feb 2, 2021
3a9ef01
[13.0][IMP] account_invoice_margin: black, isort, prettier
Reyes4711-S73 Mar 9, 2021
738b00f
[14.0][MIG] account_invoice_margin: Migration to 14.0
Reyes4711-S73 Mar 9, 2021
81d7bc0
[IMP] account_invoice_margin: Do optional fields in tree view
sergio-teruel May 3, 2021
232e69b
[UPD] Update account_invoice_margin.pot
oca-travis Jul 30, 2021
60a3fe5
[UPD] README.rst
OCA-git-bot Jul 30, 2021
8547a50
[IMP] account_invoice_margin: Avoid error when trying to install modu…
Sep 21, 2021
7d18ede
account_invoice_margin 14.0.1.0.1
OCA-git-bot Sep 29, 2021
fcda73c
[MIG] account_invoice_margin: Migration to 15.0
nedaszilinskas Jun 21, 2022
3587e9a
[UPD] Update account_invoice_margin.pot
Jun 29, 2022
7dfebc7
[UPD] README.rst
OCA-git-bot Jun 29, 2022
c6f4149
[FIX] account_invoice_margin: Take currency into account
pedrobaeza Aug 9, 2022
db37cb2
account_invoice_margin 15.0.1.0.1
OCA-git-bot Aug 15, 2022
a262480
[MIG] account_invoice_margin: Migration to 16.0
ljsalvatierra-factorlibre Mar 10, 2023
c54670e
[UPD] Update account_invoice_margin.pot
Jun 2, 2023
61bd6d2
[UPD] README.rst
OCA-git-bot Jun 2, 2023
1549b34
Added translation using Weblate (French (France) (fr_FR))
sanrav Jun 5, 2023
bff8834
Translated using Weblate (French)
sanrav Jun 5, 2023
8ce96e2
Translated using Weblate (French (France) (fr_FR))
sanrav Jun 5, 2023
cb7be5f
[UPD] README.rst
OCA-git-bot Sep 3, 2023
c3b0379
Update translation files
weblate Oct 10, 2023
8abdc71
Translated using Weblate (Spanish)
Ivorra78 Oct 12, 2023
ee01a4f
[IMP] account_invoice_margin: test performance improvement
Oct 20, 2023
09cd2c8
[BOT] post-merge updates
OCA-git-bot Oct 23, 2023
c3a349c
[IMP] account_invoice_margin: pre-commit auto fixes
jcdrubay Dec 22, 2023
e9382cb
[MIG] account_invoice_margin: Migration to 17.0
jcdrubay Dec 22, 2023
041cc9a
[UPD] Update account_invoice_margin.pot
Dec 25, 2023
b9ddff2
[BOT] post-merge updates
OCA-git-bot Dec 25, 2023
af60a2d
Added translation using Weblate (Italian)
mymage Feb 4, 2024
a078dd8
Translated using Weblate (Italian)
mymage Feb 6, 2024
50c44d5
[IMP] account_invoice_margin: pre-commit auto fixes
BhaveshHeliconia Feb 14, 2025
cde4b72
[MIG] account_invoice_margin: Migration to 18.0
BhaveshHeliconia Feb 14, 2025
1041a54
[UPD] Update account_invoice_margin.pot
Apr 9, 2025
eed7ab8
[BOT] post-merge updates
OCA-git-bot Apr 9, 2025
f4ae37b
[MIG] account_invoice_margin: Migration to 19.0
Debora7 Jan 8, 2026
be82159
[UPD] Update account_invoice_margin.pot
Jun 18, 2026
d59c258
[BOT] post-merge updates
OCA-git-bot Jun 18, 2026
50cb74e
Added translation using Weblate (Spanish (Dominican Republic))
stferraro Nov 3, 2026
4af7139
Translated using Weblate (Spanish (Dominican Republic))
stferraro Nov 3, 2026
18319bb
Added translation using Weblate (Spanish (Venezuela))
stferraro Nov 3, 2026
1a438d3
Translated using Weblate (Spanish (Venezuela))
stferraro Nov 3, 2026
482d897
[IMP] account_invoice_margin: pre-commit auto fixes
arantxa-s73 Nov 17, 2026
95bbf10
[MIG] account_invoice_margin: Migration to 20.0
arantxa-s73 Nov 17, 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
140 changes: 140 additions & 0 deletions account_invoice_margin/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
.. 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:044637822e5eeb0b498cfb5d300d8e9a9eeb583f50feeae663088dcd9626ed38
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |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/20.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-20-0/margin-analysis-20-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=20.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/20.0/account_invoice_margin/static/description/account_invoice_form.png
.. |image2| image:: https://raw.githubusercontent.com/OCA/margin-analysis/20.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:%2020.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

- `Studio73 <https://www.studio73.es>`__

- Arantxa Gandia

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/20.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 <[email protected]>
# 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 <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
"name": "Account Invoice Margin",
"summary": "Show margin in invoices",
"version": "20.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
"""
)
84 changes: 84 additions & 0 deletions account_invoice_margin/i18n/account_invoice_margin.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * account_invoice_margin
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 19.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.fields,field_description:account_invoice_margin.field_account_invoice_report__display_name
#: model:ir.model.fields,field_description:account_invoice_margin.field_account_move__display_name
#: model:ir.model.fields,field_description:account_invoice_margin.field_account_move_line__display_name
msgid "Display Name"
msgstr ""

#. module: account_invoice_margin
#: model:ir.model.fields,field_description:account_invoice_margin.field_account_invoice_report__id
#: model:ir.model.fields,field_description:account_invoice_margin.field_account_move__id
#: model:ir.model.fields,field_description:account_invoice_margin.field_account_move_line__id
msgid "ID"
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
Loading