Legal name in report header

This commit is contained in:
Alexis de Lattre
2017-02-01 12:08:38 +01:00
parent ea20effa7e
commit e353cdcad1
3 changed files with 17 additions and 2 deletions

View File

@@ -21,7 +21,8 @@ This module adds 2 fields on the Company :
""", """,
'author': 'Akretion', 'author': 'Akretion',
'website': 'http://www.akretion.com', 'website': 'http://www.akretion.com',
'depends': ['base'], # I depend on base_usability only for _report_company_legal_name()
'depends': ['base_usability'],
'data': ['company_view.xml'], 'data': ['company_view.xml'],
'installable': True, 'installable': True,
} }

View File

@@ -14,6 +14,14 @@ class ResCompany(models.Model):
legal_type = fields.Char( legal_type = fields.Char(
string="Legal Type", help="Type of Company, e.g. SARL, SAS, ...") string="Legal Type", help="Type of Company, e.g. SARL, SAS, ...")
def _report_company_legal_name(self):
self.ensure_one()
if self.legal_type:
name = u'%s %s' % (self.name, self.legal_type)
else:
name = self.name
return name
_sql_constraints = [( _sql_constraints = [(
'capital_amount_positive', 'capital_amount_positive',
'CHECK (capital_amount >= 0)', 'CHECK (capital_amount >= 0)',

View File

@@ -61,6 +61,11 @@ class ResCompany(models.Model):
} }
return options return options
def _report_company_legal_name(self):
'''Method inherited in the module base_company_extension'''
self.ensure_one()
return self.name
# for reports # for reports
@api.multi @api.multi
def _display_report_header( def _display_report_header(
@@ -70,7 +75,8 @@ class ResCompany(models.Model):
res = u'' res = u''
address = self.partner_id._display_address(without_company=True) address = self.partner_id._display_address(without_company=True)
address = address.replace('\n', u' - ') address = address.replace('\n', u' - ')
line1 = u'%s - %s' % (self.name, address)
line1 = u'%s - %s' % (self._report_company_legal_name(), address)
lines = [line1] lines = [line1]
options = self._prepare_header_options() options = self._prepare_header_options()
for details in line_details: for details in line_details: