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

[18.0][MIG] account_invoice_margin_sale: Migration to 18.0 #231

Open
wants to merge 30 commits into
base: 18.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
ca0403d
[UPD] Update account_invoice_margin_sale.pot
oca-travis Oct 14, 2020
3f03f82
Added translation using Weblate (Spanish)
HaraldPanten Dec 16, 2020
a2942af
Translated using Weblate (Spanish)
HaraldPanten Dec 16, 2020
506f0e4
[IMP] skip margin calculation for Down Payment invoice
Feb 1, 2021
6c48ceb
[14.0][MIG] account_invoice_margin_sale: Migration to 14.0
Reyes4711-S73 May 3, 2021
2ba1a79
Translated using Weblate (Spanish)
rafamarpe Feb 27, 2022
ad1f478
[MIG] account_invoice_margin_sale: Migration to 15.0
victoralmau Jul 28, 2022
30af5e1
[UPD] Update account_invoice_margin_sale.pot
Aug 23, 2022
6936529
[UPD] README.rst
OCA-git-bot Aug 23, 2022
2a02232
[MIG] account_invoice_margin_sale: Migration to 16.0
ljsalvatierra-factorlibre May 22, 2023
f4dbdbc
[MIG] account_invoice_margin_sale: Migration to 16.0
ljsalvatierra-factorlibre Jun 5, 2023
f078170
[UPD] Update account_invoice_margin_sale.pot
Jun 5, 2023
8aa4860
[UPD] README.rst
OCA-git-bot Jun 5, 2023
0bb1c68
Update translation files
weblate Jun 5, 2023
74b9737
Added translation using Weblate (French (France) (fr_FR))
sanrav Jun 5, 2023
f745176
Translated using Weblate (French (France) (fr_FR))
sanrav Jun 5, 2023
5f87f89
Translated using Weblate (Spanish)
Gelo-fl Jun 7, 2023
056e9fc
[UPD] README.rst
OCA-git-bot Sep 3, 2023
d8d35e8
[IMP] account_invoice_margin_sale: test performance improvement
josep-tecnativa Oct 20, 2023
a9d3f8e
[BOT] post-merge updates
OCA-git-bot Oct 23, 2023
aac0c97
[FIX] account_invoice_margin_sale: error creating invoice from sale o…
dreispt Jan 8, 2024
223f256
[BOT] post-merge updates
OCA-git-bot Jan 8, 2024
2e71b02
Added translation using Weblate (Italian)
mymage Jan 22, 2024
7299053
Translated using Weblate (Italian)
mymage Jan 29, 2024
ca9df02
[IMP] account_invoice_margin_sale: pre-commit auto fixes
Feb 19, 2024
8c93d02
[MIG] account_invoice_margin_sale: Migration to 17.0
Feb 19, 2024
8b38ef1
[UPD] Update account_invoice_margin_sale.pot
Apr 6, 2024
4e5850c
[BOT] post-merge updates
OCA-git-bot Apr 6, 2024
2a580ec
[MIG] account_invoice_margin_sale: Migration to 18.0
BhaveshHeliconia Feb 14, 2025
34281ea
[DON'T MERGE] test-requirements.txt
BhaveshHeliconia Feb 14, 2025
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
119 changes: 119 additions & 0 deletions account_invoice_margin_sale/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
===========================
Account Invoice Margin Sale
===========================

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

.. |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/18.0/account_invoice_margin_sale
: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-18-0/margin-analysis-18-0-account_invoice_margin_sale
: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=18.0
:alt: Try me on Runboat

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

This module propagates purchase price from sale order line to invoice
and discards the invoice lines coming from sale order lines with
down-payment when computing the margin.

**Table of contents**

.. contents::
:local:

Installation
============

This module is autoinstalable.

Usage
=====

This module also needs a security group to show margins.

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_sale%0Aversion:%2018.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

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

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

- Sergio Teruel
- Carlos Dauden
- Víctor Martínez

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

- Bhavesh Odedra
- Daniel Reis <[email protected]>

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

- Luis J. Salvatierra

- `Avoin.Systems <https://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
.. |maintainer-carlosdauden| image:: https://github.com/carlosdauden.png?size=40px
:target: https://github.com/carlosdauden
:alt: carlosdauden

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

|maintainer-sergio-teruel| |maintainer-carlosdauden|

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

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
3 changes: 3 additions & 0 deletions account_invoice_margin_sale/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import models
19 changes: 19 additions & 0 deletions account_invoice_margin_sale/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2017-2018 Tecnativa - Sergio Teruel
# Copyright 2019 Tecnativa - Carlos Dauden
# License AGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

{
"name": "Account Invoice Margin Sale",
"summary": "Set margin in invoices from sale orders",
"version": "18.0.1.0.0",
"development_status": "Production/Stable",
"maintainers": ["sergio-teruel", "carlosdauden"],
"category": "Account",
"website": "https://github.com/OCA/margin-analysis",
"author": "Tecnativa, " "Odoo Community Association (OCA)",
"license": "AGPL-3",
"application": False,
"installable": True,
"auto_install": True,
"depends": ["sale_margin", "account_invoice_margin"],
}
29 changes: 29 additions & 0 deletions account_invoice_margin_sale/i18n/account_invoice_margin_sale.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * account_invoice_margin_sale
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 17.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_sale
#: model:ir.model,name:account_invoice_margin_sale.model_account_move
msgid "Journal Entry"
msgstr ""

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

#. module: account_invoice_margin_sale
#: model:ir.model,name:account_invoice_margin_sale.model_sale_order_line
msgid "Sales Order Line"
msgstr ""
35 changes: 35 additions & 0 deletions account_invoice_margin_sale/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * account_invoice_margin_sale
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 13.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2023-06-07 19:09+0000\n"
"Last-Translator: gelo joga Rodríguez <[email protected]>\n"
"Language-Team: none\n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.17\n"

#. module: account_invoice_margin_sale
#: model:ir.model,name:account_invoice_margin_sale.model_account_move
msgid "Journal Entry"
msgstr "Asiento contable"

#. module: account_invoice_margin_sale
#: model:ir.model,name:account_invoice_margin_sale.model_account_move_line
msgid "Journal Item"
msgstr "Apunte contable"

#. module: account_invoice_margin_sale
#: model:ir.model,name:account_invoice_margin_sale.model_sale_order_line
msgid "Sales Order Line"
msgstr "Línea de pedido de venta"

#~ msgid "Journal Entries"
#~ msgstr "Entradas de diario"
32 changes: 32 additions & 0 deletions account_invoice_margin_sale/i18n/fr_FR.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * account_invoice_margin_sale
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2023-06-05 18:09+0000\n"
"Last-Translator: \"Sandrine (ACSONE)\" <[email protected]>\n"
"Language-Team: none\n"
"Language: fr_FR\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n > 1;\n"
"X-Generator: Weblate 4.17\n"

#. module: account_invoice_margin_sale
#: model:ir.model,name:account_invoice_margin_sale.model_account_move
msgid "Journal Entry"
msgstr "Pièce comptable"

#. module: account_invoice_margin_sale
#: model:ir.model,name:account_invoice_margin_sale.model_account_move_line
msgid "Journal Item"
msgstr "Ecriture comptable"

#. module: account_invoice_margin_sale
#: model:ir.model,name:account_invoice_margin_sale.model_sale_order_line
msgid "Sales Order Line"
msgstr "Ligne de commande client"
32 changes: 32 additions & 0 deletions account_invoice_margin_sale/i18n/it.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * account_invoice_margin_sale
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2024-01-29 17:38+0000\n"
"Last-Translator: mymage <[email protected]>\n"
"Language-Team: none\n"
"Language: it\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.17\n"

#. module: account_invoice_margin_sale
#: model:ir.model,name:account_invoice_margin_sale.model_account_move
msgid "Journal Entry"
msgstr "Registrazione contabile"

#. module: account_invoice_margin_sale
#: model:ir.model,name:account_invoice_margin_sale.model_account_move_line
msgid "Journal Item"
msgstr "Movimento contabile"

#. module: account_invoice_margin_sale
#: model:ir.model,name:account_invoice_margin_sale.model_sale_order_line
msgid "Sales Order Line"
msgstr "Riga ordine di vendita"
4 changes: 4 additions & 0 deletions account_invoice_margin_sale/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import sale
from . import account_invoice
33 changes: 33 additions & 0 deletions account_invoice_margin_sale/models/account_invoice.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright 2021 Sergio Teruel <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import api, models


class AccountMove(models.Model):
_inherit = "account.move"

def _get_margin_applicable_lines(self):
invoice_lines = super()._get_margin_applicable_lines()
return invoice_lines.filtered(
lambda x: not any(x.sale_line_ids.mapped("is_downpayment"))
)


class AccountMoveLine(models.Model):
_inherit = "account.move.line"

# pylint: disable=W8110
@api.depends("purchase_price", "price_subtotal")
def _compute_margin(self):
invoice_lines_with_downpayment = self.filtered(
lambda x: any(x.sale_line_ids.mapped("is_downpayment"))
)
invoice_lines_with_downpayment.update(
{
"margin": 0.0,
"margin_signed": 0.0,
"margin_percent": 0.0,
}
)
super(AccountMoveLine, self - invoice_lines_with_downpayment)._compute_margin()
14 changes: 14 additions & 0 deletions account_invoice_margin_sale/models/sale.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright 2017-2018 Tecnativa - Sergio Teruel
# Copyright 2019 Tecnativa - Carlos Dauden
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import models


class SaleOrderLine(models.Model):
_inherit = "sale.order.line"

def _prepare_invoice_line(self, **optional_values):
vals = super()._prepare_invoice_line(**optional_values)
vals["purchase_price"] = self.sudo().purchase_price
return vals
3 changes: 3 additions & 0 deletions account_invoice_margin_sale/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
11 changes: 11 additions & 0 deletions account_invoice_margin_sale/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
- [Tecnativa](https://www.tecnativa.com):
- Sergio Teruel
- Carlos Dauden
- Víctor Martínez
- [Open Source Integrators](https://www.opensourceintegrators.com):
- Bhavesh Odedra
- Daniel Reis \<<[email protected]>\>
- [Factor Libre](https://www.factorlibre.com):
- Luis J. Salvatierra
- [Avoin.Systems](https://avoin.systems/):
- Nedas Żilinskas
3 changes: 3 additions & 0 deletions account_invoice_margin_sale/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This module propagates purchase price from sale order line to invoice
and discards the invoice lines coming from sale order lines with
down-payment when computing the margin.
1 change: 1 addition & 0 deletions account_invoice_margin_sale/readme/INSTALL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This module is autoinstalable.
4 changes: 4 additions & 0 deletions account_invoice_margin_sale/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
This module also needs a security group to show margins.

1. To activate it go to user and active "Show Invoice Margin" in
security options.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading