2020-01-16 20:08:52 +05:00
|
|
|
import datetime as dt
|
2021-04-30 16:09:43 +05:00
|
|
|
|
2021-04-30 16:09:18 +05:00
|
|
|
# import inspect
|
2020-01-16 20:08:52 +05:00
|
|
|
|
2021-04-30 16:09:43 +05:00
|
|
|
from odoo import models # , fields
|
2020-02-26 17:31:04 +05:00
|
|
|
from odoo.tools.misc import DEFAULT_SERVER_DATE_FORMAT, DEFAULT_SERVER_DATETIME_FORMAT
|
2020-01-16 20:08:52 +05:00
|
|
|
|
|
|
|
|
2021-04-30 16:09:18 +05:00
|
|
|
'''class IDocument(object):
|
2020-01-17 17:22:56 +05:00
|
|
|
"""Class must be used as an interface for create new document based model"""
|
|
|
|
|
|
|
|
def get_name_by_document_template(self, document_template_id: fields.Many2one):
|
2020-01-20 18:48:12 +05:00
|
|
|
raise NotImplementedError(
|
|
|
|
"Method {} is not implemented".format(inspect.currentframe().f_code.co_name)
|
|
|
|
)
|
2020-01-17 17:22:56 +05:00
|
|
|
|
|
|
|
def get_filename_by_document_template(self, document_template_id: fields.Many2one):
|
2020-01-20 18:48:12 +05:00
|
|
|
raise NotImplementedError(
|
|
|
|
"Method {} is not implemented".format(inspect.currentframe().f_code.co_name)
|
2021-04-30 16:09:18 +05:00
|
|
|
)'''
|
|
|
|
|
2020-01-17 17:22:56 +05:00
|
|
|
|
2021-04-30 16:09:18 +05:00
|
|
|
class Utils(models.AbstractModel):
|
|
|
|
_name = "client_contracts.utils"
|
2020-01-17 17:22:56 +05:00
|
|
|
|
2021-05-03 23:17:54 +05:00
|
|
|
'''@staticmethod
|
2021-04-30 16:09:18 +05:00
|
|
|
def parse_odoo_date(date: str):
|
2020-01-16 20:08:52 +05:00
|
|
|
return dt.datetime.strptime(date, DEFAULT_SERVER_DATE_FORMAT)
|
|
|
|
|
2021-04-30 16:09:18 +05:00
|
|
|
@staticmethod
|
|
|
|
def parse_odoo_datetime(datetime: str):
|
2021-05-03 23:17:54 +05:00
|
|
|
return dt.datetime.strptime(datetime, DEFAULT_SERVER_DATETIME_FORMAT)'''
|
2020-01-29 13:57:03 +05:00
|
|
|
|
2021-04-30 16:09:18 +05:00
|
|
|
@staticmethod
|
|
|
|
def to_fixed(number, digit=2):
|
2020-01-29 13:57:03 +05:00
|
|
|
if isinstance(number, str) and number.isdigit():
|
|
|
|
number = float(number)
|
|
|
|
return format(number, ".{digit}f".format(digit=digit))
|