Skip to content

Commit

Permalink
optional report
Browse files Browse the repository at this point in the history
  • Loading branch information
gdraheim committed Jul 30, 2024
1 parent 68bffda commit 8f8385a
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions odoo2data.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
__copyright__ = "(C) 2021-2024 Guido Draheim, licensed under the Apache License 2.0"""
__version__ = "1.1.3313"

from typing import Optional, Union, Dict, List, Tuple, cast, Iterable, Iterator
from typing import Optional, Union, Dict, List, Tuple, cast, Iterable, Iterator, NamedTuple

import logging
import re
Expand Down Expand Up @@ -614,12 +614,15 @@ def _json2odoo(data: JSONList) -> Iterator[JSONDict]:
info["entry_size"] = item["Quantity"]
yield info

def run(arg: str) -> None:
class Report(NamedTuple):
data: JSONList
summary: List[str]
def report(arg: str) -> Optional[Report]:
global DAYS, OUTPUT, LABELS
if is_dayrange(arg): # "week", "month", "last", "latest"
DAYS = dayrange(arg)
logg.log(DONE, "%s -> %s", arg, DAYS)
return
return None
if arg in ["help"]:
report_name = None
for line in open(__file__):
Expand All @@ -632,14 +635,11 @@ def run(arg: str) -> None:
if report_name:
print(f"{report_name} {report_func}")
report_name = None
return
return None
###########################################################
data: Optional[JSONList] = None
summary = []
results: JSONList = []
headers = ["am", "Date", "date", "at date", "day", "at proj", "Project", "at topic", "Topic",
"at task", "Task", 'task_name:"{:}"', "m", "User",
"Quantity", "odoo:4.2f", "satz:4.2f", "summe:{:$}", "Description"]
if ONLYZEIT:
import zeit2json
data = json2odoo(zeit2json.read_zeit(DAYS.after, DAYS.before))
Expand Down Expand Up @@ -723,7 +723,18 @@ def run(arg: str) -> None:
logg.error("unknown report '%s'", arg)
import sys
logg.error(" hint: check available reports: %s help", sys.argv[0])
if results:
return None
return Report(results, summary)

HEADERS = ["am", "Date", "date", "at date", "day", "at proj", "Project", "at topic", "Topic",
"at task", "Task", 'task_name:"{:}"', "m", "User",
"Quantity", "odoo:4.2f", "satz:4.2f", "summe:{:$}", "Description"]

def run(arg: str) -> None:
reportresults = report(arg)
if reportresults:
results, summary = reportresults
headers = HEADERS
if SHORTNAME:
for item in results:
if "at proj" in item:
Expand Down

0 comments on commit 8f8385a

Please sign in to comment.