2020-01-17 17:22:56 +05:00
|
|
|
import inspect
|
2020-01-16 20:08:52 +05:00
|
|
|
import datetime as dt
|
|
|
|
|
2020-01-17 17:22:56 +05:00
|
|
|
from odoo import fields
|
2020-01-16 20:08:52 +05:00
|
|
|
from odoo.tools.misc import DEFAULT_SERVER_DATE_FORMAT, DEFAULT_SERVER_DATETIME_FORMAT
|
|
|
|
|
|
|
|
|
2020-01-17 17:22:56 +05:00
|
|
|
class IDocument(object):
|
|
|
|
"""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):
|
|
|
|
raise NotImplementedError('Method {} is not implemented'.format(inspect.currentframe().f_code.co_name))
|
|
|
|
|
|
|
|
def get_filename_by_document_template(self, document_template_id: fields.Many2one):
|
|
|
|
raise NotImplementedError('Method {} is not implemented'.format(inspect.currentframe().f_code.co_name))
|
|
|
|
|
|
|
|
|
2020-01-16 20:08:52 +05:00
|
|
|
class Extension(object):
|
|
|
|
|
|
|
|
def parse_odoo_date(self, date: str):
|
|
|
|
return dt.datetime.strptime(date, DEFAULT_SERVER_DATE_FORMAT)
|
|
|
|
|
|
|
|
def parse_odoo_datetime(self, datetime: str):
|
|
|
|
return dt.datetime.strptime(datetime, DEFAULT_SERVER_DATETIME_FORMAT)
|