Beispiel #1
0
 def _compute_completion_month(self):
     """ Completion month in full text. """
     for child in self.filtered('completion_date'):
         lang = child.sponsor_id.lang or self.env.lang or 'en_US'
         completion = fields.Date.from_string(child.completion_date)
         with setlocale(lang):
             child.completion_month = completion.strftime("%B")
 def _compute_completion_month(self):
     """ Completion month in full text. """
     for child in self.filtered('completion_date'):
         lang = child.sponsor_id.lang or self.env.lang or 'en_US'
         completion = fields.Date.from_string(child.completion_date)
         with setlocale(lang):
             child.completion_month = completion.strftime("%B")
    def _prepare_bank_payment_line(self, paylines):
        """
        Change communication of payment lines.
        :param paylines: account.payment.line recordset
        :return: dict for bank.payment.line creation
        """
        res = super(PaymentOrder, self)._prepare_bank_payment_line(paylines)
        partner = paylines.mapped('partner_id')

        with setlocale(partner.lang):
            invoices = paylines.mapped('move_line_id.invoice_id').with_context(
                lang=partner.lang)
            products = invoices.mapped('invoice_line_ids.product_id')
            invoice_type = list(set(invoices.mapped('invoice_type')))
            invoice_type = invoice_type and invoice_type[0] or 'other'
            communication = False
            if invoice_type in ('sponsorship', 'gift'):
                children = invoices.mapped(
                    'invoice_line_ids.contract_id.child_id')
                if len(children) == 1:
                    if invoice_type == 'sponsorship':
                        communication = _('Sponsorship')
                    elif len(products) == 1:
                        communication = products.name + ' ' + _('for')
                    else:
                        communication = _('sponsorship gifts').title() + \
                            ' ' + _('for')
                    communication += ' ' + children.preferred_name
                else:
                    communication = str(len(children)) + ' '
                    if invoice_type == 'sponsorship':
                        communication += _('sponsorships')
                    else:
                        communication += _('sponsorship gifts')

                if invoice_type == 'sponsorship':
                    communication += ' ' + _('Period: ')
                    if len(invoices) < 4:
                        communication += invoices.get_date(
                            'date_invoice', '%B')
                    else:
                        communication += str(len(invoices)) + ' ' + _('months')
            elif len(products) == 1:
                communication = products.name

            if communication:
                res['communication'] = communication

        return res
Beispiel #4
0
    def _prepare_bank_payment_line_with_lang(self, paylines, partner, res):
        with setlocale(partner.lang):
            invoices = paylines.mapped('move_line_id.invoice_id').with_context(
                lang=partner.lang)
            products = invoices.mapped('invoice_line_ids.product_id')
            invoice_type = list(set(invoices.mapped('invoice_type')))
            invoice_type = invoice_type and invoice_type[0] or 'other'
            communication = False
            if invoice_type in ('sponsorship', 'gift'):
                children = invoices.mapped(
                    'invoice_line_ids.contract_id.child_id')
                if len(children) == 1:
                    if invoice_type == 'sponsorship':
                        communication = _('Sponsorship')
                    elif len(products) == 1:
                        communication = products.name + ' ' + _('for')
                    else:
                        communication = _('sponsorship gifts').title() + \
                            ' ' + _('for')
                    communication += ' ' + children.preferred_name
                else:
                    communication = str(len(children)) + ' '
                    if invoice_type == 'sponsorship':
                        communication += _('sponsorships')
                    else:
                        communication += _('sponsorship gifts')

                if invoice_type == 'sponsorship':
                    communication += ' ' + _('Period: ')
                    if len(invoices) < 4:
                        communication += invoices.get_date(
                            'date_invoice', '%B')
                    else:
                        communication += str(len(invoices)) + ' ' + _('months')
            elif len(products) == 1:
                communication = products.name

            if communication:
                res['communication'] = communication

        return res
    def _prepare_bank_payment_line_with_lang(self, paylines, partner, res):
        with setlocale(partner.lang):
            invoices = paylines.mapped('move_line_id.invoice_id').with_context(
                lang=partner.lang)
            products = invoices.mapped('invoice_line_ids.product_id')
            invoice_type = list(set(invoices.mapped('invoice_type')))
            invoice_type = invoice_type and invoice_type[0] or 'other'
            communication = False
            if invoice_type in ('sponsorship', 'gift'):
                children = invoices.mapped(
                    'invoice_line_ids.contract_id.child_id')
                if len(children) == 1:
                    if invoice_type == 'sponsorship':
                        communication = _('Sponsorship')
                    elif len(products) == 1:
                        communication = products.name + ' ' + _('for')
                    else:
                        communication = _('sponsorship gifts').title() + \
                            ' ' + _('for')
                    communication += ' ' + children.preferred_name
                else:
                    communication = str(len(children)) + ' '
                    if invoice_type == 'sponsorship':
                        communication += _('sponsorships')
                    else:
                        communication += _('sponsorship gifts')

                if invoice_type == 'sponsorship':
                    communication += ' ' + _('Period: ')
                    if len(invoices) < 4:
                        communication += invoices.get_date('date_invoice',
                                                           '%B')
                    else:
                        communication += str(len(invoices)) + ' ' + _('months')
            elif len(products) == 1:
                communication = products.name

            if communication:
                res['communication'] = communication

        return res