Skip to content
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

[16.0][MIG] account_invoice_margin: Migration to v16 #163

Merged
merged 39 commits into from
Jun 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
7eb0c61
[9.0][WIP] account_invoice_margin: New module
sergio-teruel Jul 11, 2017
8f17b39
[MIG] account_invoice_margin: Migration to v11
sergio-teruel Oct 9, 2018
fe04e96
[FIX] account_invoice_margin: Avoid error on empty invoice_id
pedrobaeza Nov 27, 2018
4da941c
[11.0][IMP] account_invoice_margin: Minor fix in the same PR
sergio-teruel Apr 17, 2019
d34c9b6
[FIX] account_invoice_margin: Set purchase_price when user has not se…
sergio-teruel Dec 3, 2019
5998d5b
account_invoice_margin 11.0.1.1.0
OCA-git-bot Dec 4, 2019
766b7ec
[MIG] account_invoice_margin: Migration to v12.0
sergio-teruel Dec 4, 2019
45b49f6
[UPD] Update account_invoice_margin.pot
oca-travis Dec 9, 2019
f3c4a24
[IMP] make purchase price computation overloadable
legalsylvain Dec 11, 2019
f565ffb
[IMP] account_invoice_margin: margins computed with read_group + virt…
pedrobaeza Dec 13, 2019
70687e0
[IMP] move demo data for group, in data folder
legalsylvain Jan 7, 2020
b2fd231
[UPD] Update account_invoice_margin.pot
oca-travis Jan 7, 2020
c44de54
account_invoice_margin 12.0.2.0.0
OCA-git-bot Jan 7, 2020
7228d92
Update translation files
oca-transbot Jan 7, 2020
d2b450f
[IMP] account_invoice_margin: black, isort
sergio-teruel Feb 22, 2020
e7f9ee6
[MIG] account_invoice_margin: Migration to v13.0
sergio-teruel Feb 22, 2020
96798eb
[IMP] account_invoice_margin: Take on account invoice lines with down…
sergio-teruel Mar 26, 2020
1a47d81
[UPD] Update account_invoice_margin.pot
oca-travis Jul 17, 2020
9eae668
Update translation files
oca-transbot Jul 17, 2020
67e36ea
Update translation files
oca-transbot Aug 16, 2020
b2d049b
Translated using Weblate (Spanish)
HaraldPanten Dec 16, 2020
3134c6b
[ADD] generic method for better inheritance
Feb 1, 2021
22a7c6f
[IMP] skip margin calculation for Down Payment invoice
Feb 1, 2021
5de6036
[UPD] README.rst
OCA-git-bot Feb 2, 2021
fa1dfa4
account_invoice_margin 13.0.1.0.1
OCA-git-bot Feb 2, 2021
860ad7b
[13.0][IMP] account_invoice_margin: black, isort, prettier
Reyes4711-S73 Mar 9, 2021
477cc06
[14.0][MIG] account_invoice_margin: Migration to 14.0
Reyes4711-S73 Mar 9, 2021
2d5d0c6
[IMP] account_invoice_margin: Do optional fields in tree view
sergio-teruel May 3, 2021
815d2c1
[UPD] Update account_invoice_margin.pot
oca-travis Jul 30, 2021
920c502
[UPD] README.rst
OCA-git-bot Jul 30, 2021
9fd297e
[IMP] account_invoice_margin: Avoid error when trying to install modu…
Sep 21, 2021
ea78da2
account_invoice_margin 14.0.1.0.1
OCA-git-bot Sep 29, 2021
328f6ba
[MIG] account_invoice_margin: Migration to 15.0
nedaszilinskas Jun 21, 2022
0dd9ccc
[UPD] Update account_invoice_margin.pot
Jun 29, 2022
393588e
[UPD] README.rst
OCA-git-bot Jun 29, 2022
189f362
[FIX] account_invoice_margin: Take currency into account
pedrobaeza Aug 9, 2022
071b978
account_invoice_margin 15.0.1.0.1
OCA-git-bot Aug 15, 2022
cd73bf4
[IMP] account_invoice_margin: pre-commit stuff
ljsalvatierra-factorlibre Mar 1, 2023
82a1784
[MIG] account_invoice_margin: Migration to 16.0
ljsalvatierra-factorlibre Mar 10, 2023
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
114 changes: 114 additions & 0 deletions account_invoice_margin/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
======================
Account Invoice Margin
======================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |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/licence-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/15.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-15-0/margin-analysis-15-0-account_invoice_margin
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/132/15.0
:alt: Try me on Runbot

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

This module allows to show sales margin in invoices.

The new information is available:

* on the account form view

.. figure:: https://raw.githubusercontent.com/OCA/margin-analysis/15.0/account_invoice_margin/static/description/account_invoice_form.png

* and on the account tree view

.. figure:: https://raw.githubusercontent.com/OCA/margin-analysis/15.0/account_invoice_margin/static/description/account_invoice_tree.png

**Table of contents**

.. contents::
:local:

Usage
=====

This module also adds a security group.

#. 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 smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/margin-analysis/issues/new?body=module:%20account_invoice_margin%0Aversion:%2015.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

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/15.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": "16.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",
}
56 changes: 56 additions & 0 deletions account_invoice_margin/hooks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import logging

from odoo.tools 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(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
"""
)
69 changes: 69 additions & 0 deletions account_invoice_margin/i18n/account_invoice_margin.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * account_invoice_margin
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 15.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_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 ""

#. 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 ""

#. 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 ""

#. 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 ""
78 changes: 78 additions & 0 deletions account_invoice_margin/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# 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: 2020-12-16 22:19+0000\n"
"Last-Translator: Harald Panten <[email protected]>\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.3.2\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 Entries"
msgstr "Asientos Contables"

#. 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_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
msgid "Margin"
msgstr "Margen"

#. module: account_invoice_margin
#: 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 "Margen (%)"

#. module: account_invoice_margin
#: 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 "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"

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

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

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