[IMP] pre-commit: first run on whole repo

This commit is contained in:
Kevin Khao
2021-11-26 18:54:38 +03:00
parent a04b8980e1
commit 167aefee13
289 changed files with 6020 additions and 4170 deletions

View File

@@ -2,14 +2,14 @@
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import api, models, _
from odoo import _, api, models
class ResCompany(models.Model):
_inherit = 'res.company'
_inherit = "res.company"
@api.model
def generate_line(self, fields, options, icon=True, separator=' - '):
def generate_line(self, fields, options, icon=True, separator=" - "):
assert fields
assert options
content = []
@@ -20,13 +20,13 @@ class ResCompany(models.Model):
label = field[1]
uicon = False
elif isinstance(field, str) and field in options:
value = options[field]['value']
label = options[field].get('label')
uicon = options[field].get('icon')
value = options[field]["value"]
label = options[field].get("label")
uicon = options[field].get("icon")
if value:
prefix = icon and uicon or label
if prefix:
content.append('%s %s' % (prefix, value))
content.append("%s %s" % (prefix, value))
else:
content.append(value)
line = separator.join(content)
@@ -35,46 +35,51 @@ class ResCompany(models.Model):
def _prepare_header_options(self):
self.ensure_one()
options = {
'phone': {
'value': self.phone,
"phone": {
"value": self.phone,
# http://www.fileformat.info/info/unicode/char/1f4de/index.htm
'icon': '\U0001F4DE',
'label': _('Tel:')},
'email': {
'value': self.email,
"icon": "\U0001F4DE",
"label": _("Tel:"),
},
"email": {
"value": self.email,
# http://www.fileformat.info/info/unicode/char/2709/index.htm
'icon': '\u2709',
'label': _('E-mail:')},
'website': {
'value': self.website,
'icon': '\U0001f310',
'label': _('Website:')},
'vat': {
'value': self.vat,
'label': _('VAT:')},
}
"icon": "\u2709",
"label": _("E-mail:"),
},
"website": {
"value": self.website,
"icon": "\U0001f310",
"label": _("Website:"),
},
"vat": {"value": self.vat, "label": _("VAT:")},
}
return options
def _report_company_legal_name(self):
'''Method inherited in the module base_company_extension'''
"""Method inherited in the module base_company_extension"""
self.ensure_one()
return self.name
# for reports
def _display_report_header(
self, line_details=[['phone', 'website'], ['vat']],
icon=True, line_separator=' - '):
self,
line_details=[["phone", "website"], ["vat"]],
icon=True,
line_separator=" - ",
):
self.ensure_one()
res = ''
res = ""
address = self.partner_id._display_address(without_company=True)
address = address.replace('\n', ' - ')
address = address.replace("\n", " - ")
line1 = '%s - %s' % (self._report_company_legal_name(), address)
line1 = "%s - %s" % (self._report_company_legal_name(), address)
lines = [line1]
options = self._prepare_header_options()
for details in line_details:
line = self.generate_line(
details, options, icon=icon, separator=line_separator)
details, options, icon=icon, separator=line_separator
)
lines.append(line)
res = '\n'.join(lines)
res = "\n".join(lines)
return res