Optional disable fill time column

This commit is contained in:
Кокос Артем Николаевич
2026-01-22 12:38:06 +07:00
parent e7efda232c
commit ead6c72d16
2 changed files with 20 additions and 4 deletions

View File

@@ -43,6 +43,11 @@ def main(argv: Optional[List[str]] = None) -> int:
default="", default="",
help="Override author name from .env (REDMINE_AUTHOR)" help="Override author name from .env (REDMINE_AUTHOR)"
) )
parser.add_argument(
"--no-time",
action="store_true",
help="Do not include 'Затрачено за отчетный период' column in ODT report"
)
args = parser.parse_args(argv) args = parser.parse_args(argv)
try: try:
@@ -74,8 +79,14 @@ def main(argv: Optional[List[str]] = None) -> int:
print("❌ Output file must end with .odt", file=sys.stderr) print("❌ Output file must end with .odt", file=sys.stderr)
return 1 return 1
try: try:
author = Config.get_author(args.author) doc = format_odt(
doc = format_odt(issue_hours, author=author, from_date=from_date, to_date=to_date) issue_hours,
author=Config.get_author(args.author),
from_date=from_date,
to_date=to_date,
fill_time=not args.no_time
)
doc.save(args.output) doc.save(args.output)
print(f"✅ Report saved to {args.output}") print(f"✅ Report saved to {args.output}")
except ImportError: except ImportError:

View File

@@ -14,7 +14,8 @@ def format_odt(
issue_hours: List[Tuple[Issue, float]], issue_hours: List[Tuple[Issue, float]],
author: str = "", author: str = "",
from_date: str = "", from_date: str = "",
to_date: str = "" to_date: str = "",
fill_time: bool = True
) -> "OpenDocument": ) -> "OpenDocument":
template_path = "template.odt" template_path = "template.odt"
if not os.path.exists(template_path): if not os.path.exists(template_path):
@@ -132,7 +133,11 @@ def format_odt(
row.addElement(status_cell) row.addElement(status_cell)
time_cell = TableCell(stylename=cell_style_name) time_cell = TableCell(stylename=cell_style_name)
p = P(stylename=para_style_name, text=hours_to_human(hours)) if fill_time:
time_text = hours_to_human(hours)
else:
time_text = ""
p = P(stylename=para_style_name, text=time_text)
time_cell.addElement(p) time_cell.addElement(p)
row.addElement(time_cell) row.addElement(time_cell)