merge conflict solved

This commit is contained in:
Alexandr 2021-07-26 13:41:35 +05:00
commit 2b1d550f11
3 changed files with 15 additions and 61 deletions

View File

@ -1,10 +1,18 @@
# DOCS report # DOCS report
Adds docx reports printing from docx templates like standard Odoo reports
with qweb templates. Standard Odoo reports also available.
For generating pdf from docx external service the "gotenberg" is used. Позволяет добавлять в модель отчётов в качестве шаблона-источника файлы формата docx.
It should work at the same server as Odoo app. If "gotenberg" absent, there Получить отчёты на основе такого шаблона можно в формате docx или pdf.
will be only reports in docx format. Для преобразования docx -> pdf требуется доступный сервис gotenberg на localhost:8808.
Пример запуска сервиса в docker-compose рядом с Odoo:
To get and start "gotenberg" container use command: ```yaml
docker run -h docx_to_pdf -e DEFAULT_LISTEN_PORT=8808 thecodingmachine/gotenberg gotenberg:
image: thecodingmachine/gotenberg:6
restart: unless-stopped
environment:
LOG_LEVEL: INFO
DEFAULT_LISTEN_PORT: 8808
DISABLE_GOOGLE_CHROME: 1
DEFAULT_WAIT_TIMEOUT: 30
MAXIMUM_WAIT_TIMEOUT: 60
```

View File

@ -1 +0,0 @@
MODULE_NAME = __package__.split(".")[-2]

View File

@ -1,53 +0,0 @@
from decimal import Decimal
from num2words import num2words
from num2words import CONVERTES_TYPES
# Can use params:
# ~ number: int, float or validate string
# ~ to: num2words.CONVERTER_TYPES
# ~ lang: num2words.CONVERTER_CLASSES
# ~ currency: num2words.CONVERTER_CLASSES.CURRENCY_FORMS
# Jinja2 Global Method
def num2words_(number, **kwargs):
if _perform_convert(number):
if "lang" not in kwargs:
kwargs["lang"] = "ru"
if "to" not in kwargs or kwargs["to"] not in CONVERTES_TYPES:
kwargs["to"] = "cardinal"
return num2words(number, **kwargs)
# Jinja2 Global Method
def num2words_currency(number, **kwargs):
if _perform_convert(number):
if "lang" not in kwargs:
kwargs["lang"] = "ru"
if "to" not in kwargs or kwargs["to"] not in CONVERTES_TYPES:
kwargs["to"] = "currency"
if "currency" not in kwargs:
kwargs["currency"] = "RUB"
result = num2words(number, **kwargs)
total = result.split(",")[0]
part_word = result.split()[-1]
part_number = Decimal(str(number)) % 1
return "{total}, {part_n} {part_w}".format(
total=total.capitalize(),
part_n="{:02d}".format(int(part_number * 100)),
part_w=part_word,
)
def _perform_convert(number):
if isinstance(number, int) or isinstance(number, float):
return True
if isinstance(number, str):
try:
number = float(number)
return True
except ValueError:
return False
return False