Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
91a9bcc
[9.0][WIP] account_invoice_margin: New module
sergio-teruel Jul 11, 2017
847d7e4
[MIG] account_invoice_margin: Migration to v11
sergio-teruel Oct 9, 2018
eb81e05
[FIX] account_invoice_margin: Avoid error on empty invoice_id
pedrobaeza Nov 27, 2018
02f6dd5
[11.0][IMP] account_invoice_margin: Minor fix in the same PR
sergio-teruel Apr 17, 2019
c45d854
[FIX] account_invoice_margin: Set purchase_price when user has not se…
sergio-teruel Dec 3, 2019
fb3d62d
account_invoice_margin 11.0.1.1.0
OCA-git-bot Dec 4, 2019
20348a3
[MIG] account_invoice_margin: Migration to v12.0
sergio-teruel Dec 4, 2019
5861197
[UPD] Update account_invoice_margin.pot
oca-travis Dec 9, 2019
82a0fbc
[IMP] make purchase price computation overloadable
legalsylvain Dec 11, 2019
d1956a2
[IMP] account_invoice_margin: margins computed with read_group + virt…
pedrobaeza Dec 13, 2019
eae1239
[IMP] move demo data for group, in data folder
legalsylvain Jan 7, 2020
02fa0ac
[UPD] Update account_invoice_margin.pot
oca-travis Jan 7, 2020
4c7277b
account_invoice_margin 12.0.2.0.0
OCA-git-bot Jan 7, 2020
1ec1de8
Update translation files
oca-transbot Jan 7, 2020
c035368
[IMP] account_invoice_margin: black, isort
sergio-teruel Feb 22, 2020
4378ece
[MIG] account_invoice_margin: Migration to v13.0
sergio-teruel Feb 22, 2020
726eb60
[IMP] account_invoice_margin: Take on account invoice lines with down…
sergio-teruel Mar 26, 2020
8703cc1
[UPD] Update account_invoice_margin.pot
oca-travis Jul 17, 2020
ab8750c
Update translation files
oca-transbot Jul 17, 2020
a1c824f
Update translation files
oca-transbot Aug 16, 2020
252c0c7
Translated using Weblate (Spanish)
HaraldPanten Dec 16, 2020
457202f
[ADD] generic method for better inheritance
Feb 1, 2021
2796a49
[IMP] skip margin calculation for Down Payment invoice
Feb 1, 2021
6c5ae26
[UPD] README.rst
OCA-git-bot Feb 2, 2021
766b792
account_invoice_margin 13.0.1.0.1
OCA-git-bot Feb 2, 2021
dde0f0b
[13.0][IMP] account_invoice_margin: black, isort, prettier
Reyes4711-S73 Mar 9, 2021
4667caa
[14.0][MIG] account_invoice_margin: Migration to 14.0
Reyes4711-S73 Mar 9, 2021
0c17de6
[IMP] account_invoice_margin: Do optional fields in tree view
sergio-teruel May 3, 2021
9115507
[UPD] Update account_invoice_margin.pot
oca-travis Jul 30, 2021
efcb72a
[UPD] README.rst
OCA-git-bot Jul 30, 2021
af65f14
[IMP] account_invoice_margin: Avoid error when trying to install modu…
Sep 21, 2021
e1692a9
account_invoice_margin 14.0.1.0.1
OCA-git-bot Sep 29, 2021
f84b4d2
[MIG] account_invoice_margin: Migration to 15.0
nedaszilinskas Jun 21, 2022
92f3fac
[UPD] Update account_invoice_margin.pot
Jun 29, 2022
fb9b9e3
[UPD] README.rst
OCA-git-bot Jun 29, 2022
f7614b7
[FIX] account_invoice_margin: Take currency into account
pedrobaeza Aug 9, 2022
c52465d
account_invoice_margin 15.0.1.0.1
OCA-git-bot Aug 15, 2022
848ac3e
[MIG] account_invoice_margin: Migration to 16.0
ljsalvatierra-factorlibre Mar 10, 2023
c5d0988
[UPD] Update account_invoice_margin.pot
Jun 2, 2023
d3dfa3a
[UPD] README.rst
OCA-git-bot Jun 2, 2023
3b5171b
Added translation using Weblate (French (France) (fr_FR))
sanrav Jun 5, 2023
9b016c1
Translated using Weblate (French)
sanrav Jun 5, 2023
6dda291
Translated using Weblate (French (France) (fr_FR))
sanrav Jun 5, 2023
f01a955
[UPD] README.rst
OCA-git-bot Sep 3, 2023
dd02867
Update translation files
weblate Oct 10, 2023
eb48f04
Translated using Weblate (Spanish)
Ivorra78 Oct 12, 2023
94e0512
[IMP] account_invoice_margin: test performance improvement
josep-tecnativa Oct 20, 2023
78c9485
[BOT] post-merge updates
OCA-git-bot Oct 23, 2023
26c0f00
[IMP] account_invoice_margin: pre-commit auto fixes
jcdrubay Dec 22, 2023
11a2309
[MIG] account_invoice_margin: Migration to 17.0
jcdrubay Dec 22, 2023
b780cb8
[UPD] Update account_invoice_margin.pot
Dec 25, 2023
ce184db
[BOT] post-merge updates
OCA-git-bot Dec 25, 2023
488ef2b
Added translation using Weblate (Italian)
mymage Feb 4, 2024
39bfc46
Translated using Weblate (Italian)
mymage Feb 6, 2024
e745cb6
[IMP] account_invoice_margin: pre-commit auto fixes
BhaveshHeliconia Feb 14, 2025
5199261
[MIG] account_invoice_margin: Migration to 18.0
BhaveshHeliconia Feb 14, 2025
ef53bf1
[UPD] Update account_invoice_margin.pot
Apr 9, 2025
00c9578
[BOT] post-merge updates
OCA-git-bot Apr 9, 2025
1d872e7
[MIG] account_invoice_margin: Migration to 19.0
Alexis-SDK Jun 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
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 ""
87 changes: 87 additions & 0 deletions account_invoice_margin/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * account_invoice_margin
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 9.0c\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-12-04 13:11+0000\n"
"PO-Revision-Date: 2023-10-12 13:38+0000\n"
"Last-Translator: Ivorra78 <informatica@totmaterial.es>\n"
"Language-Team: \n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.17\n"

#. module: account_invoice_margin
#: model:ir.model.fields,field_description:account_invoice_margin.field_account_move_line__purchase_price
msgid "Cost"
msgstr "Coste"

#. module: account_invoice_margin
#: model:ir.model,name:account_invoice_margin.model_account_invoice_report
msgid "Invoices Statistics"
msgstr "Estadísticas de facturas"

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

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

#. 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_invoice_report__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
#: model:ir.model.fields,field_description:account_invoice_margin.field_account_payment__margin
msgid "Margin"
msgstr "Margen"

#. 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
#: model:ir.model.fields,field_description:account_invoice_margin.field_account_payment__margin_percent
msgid "Margin (%)"
msgstr "Margen (%)"

#. 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
#: model:ir.model.fields,field_description:account_invoice_margin.field_account_payment__margin_signed
msgid "Margin Signed"
msgstr "Margen firmado"

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

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

#~ msgid "Journal Entries"
#~ msgstr "Asientos Contables"

#, fuzzy
#~| msgid "Invoice Line"
#~ msgid "Invoice"
#~ msgstr "Línea factura"

#~ msgid "Invoice Line"
#~ msgstr "Línea factura"

#~ msgid "% Margin"
#~ msgstr "% Margen"
Loading
Loading