Skip to content

Commit

Permalink
Merge PR #90 into 12.0
Browse files Browse the repository at this point in the history
Signed-off-by legalsylvain
  • Loading branch information
github-grap-bot committed Jan 30, 2024
2 parents d871b03 + d93ab9f commit 95f9537
Show file tree
Hide file tree
Showing 6 changed files with 2 additions and 73 deletions.
5 changes: 1 addition & 4 deletions joint_buying_base/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,10 @@
"res_company_active",
"web_notify",
"web_view_leaflet_map_partner",
"web_widget_bokeh_chart",
# GRAP
"name_search_reset_res_partner",
],
"external_dependencies": {
"python": ["openupgradelib", "geopy", "bokeh", "pandas", "treelib"]
},
"external_dependencies": {"python": ["openupgradelib", "geopy", "treelib"]},
"data": [
"security/ir_module_category.xml",
"security/res_groups.xml",
Expand Down
50 changes: 0 additions & 50 deletions joint_buying_base/models/joint_buying_tour.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,7 @@
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from datetime import timedelta
from math import pi

import pandas as pd
from bokeh.embed import components
from bokeh.palettes import Category20c
from bokeh.plotting import figure
from bokeh.transform import cumsum
from dateutil.relativedelta import relativedelta

from odoo import _, api, fields, models
Expand Down Expand Up @@ -97,8 +91,6 @@ class JointBuyingTour(models.Model):
comodel_name="res.currency", related="carrier_id.currency_id"
)

cost_chart = fields.Text(compute="_compute_cost_chart")

transport_request_qty = fields.Integer(compute="_compute_transport_request_qty")

is_on_my_way = fields.Boolean(
Expand Down Expand Up @@ -154,48 +146,6 @@ def _compute_vehicle_cost(self):
for tour in self:
tour.vehicle_cost = sum(tour.mapped("line_ids.vehicle_cost"))

@api.depends("vehicle_cost", "salary_cost", "toll_cost")
def _compute_cost_chart(self):
for rec in self:
x = {
_("Salary"): rec.salary_cost,
_("Vehicle"): rec.vehicle_cost,
_("Toll"): rec.toll_cost,
}
data = (
pd.Series(x)
.reset_index(name="value")
.rename(columns={"index": "cost_type"})
)
data["angle"] = data["value"] / data["value"].sum() * 2 * pi
data["color"] = Category20c[len(x)]

p = figure(
height=300,
width=300,
toolbar_location=None,
tools="hover",
tooltips="@cost_type: @value",
)

p.wedge(
x=0,
y=1,
radius=0.4,
start_angle=cumsum("angle", include_zero=True),
end_angle=cumsum("angle"),
line_color="white",
fill_color="color",
source=data,
)

p.axis.axis_label = None
p.axis.visible = False
p.grid.grid_line_color = None

script, div = components(p)
rec.cost_chart = f"{div}{script}"

@api.depends("line_ids")
def _compute_stop_qty(self):
for tour in self:
Expand Down
5 changes: 0 additions & 5 deletions joint_buying_base/tests/test_tour.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,3 @@ def test_103_check_description(self):
self.assertIn("Journey", self.tour_lyon_savoie.description)
self.assertIn("Truck loading", self.tour_lyon_savoie.description)
self.assertIn("Truck unloading", self.tour_lyon_savoie.description)

def test_104_check_cost_chart(self):
self.assertIn("Salary", self.tour_lyon_savoie.cost_chart)
self.assertIn("Vehicle", self.tour_lyon_savoie.cost_chart)
self.assertIn("Toll", self.tour_lyon_savoie.cost_chart)
5 changes: 0 additions & 5 deletions joint_buying_base/views/view_joint_buying_tour.xml
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,6 @@ There may be traffic jams, delays, unforeseen events, etc...
<field name="salary_cost"/>
<field name="vehicle_cost"/>
</group>
<group colspan="2">
<div>
<field name="cost_chart" widget="bokeh_chart" nolabel="1"/>
</div>
</group>
</group>
</page>
</notebook>
Expand Down
2 changes: 0 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# generated from manifests external_dependencies
bokeh==1.1.0
geopy
openupgradelib
pandas
treelib
8 changes: 1 addition & 7 deletions setup/joint_buying_base/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,5 @@

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon={
'external_dependencies_override': {
'python': {
'bokeh': 'bokeh==1.1.0',
}
}
},
odoo_addon=True,
)

0 comments on commit 95f9537

Please sign in to comment.