Skip to content

Commit

Permalink
[ADD] egd_analytic_custom: new module
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelsavegnago committed Nov 13, 2023
1 parent e95f9bc commit 58773bd
Show file tree
Hide file tree
Showing 12 changed files with 220 additions and 0 deletions.
81 changes: 81 additions & 0 deletions egd_analytic_custom/README.rst
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.
1 change: 1 addition & 0 deletions egd_analytic_custom/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
17 changes: 17 additions & 0 deletions egd_analytic_custom/__manifest__.py
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": [],
}
1 change: 1 addition & 0 deletions egd_analytic_custom/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import account_analytic_line
61 changes: 61 additions & 0 deletions egd_analytic_custom/models/account_analytic_line.py
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

Check warning on line 30 in egd_analytic_custom/models/account_analytic_line.py

View check run for this annotation

Codecov / codecov/patch

egd_analytic_custom/models/account_analytic_line.py#L27-L30

Added lines #L27 - L30 were not covered by tests
if record.product_id:
if record.account_id:
account_analytic = record.account_id
blanket_orders = record.env["sale.blanket.order"].search(

Check warning on line 34 in egd_analytic_custom/models/account_analytic_line.py

View check run for this annotation

Codecov / codecov/patch

egd_analytic_custom/models/account_analytic_line.py#L33-L34

Added lines #L33 - L34 were not covered by tests
[("analytic_account_id", "=", account_analytic.id)]
)
if blanket_orders:
products = blanket_orders.egd_order_product_ids.search(

Check warning on line 38 in egd_analytic_custom/models/account_analytic_line.py

View check run for this annotation

Codecov / codecov/patch

egd_analytic_custom/models/account_analytic_line.py#L38

Added line #L38 was not covered by tests
[("product_id", "=", record.product_id.id)]
)
services = blanket_orders.egd_order_service_ids.search(

Check warning on line 41 in egd_analytic_custom/models/account_analytic_line.py

View check run for this annotation

Codecov / codecov/patch

egd_analytic_custom/models/account_analytic_line.py#L41

Added line #L41 was not covered by tests
[("product_id", "=", record.product_id.id)]
)
if products:
price_unit = products[0].price_unit

Check warning on line 45 in egd_analytic_custom/models/account_analytic_line.py

View check run for this annotation

Codecov / codecov/patch

egd_analytic_custom/models/account_analytic_line.py#L45

Added line #L45 was not covered by tests
elif services:
price_unit = services[0].price_unit
record.egd_target_value = price_unit

Check warning on line 48 in egd_analytic_custom/models/account_analytic_line.py

View check run for this annotation

Codecov / codecov/patch

egd_analytic_custom/models/account_analytic_line.py#L47-L48

Added lines #L47 - L48 were not covered by tests

@api.depends(
"account_id",
"egd_target_value",
"unit_amount",
"amount",
)
def _compute_egd_target_above(self):
for record in self:
target_above = False

Check warning on line 58 in egd_analytic_custom/models/account_analytic_line.py

View check run for this annotation

Codecov / codecov/patch

egd_analytic_custom/models/account_analytic_line.py#L58

Added line #L58 was not covered by tests
if (record.amount / record.unit_amount) > record.egd_target_value:
target_above = True
record.egd_target_above = target_above

Check warning on line 61 in egd_analytic_custom/models/account_analytic_line.py

View check run for this annotation

Codecov / codecov/patch

egd_analytic_custom/models/account_analytic_line.py#L60-L61

Added lines #L60 - L61 were not covered by tests
Empty file.
Empty file.
Empty file.
Binary file added egd_analytic_custom/static/description/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
52 changes: 52 additions & 0 deletions egd_analytic_custom/views/account_analytic_line.xml
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>
1 change: 1 addition & 0 deletions setup/egd_analytic_custom/odoo/addons/egd_analytic_custom
6 changes: 6 additions & 0 deletions setup/egd_analytic_custom/setup.py
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,
)

0 comments on commit 58773bd

Please sign in to comment.