MT#5879 Make email invoices query simplier.

Remove redundant link through contract_balances to contracts.
Process customer email template and add month and year into invoice data.
MT#5879 Default content on template creation and x- mimetype.

Store default template content on template creation.
Replace image/x-mimetype with image/mimetype to fix PDF generation.
MT#7867 Api changes for invoice template per customer. For review.
MT#7867 InvoiceTemplate API draft.
MT#5879 Fix multi-undo functionality.

Call setCurrentLayer => draw.setCurrentLayer only on initialization stages.
MT#5879 Make possible to restart generate_invoices.
MT#5879 Deny to create  invoice templates with duplicated names
MT#5879 Merge with Andreas version of Invoice Template APIs.