Пример #1
0
    def _wrap_payment_block(self,
                            cr,
                            uid,
                            html_block,
                            amount,
                            currency_id,
                            acquirer=None,
                            context=None):
        """ override original method to add the paybox html block """
        if not html_block:
            if acquirer and acquirer == 'Paybox':
                return ''
            else:
                link = '#action=account.action_account_config'
                payment_header = _(""" You can finish the configuration in the
<a href="%s">Bank&Cash settings</a>""") % link
                amount = _('No online payment acquirers configured')
                group_ids = self.pool.get('res.users').browse(
                    cr, uid, uid, context=context).groups_id
                if any(group.is_portal for group in group_ids):
                    return ''
        else:
            payment_header = _('Pay safely online')
            currency_obj = self.pool['res.currency']
            currency = currency_obj.browse(cr, uid, currency_id)
            currency_str = currency.symbol or currency.name
            if acquirer and acquirer == 'Paybox':
                amount_str = float_repr(
                    amount,
                    self.pool.get('decimal.precision').precision_get(
                        cr, uid, 'Account'))
                amount = (u"%s %s" %
                          ((currency_str,
                            amount_str) if currency.position == 'before' else
                           (amount_str, currency_str)))
            else:
                amount_str = float_repr(
                    amount,
                    self.pool.get('decimal.precision').precision_get(
                        cr, uid, 'Account'))
                amount = (u"%s %s" %
                          ((currency_str,
                            amount_str) if currency.position == 'before' else
                           (amount_str, currency_str)))

        result = """<div class="payment_acquirers">
                         <div class="payment_header">
                             <div class="payment_amount">%s</div>
                             %s
                         </div>
                         %%s
                     </div>""" % (amount, payment_header)
        return result % html_block
Пример #2
0
 def _wrap_payment_block(self,
                         cr,
                         uid,
                         html_block,
                         amount,
                         currency_id,
                         context=None):
     payment_header = _('Pay safely online')
     amount_str = float_repr(
         amount,
         self.pool.get('decimal.precision').precision_get(
             cr, uid, 'Account'))
     currency = self.pool['res.currency'].browse(cr,
                                                 uid,
                                                 currency_id,
                                                 context=context)
     currency_str = currency.symbol or currency.name
     amount = u"%s %s" % (
         (currency_str, amount_str) if currency.position == 'before' else
         (amount_str, currency_str))
     result = u"""<div class="payment_acquirers">
                      <div class="payment_header">
                          <div class="payment_amount">%s</div>
                          %s
                      </div>
                      %%s
                  </div>""" % (amount, payment_header)
     return result % html_block.decode("utf-8")
Пример #3
0
 def _wrap_payment_block(self, cr, uid, html_block, amount, currency, context=None):
     if not html_block:
         link = "#action=account.action_account_config"
         payment_header = _('You can finish the configuration in the <a href="%s">Bank&Cash settings</a>') % link
         amount = _("No online payment acquirers configured")
         group_ids = self.pool.get("res.users").browse(cr, SUPERUSER_ID, uid, context=context).groups_id
         if any(group.is_portal for group in group_ids):
             return ""
     else:
         payment_header = _("Pay safely online")
         amount_str = float_repr(amount, self.pool.get("decimal.precision").precision_get(cr, uid, "Account"))
         currency_str = currency.symbol or currency.name
         amount = u"%s %s" % (
             (currency_str, amount_str) if currency.position == "before" else (amount_str, currency_str)
         )
     result = """<div class="payment_acquirers">
                      <div class="payment_header">
                          <div class="payment_amount">%s</div>
                          %s
                      </div>
                      %%s
                  </div>""" % (
         amount,
         payment_header,
     )
     return result % html_block
Пример #4
0
 def _wrap_payment_block(self,
                         cr,
                         uid,
                         html_block,
                         amount,
                         currency,
                         context=None):
     if not html_block:
         link = '#action=account.action_account_config'
         payment_header = _(
             'You can finish the configuration in the <a href="%s">Bank&Cash settings</a>'
         ) % link
         amount = _('No online payment acquirers configured')
         group_ids = self.pool.get('res.users').browse(
             cr, SUPERUSER_ID, uid, context=context).groups_id
         if any(group.is_portal for group in group_ids):
             return ''
     else:
         payment_header = _('Pay safely online')
         amount_str = float_repr(
             amount,
             self.pool.get('decimal.precision').precision_get(
                 cr, uid, 'Account'))
         currency_str = currency.symbol or currency.name
         amount = u"%s %s" % ((currency_str, amount_str)
                              if currency.position == 'before' else
                              (amount_str, currency_str))
     result = """<div class="payment_acquirers">
                      <div class="payment_header">
                          <div class="payment_amount">%s</div>
                          %s
                      </div>
                      %%s
                  </div>""" % (amount, payment_header)
     return result % html_block
 def ogone_form_generate_values(self, cr, uid, id, values, context=None):
     base_url = self.pool['ir.config_parameter'].get_param(cr, uid, 'web.base.url')
     acquirer = self.browse(cr, uid, id, context=context)
     if not acquirer.payment_term_id:
         return super(PaymentAcquirerOgone, self).ogone_form_generate_values(cr, uid, id, values, context=context)
     ogone_tx_values = dict(values)
     temp_ogone_tx_values = {
         'PSPID': acquirer.ogone_pspid,
         'ORDERID': values['reference'],
         'AMOUNT': float_repr(float_round(values['amount'], 2) * 100, 0),
         'CURRENCY': values['currency'] and values['currency'].name or '',
         'LANGUAGE': values.get('partner_lang'),
         'CN': values.get('partner_name'),
         'EMAIL': values.get('partner_email'),
         'OWNERZIP': values.get('partner_zip'),
         'OWNERADDRESS': values.get('partner_address'),
         'OWNERTOWN': values.get('partner_city'),
         'OWNERCTY': values.get('partner_country') and values.get('partner_country').code or '',
         'OWNERTELNO': values.get('partner_phone'),
         'ACCEPTURL': '%s' % urlparse.urljoin(base_url, OgoneController._accept_url),
         'DECLINEURL': '%s' % urlparse.urljoin(base_url, OgoneController._decline_url),
         'EXCEPTIONURL': '%s' % urlparse.urljoin(base_url, OgoneController._exception_url),
         'CANCELURL': '%s' % urlparse.urljoin(base_url, OgoneController._cancel_url),
         'PARAMPLUS': 'return_url=%s' % ogone_tx_values.pop('return_url') if ogone_tx_values.get('return_url') else False,
     }
     if values.get('type') == 'form_save':
         temp_ogone_tx_values.update({
             'ALIAS': 'ODOO-NEW-ALIAS-%s' % time.time(),    # something unique,
             'ALIASUSAGE': values.get('alias_usage') or acquirer.ogone_alias_usage,
         })
     totlines = acquirer.payment_term_id.compute(
         float_round(values['amount'], 2),
     )[0]
     index = 1
     for scheduled_date, amount in sorted(totlines):
         scheduled_date = datetime.strptime(scheduled_date, DEFAULT_SERVER_DATE_FORMAT).strftime('%d/%m/%Y')
         if index == 1:
             temp_ogone_tx_values['AMOUNT1'] = float_repr(float_round(amount, 2) * 100, 0)
         else:
             temp_ogone_tx_values['AMOUNT' + str(index)] = float_repr(float_round(amount, 2) * 100, 0)
             temp_ogone_tx_values['EXECUTIONDATE' + str(index)] = scheduled_date
         index += 1
     shasign = self._ogone_generate_shasign(acquirer, 'in', temp_ogone_tx_values)
     temp_ogone_tx_values['SHASIGN'] = shasign
     ogone_tx_values.update(temp_ogone_tx_values)
     return ogone_tx_values
Пример #6
0
    def _wrap_payment_block(self, cr, uid, html_block, amount,
                            currency_id, acquirer=None, context=None):
        """ override original method to add the paybox html block """
        if not html_block:
            if acquirer and acquirer == 'Paybox':
                return ''
            else:
                link = '#action=account.action_account_config'
                payment_header = _(""" You can finish the configuration in the
<a href="%s">Bank&Cash settings</a>""") % link
                amount = _('No online payment acquirers configured')
                group_ids = self.pool.get('res.users').browse(
                    cr, uid, uid, context=context).groups_id
                if any(group.is_portal for group in group_ids):
                    return ''
        else:
            payment_header = _('Pay safely online')
            currency_obj = self.pool['res.currency']
            currency = currency_obj.browse(cr, uid, currency_id)
            currency_str = currency.symbol or currency.name
            if acquirer and acquirer == 'Paybox':
                amount_str = float_repr(
                    amount,
                    self.pool.get('decimal.precision').precision_get(cr, uid, 'Account'))
                amount = (u"%s %s" % ((currency_str, amount_str)
                          if currency.position == 'before' else (amount_str, currency_str)))
            else:
                amount_str = float_repr(
                    amount, self.pool.get('decimal.precision').precision_get(cr, uid, 'Account'))
                amount = (u"%s %s" % ((currency_str, amount_str)
                          if currency.position == 'before' else (amount_str, currency_str)))

        result = """<div class="payment_acquirers">
                         <div class="payment_header">
                             <div class="payment_amount">%s</div>
                             %s
                         </div>
                         %%s
                     </div>""" % (amount, payment_header)
        return result % html_block
Пример #7
0
    def _get_invoices_data_tax(self, cr, uid, ids, field_name, arg, context=None):
        obj = self.pool['account.invoice']
        month_begin = date.today().replace(day=1)
        date_begin = (month_begin - relativedelta.relativedelta(months=self._period_number - 1)).strftime(tools.DEFAULT_SERVER_DATE_FORMAT)
        date_end = month_begin.replace(day=calendar.monthrange(month_begin.year, month_begin.month)[1]).strftime(tools.DEFAULT_SERVER_DATE_FORMAT)

        res = {}
        for id in ids:
            created_domain = [('type', 'in', ['out_invoice', 'out_refund']), ('section_id', '=', id), ('state', 'not in', ['draft', 'cancel']), ('date_invoice', '>=', date_begin), ('date_invoice', '<=', date_end)]
            values = self.__get_bar_values(cr, uid, obj, created_domain, ['amount_total', 'date_invoice'], 'amount_total', 'date_invoice', context=context)
            for value in values:
                value['value'] = float_repr(value.get('value', 0), precision_digits=3)
            res[id] = json.dumps(values)
        return res
Пример #8
0
 def _wrap_payment_block(self, cr, uid, html_block, amount, currency_id, context=None):
     payment_header = _('Pay safely online')
     currency = self.pool['res.currency'].browse(cr, uid, currency_id, context=context)
     amount_str = float_repr(amount, currency.decimal_places)
     currency_str = currency.symbol or currency.name
     amount = u"%s %s" % ((currency_str, amount_str) if currency.position == 'before' else (amount_str, currency_str))
     result = u"""<div class="payment_acquirers">
                      <div class="payment_header">
                          <div class="payment_amount">%s</div>
                          %s
                      </div>
                      %%s
                  </div>""" % (amount, payment_header)
     return result % html_block.decode("utf-8")
 def _wrap_payment_block(self, cr, uid, html_block, amount, currency_id, context=None):
     payment_header = _("Pay safely online")
     amount_str = float_repr(amount, self.pool.get("decimal.precision").precision_get(cr, uid, "Account"))
     currency = self.pool["res.currency"].browse(cr, uid, currency_id, context=context)
     currency_str = currency.symbol or currency.name
     amount = u"%s %s" % (
         (currency_str, amount_str) if currency.position == "before" else (amount_str, currency_str)
     )
     result = u"""<div class="payment_acquirers">
                      <div class="payment_header">
                          <div class="payment_amount">%s</div>
                          %s
                      </div>
                      %%s
                  </div>""" % (
         amount,
         payment_header,
     )
     return result % html_block.decode("utf-8")