-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD] egd_analytic_custom: new module
- Loading branch information
1 parent
e95f9bc
commit 58773bd
Showing
12 changed files
with
220 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
================== | ||
Egd Analytic Custom | ||
================== | ||
.. |badge1| image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg | ||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html | ||
:alt: License: AGPL-3 | ||
|
||
|badge1| | ||
|
||
EGD Analytic Custom | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Configuration | ||
============= | ||
|
||
To Configure... | ||
|
||
Usage | ||
===== | ||
|
||
To usage... | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues | ||
<https://github.com/Escodoo/{project_repo}/issues>`_. In case of trouble, please | ||
check there if your issue has already been reported. If you spotted it first, | ||
help us smash it by providing detailed and welcomed feedback. | ||
|
||
Do not contact contributors directly about support or help with technical issues. | ||
|
||
Credits | ||
======= | ||
|
||
Authors | ||
~~~~~~~ | ||
|
||
* Escodoo | ||
|
||
Contributors | ||
~~~~~~~~~~~~ | ||
|
||
* Marcel Savegnago <[email protected]> | ||
|
||
Other credits | ||
~~~~~~~~~~~~~ | ||
|
||
The development of this module has been financially supported by: | ||
|
||
* Escodoo - `https://www.escodoo.com.br <https://www.escodoo.com.br>`_ | ||
|
||
Maintainers | ||
~~~~~~~~~~~ | ||
|
||
This module is maintained by the Escodoo. | ||
|
||
.. |maintainer-escodoo| image:: https://github.com/escodoo.png?size=80px | ||
:target: https://github.com/Escodoo | ||
:alt: escodoo | ||
|
||
|maintainer-escodoo| | ||
|
||
We at Escodoo are exclusively dedicated to deploying the Odoo Platform and are | ||
focused on providing solutions that make our customers more competitive, lowering | ||
costs, making technology more accessible and ensuring it is used strategically to | ||
add even more value to the business. | ||
|
||
.. |maintainer-marcelsavegnago| image:: https://github.com/marcelsavegnago.png?size=40px | ||
:target: https://github.com/marcelsavegnago | ||
:alt: marcelsavegnago | ||
|
||
Current `maintainer <https://odoo-community.org/page/maintainer-role>`__: | ||
|
||
|maintainer-marcelsavegnago| | ||
|
||
To contribute to this module, please visit https://www.escodoo.com.br. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Copyright 2023 - TODAY, Escodoo | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
{ | ||
"name": "Egd Analytic Custom", | ||
"summary": """ | ||
EGD Analytic Custom""", | ||
"version": "14.0.1.0.0", | ||
"license": "AGPL-3", | ||
"author": "Escodoo", | ||
"website": "https://github.com/Escodoo/egd-addons", | ||
"depends": ["egd_sale_blanket_order_custom"], | ||
"data": [ | ||
"views/account_analytic_line.xml", | ||
], | ||
"demo": [], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import account_analytic_line |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# Copyright 2023 - TODAY, Marcel Savegnago <[email protected]> | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import api, fields, models | ||
|
||
|
||
class AccountAnalyticLine(models.Model): | ||
|
||
_inherit = "account.analytic.line" | ||
|
||
egd_target_value = fields.Float( | ||
string="Target Price Unit", compute="_compute_egd_target_value" | ||
) | ||
|
||
egd_target_above = fields.Boolean( | ||
string="Target Above", | ||
compute="_compute_egd_target_above", | ||
) | ||
|
||
@api.depends( | ||
"account_id", | ||
"unit_amount", | ||
"amount", | ||
) | ||
def _compute_egd_target_value(self): | ||
for record in self: | ||
products = False | ||
services = False | ||
price_unit = 0 | ||
account_analytic = False | ||
if record.product_id: | ||
if record.account_id: | ||
account_analytic = record.account_id | ||
blanket_orders = record.env["sale.blanket.order"].search( | ||
[("analytic_account_id", "=", account_analytic.id)] | ||
) | ||
if blanket_orders: | ||
products = blanket_orders.egd_order_product_ids.search( | ||
[("product_id", "=", record.product_id.id)] | ||
) | ||
services = blanket_orders.egd_order_service_ids.search( | ||
[("product_id", "=", record.product_id.id)] | ||
) | ||
if products: | ||
price_unit = products[0].price_unit | ||
elif services: | ||
price_unit = services[0].price_unit | ||
record.egd_target_value = price_unit | ||
|
||
@api.depends( | ||
"account_id", | ||
"egd_target_value", | ||
"unit_amount", | ||
"amount", | ||
) | ||
def _compute_egd_target_above(self): | ||
for record in self: | ||
target_above = False | ||
if (record.amount / record.unit_amount) > record.egd_target_value: | ||
target_above = True | ||
record.egd_target_above = target_above | ||
Empty file.
Empty file.
Empty file.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<!-- Copyright 2023 - TODAY, Marcel Savegnago <[email protected]> | ||
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). --> | ||
<odoo> | ||
|
||
<record model="ir.ui.view" id="account_analytic_line_form_view"> | ||
<field name="name">account.analytic.line.form (in egd_account_custom)</field> | ||
<field name="model">account.analytic.line</field> | ||
<field name="inherit_id" ref="analytic.view_account_analytic_line_form" /> | ||
<field name="arch" type="xml"> | ||
<field name="amount" position="before"> | ||
<field name="egd_target_above" invisible="1" /> | ||
<field | ||
name="egd_target_value" | ||
optional="show" | ||
widget="badge" | ||
decoration-success="egd_target_above == False" | ||
decoration-danger="egd_target_above == True" | ||
/> | ||
</field> | ||
</field> | ||
</record> | ||
<!-- | ||
<record model="ir.ui.view" id="account_analytic_line_search_view"> | ||
<field name="name">account.analytic.line.search (in egd_account_custom)</field> | ||
<field name="model">account.analytic.line</field> | ||
<field name="inherit_id" ref="TODO othermodule.search_view"/> | ||
<field name="arch" type="xml"> | ||
</field> | ||
</record> | ||
--> | ||
<record model="ir.ui.view" id="account_analytic_line_tree_view"> | ||
<field name="name">account.analytic.line.tree (in egd_account_custom)</field> | ||
<field name="model">account.analytic.line</field> | ||
<field name="inherit_id" ref="analytic.view_account_analytic_line_tree" /> | ||
<field name="arch" type="xml"> | ||
<field name="amount" position="before"> | ||
<field name="egd_target_above" invisible="1" /> | ||
<field | ||
name="egd_target_value" | ||
optional="show" | ||
widget="badge" | ||
decoration-success="egd_target_above == False" | ||
decoration-danger="egd_target_above == True" | ||
/> | ||
<field name="egd_target_above" optional="hide" /> | ||
</field> | ||
</field> | ||
</record> | ||
|
||
</odoo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../../egd_analytic_custom |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import setuptools | ||
|
||
setuptools.setup( | ||
setup_requires=['setuptools-odoo'], | ||
odoo_addon=True, | ||
) |