Skip to content

Commit

Permalink
Merge PR #1832 into 15.0
Browse files Browse the repository at this point in the history
Signed-off-by dreispt
  • Loading branch information
OCA-git-bot committed Feb 8, 2022
2 parents d175475 + 446449d commit 931ef79
Show file tree
Hide file tree
Showing 16 changed files with 821 additions and 0 deletions.
77 changes: 77 additions & 0 deletions sale_order_invoice_amount/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
=========================
Sale Order Invoice Amount
=========================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fsale--workflow-lightgray.png?logo=github
:target: https:/OCA/sale-workflow/tree/13.0/sale_order_invoice_amount
:alt: OCA/sale-workflow
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/sale-workflow-13-0/sale-workflow-13-0-sale_order_invoice_amount
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/167/13.0
:alt: Try me on Runbot

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

The purpose of this module is to add two fields in the sale order model:

* invoiced_amount: total invoiced amount.
* uninvoiced_amount: total uninvoiced amount.

**Table of contents**

.. contents::
:local:

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

Bugs are tracked on `GitHub Issues <https:/OCA/sale-workflow/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:/OCA/sale-workflow/issues/new?body=module:%20sale_order_invoice_amount%0Aversion:%2013.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
~~~~~~~

* ForgeFlow

Contributors
~~~~~~~~~~~~

* Mateu Griful <[email protected]>
* Lois Rilo <[email protected]>

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.

This module is part of the `OCA/sale-workflow <https:/OCA/sale-workflow/tree/13.0/sale_order_invoice_amount>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions sale_order_invoice_amount/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
20 changes: 20 additions & 0 deletions sale_order_invoice_amount/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright (C) 2021 ForgeFlow S.L.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)

{
"name": "Sale Order Invoice Amount",
"version": "15.0.1.0.0",
"author": "ForgeFlow, Odoo Community Association (OCA)",
"website": "https:/OCA/sale-workflow",
"category": "Sales",
"license": "LGPL-3",
"summary": "Display the invoiced and uninvoiced total in the sale order",
"depends": ["sale", "account"],
"data": ["views/sale_order_view.xml"],
"installable": True,
"assets": {
"web.assets_qweb": [
"sale_order_invoice_amount/static/src/xml/**/*",
],
},
}
39 changes: 39 additions & 0 deletions sale_order_invoice_amount/i18n/sale_order_invoice_amount.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * sale_order_invoice_amount
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 13.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: sale_order_invoice_amount
#: model:ir.model.fields,field_description:sale_order_invoice_amount.field_sale_order__invoiced_amount
msgid "Invoiced Amount"
msgstr ""

#. module: sale_order_invoice_amount
#: model_terms:ir.ui.view,arch_db:sale_order_invoice_amount.view_order_tree_invoiced_amount
msgid "Invoiced Total"
msgstr ""

#. module: sale_order_invoice_amount
#: model:ir.model,name:sale_order_invoice_amount.model_sale_order
msgid "Sales Order"
msgstr ""

#. module: sale_order_invoice_amount
#: model:ir.model.fields,field_description:sale_order_invoice_amount.field_sale_order__uninvoiced_amount
msgid "Uninvoiced Amount"
msgstr ""

#. module: sale_order_invoice_amount
#: model_terms:ir.ui.view,arch_db:sale_order_invoice_amount.view_order_tree_invoiced_amount
msgid "Uninvoiced Total"
msgstr ""
1 change: 1 addition & 0 deletions sale_order_invoice_amount/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import sale_order
72 changes: 72 additions & 0 deletions sale_order_invoice_amount/models/sale_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Copyright (C) 2021 ForgeFlow S.L.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
import json

from odoo import api, fields, models
from odoo.tools.misc import formatLang


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

invoiced_amount = fields.Monetary(
compute="_compute_invoice_amount",
store=True,
)

uninvoiced_amount = fields.Monetary(
compute="_compute_invoice_amount",
store=True,
)

@api.depends(
"state",
"invoice_ids",
"invoice_ids.amount_total_signed",
"amount_total",
"invoice_ids.state",
)
def _compute_invoice_amount(self):
for rec in self:
if rec.state != "cancel" and rec.invoice_ids:
rec.invoiced_amount = 0.0
for invoice in rec.invoice_ids:
if invoice.state != "cancel":
rec.invoiced_amount += invoice.amount_total_signed
rec.uninvoiced_amount = max(0, rec.amount_total - rec.invoiced_amount)
else:
rec.invoiced_amount = 0.0
if rec.state in ["draft", "sent", "cancel"]:
rec.uninvoiced_amount = 0.0
else:
rec.uninvoiced_amount = rec.amount_total

@api.depends(
"order_line.tax_id",
"order_line.price_unit",
"amount_total",
"amount_untaxed",
"state",
"invoice_ids",
"invoice_ids.amount_total_signed",
"amount_total",
"invoice_ids.state",
)
def _compute_tax_totals_json(self):
res = super(SaleOrder, self)._compute_tax_totals_json()
lang_env = self.with_context(lang=self.partner_id.lang).env
total_json = json.loads(self.tax_totals_json)
total_json.update(
{
"invoiced_amount": self.invoiced_amount,
"formatted_invoiced_amount": formatLang(
lang_env, self.invoiced_amount, currency_obj=self.currency_id
),
"uninvoiced_amount": self.uninvoiced_amount,
"formatted_uninvoiced_amount": formatLang(
lang_env, self.uninvoiced_amount, currency_obj=self.currency_id
),
}
)
self.tax_totals_json = json.dumps(total_json)
return res
2 changes: 2 additions & 0 deletions sale_order_invoice_amount/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* Mateu Griful <[email protected]>
* Lois Rilo <[email protected]>
4 changes: 4 additions & 0 deletions sale_order_invoice_amount/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
The purpose of this module is to add two fields in the sale order model:

* invoiced_amount: total invoiced amount.
* uninvoiced_amount: total uninvoiced amount.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 931ef79

Please sign in to comment.