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

[MIG][18.0] Migration of sale_financial_risk_info from 16.0 #412

Open
wants to merge 19 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
19 commits
Select commit Hold shift + click to select a range
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
100 changes: 100 additions & 0 deletions sale_financial_risk_info/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
========================
Sale Financial Risk Info
========================

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

.. |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-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%2Fcredit--control-lightgray.png?logo=github
:target: https://github.com/OCA/credit-control/tree/18.0/sale_financial_risk_info
:alt: OCA/credit-control
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/credit-control-18-0/credit-control-18-0-sale_financial_risk_info
: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/credit-control&target_branch=18.0
:alt: Try me on Runboat

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

Extends account financial risk to add consumption info in sales orders.

**Table of contents**

.. contents::
:local:

Configuration
=============

ir.configparameter options
--------------------------

#. You can define the configparameter
"salefinancial_risk_info.info_pattern" to customize displayed info. Ex.
"<h5{textclass}>{risktotal} / {creditlimit} ({riskpercent}%)</h5>" In
addition to the example parameters there is the parameter
"riskavailable".

Usage
=====

To use this module, you need to:

1. Go to *Customers > Financial Risk*
2. Set limits and choose options to compute in credit limit.
3. Go to *Sales -> Orders -> Orders* and create a new Sales Orders.

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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/credit-control/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/credit-control/issues/new?body=module:%20sale_financial_risk_info%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>`__:

- Carlos Dauden
- Ernesto Tejeda

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/credit-control <https://github.com/OCA/credit-control/tree/18.0/sale_financial_risk_info>`_ 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_financial_risk_info/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
15 changes: 15 additions & 0 deletions sale_financial_risk_info/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2021 Tecnativa - Carlos Dauden
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
"name": "Sale Financial Risk Info",
"summary": "Adds risk consumption info in sales orders.",
"version": "18.0.1.0.1",
"category": "Sales Management",
"license": "AGPL-3",
"author": "Tecnativa, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/credit-control",
"depends": ["sale", "account_financial_risk"],
"data": ["views/res_partner_view.xml", "views/sale_order_view.xml"],
"installable": True,
}
60 changes: 60 additions & 0 deletions sale_financial_risk_info/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * sale_financial_risk_info
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-02-11 02:39+0000\n"
"PO-Revision-Date: 2023-07-13 10:10+0000\n"
"Last-Translator: Ivorra78 <[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.17\n"

#. module: sale_financial_risk_info
#: model:ir.model,name:sale_financial_risk_info.model_res_partner
msgid "Contact"
msgstr "Contacto"

#. module: sale_financial_risk_info
#: model:ir.model.fields,field_description:sale_financial_risk_info.field_sale_order__risk_info
msgid "Risk Info"
msgstr "Riesgo consumido"

#. module: sale_financial_risk_info
#: model:ir.model.fields,field_description:sale_financial_risk_info.field_sale_order__risk_remaining_percentage
msgid "Risk Remaining (Percentage)"
msgstr "Riesgo restante (porcentaje)"

#. module: sale_financial_risk_info
#: model:ir.model.fields,field_description:sale_financial_risk_info.field_sale_order__risk_remaining_value
msgid "Risk Remaining (Value)"
msgstr "Riesgo restante (valor)"

#. module: sale_financial_risk_info
#: model:ir.model.fields,field_description:sale_financial_risk_info.field_res_partner__risk_percent_warning
#: model:ir.model.fields,field_description:sale_financial_risk_info.field_res_users__risk_percent_warning
msgid "Risk percent warning"
msgstr "Porcentaje riesgo alerta"

#. module: sale_financial_risk_info
#: model:ir.model,name:sale_financial_risk_info.model_sale_order
msgid "Sales Order"
msgstr "Pedido de venta"

#. module: sale_financial_risk_info
#. odoo-python
#: code:addons/sale_financial_risk_info/models/sale.py:0
#, python-format
msgid "Unlimited"
msgstr "Sin límite"

#, python-format
#~ msgid "<h5%s>%s%s of %s%s (%s%%)</h5>"
#~ msgstr "<h5%s>%s%s de %s%s (%s%%)</h5>"
64 changes: 64 additions & 0 deletions sale_financial_risk_info/i18n/it.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * sale_financial_risk_info
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2022-10-27 18:43+0000\n"
"Last-Translator: Francesco Foresti <[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.14.1\n"

#. module: sale_financial_risk_info
#: model:ir.model,name:sale_financial_risk_info.model_res_partner
msgid "Contact"
msgstr "Contatto"

#. module: sale_financial_risk_info
#: model:ir.model.fields,field_description:sale_financial_risk_info.field_sale_order__risk_info
msgid "Risk Info"
msgstr "Informazioni sul rischio"

#. module: sale_financial_risk_info
#: model:ir.model.fields,field_description:sale_financial_risk_info.field_sale_order__risk_remaining_percentage
msgid "Risk Remaining (Percentage)"
msgstr "Rischio rimanente (%)"

#. module: sale_financial_risk_info
#: model:ir.model.fields,field_description:sale_financial_risk_info.field_sale_order__risk_remaining_value
msgid "Risk Remaining (Value)"
msgstr "Rischio rimanente (valore)"

#. module: sale_financial_risk_info
#: model:ir.model.fields,field_description:sale_financial_risk_info.field_res_partner__risk_percent_warning
#: model:ir.model.fields,field_description:sale_financial_risk_info.field_res_users__risk_percent_warning
msgid "Risk percent warning"
msgstr "Avviso percentuale di rischio"

#. module: sale_financial_risk_info
#: model:ir.model,name:sale_financial_risk_info.model_sale_order
msgid "Sales Order"
msgstr "Ordine di vendita"

#. module: sale_financial_risk_info
#. odoo-python
#: code:addons/sale_financial_risk_info/models/sale.py:0
#, python-format
msgid "Unlimited"
msgstr "Illimitato"

#~ msgid "Display Name"
#~ msgstr "Nome da visualizzare"

#~ msgid "ID"
#~ msgstr "ID"

#~ msgid "Last Modified on"
#~ msgstr "Ultima modifica il"
52 changes: 52 additions & 0 deletions sale_financial_risk_info/i18n/sale_financial_risk_info.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * sale_financial_risk_info
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.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_financial_risk_info
#: model:ir.model,name:sale_financial_risk_info.model_res_partner
msgid "Contact"
msgstr ""

#. module: sale_financial_risk_info
#: model:ir.model.fields,field_description:sale_financial_risk_info.field_sale_order__risk_info
msgid "Risk Info"
msgstr ""

#. module: sale_financial_risk_info
#: model:ir.model.fields,field_description:sale_financial_risk_info.field_sale_order__risk_remaining_percentage
msgid "Risk Remaining (Percentage)"
msgstr ""

#. module: sale_financial_risk_info
#: model:ir.model.fields,field_description:sale_financial_risk_info.field_sale_order__risk_remaining_value
msgid "Risk Remaining (Value)"
msgstr ""

#. module: sale_financial_risk_info
#: model:ir.model.fields,field_description:sale_financial_risk_info.field_res_partner__risk_percent_warning
#: model:ir.model.fields,field_description:sale_financial_risk_info.field_res_users__risk_percent_warning
msgid "Risk percent warning"
msgstr ""

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

#. module: sale_financial_risk_info
#. odoo-python
#: code:addons/sale_financial_risk_info/models/sale.py:0
#, python-format
msgid "Unlimited"
msgstr ""
2 changes: 2 additions & 0 deletions sale_financial_risk_info/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import res_partner
from . import sale
10 changes: 10 additions & 0 deletions sale_financial_risk_info/models/res_partner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Copyright 2021 Tecnativa - Carlos Dauden
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import fields, models


class ResPartner(models.Model):
_inherit = "res.partner"

risk_percent_warning = fields.Integer(string="Risk percent warning", default=80)
49 changes: 49 additions & 0 deletions sale_financial_risk_info/models/sale.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Copyright 2021 Tecnativa - Carlos Dauden
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import _, api, fields, models
from odoo.tools.misc import format_amount


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

risk_info = fields.Html(compute="_compute_risk_info")
risk_remaining_value = fields.Monetary(related="partner_id.risk_remaining_value")
risk_remaining_percentage = fields.Float(
related="partner_id.risk_remaining_percentage"
)

@api.depends("partner_invoice_id")
def _compute_risk_info(self):
ICP = self.env["ir.config_parameter"].sudo()
info_pattern = ICP.get_param(
"sale_financial_risk_info.info_pattern",
default="<h5{text_class}>{risk_total} / {credit_limit} ("
"{risk_percent}%)</h5>",
)
for sale in self:
partner = sale.partner_invoice_id.commercial_partner_id
if not partner.credit_limit:
sale.risk_info = _("Unlimited")
continue
risk_percent = round(partner.risk_total / partner.credit_limit * 100)
if risk_percent >= partner.risk_percent_warning:
text_class = ' class="text-danger"'
else:
text_class = ""
sale.risk_info = info_pattern.format(
text_class=text_class,
risk_total=format_amount(
self.env, partner.risk_total, partner.risk_currency_id
),
credit_limit=format_amount(
self.env, partner.credit_limit, partner.risk_currency_id
),
risk_percent=risk_percent,
risk_available=format_amount(
self.env,
partner.credit_limit - partner.risk_total,
partner.risk_currency_id,
),
)
3 changes: 3 additions & 0 deletions sale_financial_risk_info/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
7 changes: 7 additions & 0 deletions sale_financial_risk_info/readme/CONFIGURE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## ir.configparameter options

#\. You can define the configparameter
"salefinancial_risk_info.info_pattern" to customize displayed info. Ex.
"\<h5{textclass}\>{risktotal} / {creditlimit} ({riskpercent}%)\</h5\>"
In addition to the example parameters there is the parameter
"riskavailable".
3 changes: 3 additions & 0 deletions sale_financial_risk_info/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- [Tecnativa](https://www.tecnativa.com):
- Carlos Dauden
- Ernesto Tejeda
1 change: 1 addition & 0 deletions sale_financial_risk_info/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Extends account financial risk to add consumption info in sales orders.
5 changes: 5 additions & 0 deletions sale_financial_risk_info/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
To use this module, you need to:

1. Go to *Customers \> Financial Risk*
2. Set limits and choose options to compute in credit limit.
3. Go to *Sales -\> Orders -\> Orders* and create a new Sales Orders.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading