[IMP] snailmail: adding special map for the country names

This commit is contained in:
Rémi Rahir
2018-09-29 11:12:38 +02:00
parent 2ff9b379ef
commit b6a981405e
6 changed files with 298 additions and 2 deletions
+1
View File
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
from . import models
from . import country_utils
+255
View File
@@ -0,0 +1,255 @@
SNAILMAIL_COUNTRIES = {
"AC": "Ascension",
"AD": "Andorra",
"AE": "United Arab Emirates",
"AF": "Afghanistan",
"AG": "Antigua and Barbuda",
"AI": "Anguilla",
"AL": "Albania",
"AM": "Armenia",
"AN": "Netherlands Antilles",
"AO": "Angola",
"AQ": "Antarctica",
"AR": "Argentina",
"AS": "American Samoa",
"AT": "Austria",
"AU": "Australia",
"AW": "Aruba",
"AX": "Aland Islands",
"AZ": "Azerbaijan",
"BA": "Bosnia and Herzegovina",
"BB": "Barbados",
"BD": "Bangladesh",
"BE": "Belgium",
"BF": "Burkina Faso",
"BG": "Bulgaria",
"BH": "Bahrain",
"BI": "Burundi",
"BJ": "Benin",
"BL": "Saint Barth\u00e9lemy",
"BM": "Bermuda",
"BN": "Brunei",
"BO": "Bolivia",
"BQ": "Bonaire Sint Eustatius and Saba",
"BR": "Brazil",
"BS": "Bahamas",
"BT": "Bhutan",
"BV": "Bouvet Island",
"BW": "Botswana",
"BY": "Belarus",
"BZ": "Belize",
"CA": "Canada",
"CC": "Cocos (Keeling) Islands",
"CD": "Congo Democratic Republic",
"CF": "Central African Republic",
"CG": "Congo Republic",
"CH": "Switzerland",
"CI": "C\u00f4te d'Ivoire",
"CK": "Cook Islands",
"CL": "Chile",
"CM": "Cameroon",
"CN": "China People's Republic",
"CO": "Colombia",
"CR": "Costa Rica",
"CU": "Cuba",
"CV": "Cape Verde",
"CW": "Cura\u00e7ao",
"CX": "Christmas Island",
"CY": "Cyprus",
"CZ": "Czech Republic",
"DE": "Germany",
"DG": "Diego Garcia",
"DJ": "Djibouti",
"DK": "Denmark",
"DM": "Dominica",
"DO": "Dominican Republic",
"DZ": "Algeria",
"EC": "Ecuador",
"EE": "Estonia",
"EG": "Egypt",
"EH": "Western Sahara",
"ER": "Eritrea",
"ES": "Spain",
"ET": "Ethiopia",
"FI": "Finland",
"FJ": "Fiji",
"FK": "Falkland Islands",
"FM": "Micronesia",
"FO": "Faroe Islands",
"FR": "France",
"GA": "Gabon",
"GB": "Great Britain",
"GD": "Grenada",
"GE": "Georgia",
"GF": "French Guiana",
"GG": "Guernsey",
"GH": "Ghana",
"GI": "Gibraltar",
"GL": "Greenland",
"GM": "Gambia",
"GN": "Guinea Republic",
"GP": "Guadeloupe",
"GQ": "Equatorial Guinea",
"GR": "Greece",
"GS": "South Georgia and Sandwich",
"GT": "Guatemala",
"GU": "Guam",
"GW": "Guinea-Bissau",
"GY": "Guyana",
"HK": "Hong Kong",
"HM": "Heard Island And Mcdonald Islands",
"HN": "Honduras",
"HR": "Croatia",
"HT": "Haiti",
"HU": "Hungary",
"ID": "Indonesia",
"IE": "Ireland",
"IL": "Israel",
"IM": "Isle of Man",
"IN": "India",
"IO": "British Indian Ocean Territory",
"IQ": "Iraq",
"IR": "Iran",
"IS": "Iceland",
"IT": "Italy",
"JE": "Jersey",
"JM": "Jamaica",
"JO": "Jordan",
"JP": "Japan",
"KE": "Kenya",
"KG": "Kyrgyzstan",
"KH": "Cambodia",
"KI": "Kiribati",
"KM": "Comoros",
"KN": "Saint Kitts and Nevis",
"KP": "Korea Dem. Peo. Rep.",
"KR": "Korea (South Korea) Republic",
"KW": "Kuwait",
"KY": "Cayman Islands",
"KZ": "Kazakstan",
"LA": "Laos People's Democratic Republic",
"LB": "Lebanon",
"LC": "Saint Lucia",
"LI": "Liechtenstein",
"LK": "Sri Lanka",
"LR": "Liberia",
"LS": "Lesotho",
"LT": "Lithuania",
"LU": "Luxembourg",
"LV": "Latvia",
"LY": "Libyan",
"MA": "Morocco",
"MC": "Monaco",
"MD": "Moldova",
"ME": "Montenegro",
"MF": "Saint Martin",
"MG": "Madagascar",
"MH": "Marshall Islands",
"MK": "Macedonia",
"ML": "Mali",
"MM": "Myanmar",
"MN": "Mongolia",
"MO": "Macao",
"MP": "Mariana Islands",
"MQ": "Martinique",
"MR": "Mauritania",
"MS": "Montserrat",
"MT": "Malta",
"MU": "Mauritius",
"MV": "Maldives",
"MW": "Malawi",
"MX": "Mexico",
"MY": "Malaysia",
"MZ": "Mozambique",
"NA": "Namibia",
"NC": "New Caledonia",
"NE": "Niger",
"NF": "Norfolk Island",
"NG": "Nigeria",
"NI": "Nicaragua",
"NL": "Netherlands",
"NO": "Norway",
"NP": "Nepal",
"NR": "Nauru",
"NU": "Niue",
"NZ": "New Zealand",
"OM": "Oman",
"PA": "Panama",
"PE": "Peru",
"PF": "French Polynesia",
"PG": "Papua New Guinea",
"PH": "Philippines",
"PK": "Pakistan",
"PL": "Poland",
"PM": "Saint Pierre and Miquelon",
"PN": "Pitcairn Island",
"PR": "Puerto Rico",
"PS": "Palestine",
"PT": "Portugal",
"PW": "Palau",
"PY": "Paraguay",
"QA": "Qatar",
"RE": "R\u00e9union",
"RO": "Romania",
"RS": "Serbia",
"RU": "Russian Federation",
"RW": "Rwanda",
"SA": "Saudi Arabia",
"SB": "Solomon Islands",
"SC": "Seychelles",
"SD": "Sudan",
"SE": "Sweden",
"SG": "Singapore",
"SH": "Ascension StHelena & Tristan",
"SI": "Slovenia",
"SJ": "Svalbard and Jan Mayen",
"SK": "Slovak Republic",
"SL": "Sierra Leone",
"SM": "San Marino",
"SN": "Senegal",
"SO": "Somalia",
"SR": "Suriname",
"SS": "South Sudan",
"ST": "Sao Tome and Principe",
"SV": "El Salvardor",
"SX": "Sint Maarten",
"SY": "Syria",
"SZ": "Swaziland",
"TA": "Tristan da Cunha",
"TC": "Turks and Caicos",
"TD": "Chad",
"TF": "French Southern Territories",
"TG": "Togo",
"TH": "Thailand",
"TJ": "Tajikistan",
"TK": "Tokelau Islands",
"TL": "Timor-Leste",
"TM": "Turkmenistan",
"TN": "Tunisia",
"TO": "Tonga",
"TR": "Turkey",
"TT": "Trinidad and Tobago",
"TV": "Tuvalu",
"TW": "China Taiwan",
"TZ": "Tanzania",
"UA": "Ukraine",
"UG": "Uganda",
"US": "United States of America",
"UY": "Uruguay",
"UZ": "Uzbekistan",
"VA": "Vatican City State",
"VC": "St. Vincent and Grenadines",
"VE": "Venezuela",
"VG": "Virgin Islands british",
"VI": "Virgin Islands",
"VN": "Viet Nam",
"VU": "Vanuatu",
"WF": "Wallis and Futuna Islands",
"WS": "Western Samoa",
"XZ": "Kosovo",
"YE": "Yemen",
"YT": "Mayotte",
"ZA": "South Africa",
"ZM": "Zambia",
"ZW": "Zimbabwe"
}
+3 -1
View File
@@ -1,6 +1,8 @@
# -*- coding: utf-8 -*-
from . import res_company
from . import res_partner
from . import res_config_settings
from . import snailmail_letter
from . import ir_actions_report
from . import ir_actions_report
from . import ir_qweb_fields
+13
View File
@@ -0,0 +1,13 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import api, models
class Contact(models.AbstractModel):
_inherit = 'ir.qweb.field.contact'
@api.model
def value_to_html(self, value, options):
snailmail_layout = options['template_options'].get('snailmail_layout')
value = value.with_context(snailmail_layout=snailmail_layout)
return super(Contact, self).value_to_html(value, options)
+21
View File
@@ -0,0 +1,21 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import api, models
from odoo.addons.snailmail.country_utils import SNAILMAIL_COUNTRIES
class ResPartner(models.Model):
_inherit = "res.partner"
@api.multi
def _get_country_name(self):
# when sending a letter, thus rendering the report with the snailmail_layout,
# we need to override the country name to its english version following the
# dictionary imported in country_utils.py
country_code = self.country_id.code
if self.env.context.get('snailmail_layout') and country_code in SNAILMAIL_COUNTRIES:
return SNAILMAIL_COUNTRIES.get(country_code)
return super(ResPartner, self)._get_country_name()
+5 -1
View File
@@ -831,7 +831,7 @@ class Partner(models.Model):
'state_code': self.state_id.code or '',
'state_name': self.state_id.name or '',
'country_code': self.country_id.code or '',
'country_name': self.country_id.name or '',
'country_name': self._get_country_name(),
'company_name': self.commercial_company_name or '',
}
for field in self._address_fields():
@@ -856,6 +856,10 @@ class Partner(models.Model):
'template': '/base/static/xls/res_partner.xls'
}]
@api.multi
def _get_country_name(self):
return self.country_id.name or ''
class ResPartnerIndustry(models.Model):
_description = 'Industry'