Ejemplo n.º 1
0
    def _get_invoices_data(self, cr, uid, ids, field_name, arg, context=None):
        obj = self.pool['account.invoice.report']
        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', '>=', date_begin),
                              ('date', '<=', date_end)]
            values = self.__get_bar_values(cr,
                                           uid,
                                           obj,
                                           created_domain,
                                           ['price_total', 'date'],
                                           'price_total',
                                           'date',
                                           context=context)
            for value in values:
                value['value'] = float_repr(
                    value.get('value', 0),
                    precision_digits=self.pool['decimal.precision'].
                    precision_get(cr, uid, 'Account'))
            res[id] = json.dumps(values)
        return res
Ejemplo n.º 2
0
 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)
     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,
         })
     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
 def ogone_form_generate_values(self, cr, uid, id, partner_values, tx_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)
     ogone_tx_values = dict(tx_values)
     temp_ogone_tx_values = {
         'PSPID': acquirer.ogone_pspid,
         'ORDERID': tx_values['reference'],
         'AMOUNT': float_repr(float_round(tx_values['amount'], 2) * 100, 0),
         'CURRENCY': tx_values['currency'] and tx_values['currency'].name or '',
         'LANGUAGE':  partner_values['lang'],
         'CN':  partner_values['name'],
         'EMAIL':  partner_values['email'],
         'OWNERZIP':  partner_values['zip'],
         'OWNERADDRESS':  partner_values['address'],
         'OWNERTOWN':  partner_values['city'],
         'OWNERCTY':  partner_values['country'] and partner_values['country'].code or '',
         'OWNERTELNO': partner_values['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),
     }
     if ogone_tx_values.get('return_url'):
         temp_ogone_tx_values['PARAMPLUS'] = 'return_url=%s' % ogone_tx_values.pop('return_url')
     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 partner_values, ogone_tx_values
Ejemplo n.º 4
0
 def ogone_form_generate_values(self, cr, uid, id, partner_values, tx_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)
     ogone_tx_values = dict(tx_values)
     temp_ogone_tx_values = {
         "PSPID": acquirer.ogone_pspid,
         "ORDERID": tx_values["reference"],
         "AMOUNT": float_repr(float_round(tx_values["amount"], 2) * 100, 0),
         "CURRENCY": tx_values["currency"] and tx_values["currency"].name or "",
         "LANGUAGE": partner_values["lang"],
         "CN": partner_values["name"],
         "EMAIL": partner_values["email"],
         "OWNERZIP": partner_values["zip"],
         "OWNERADDRESS": partner_values["address"],
         "OWNERTOWN": partner_values["city"],
         "OWNERCTY": partner_values["country"] and partner_values["country"].code or "",
         "OWNERTELNO": partner_values["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),
     }
     if tx_values.get("type") == "form_save":
         temp_ogone_tx_values.update(
             {
                 "ALIAS": "ODOO-NEW-ALIAS-%s" % time.time(),  # something unique,
                 "ALIASUSAGE": tx_values.get("alias_usage") or acquirer.ogone_alias_usage,
             }
         )
     if ogone_tx_values.get("return_url"):
         temp_ogone_tx_values["PARAMPLUS"] = "return_url=%s" % ogone_tx_values.pop("return_url")
     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 partner_values, ogone_tx_values
Ejemplo n.º 5
0
 def ogone_form_generate_values(self,
                                cr,
                                uid,
                                id,
                                partner_values,
                                tx_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)
     ogone_tx_values = dict(tx_values)
     temp_ogone_tx_values = {
         'PSPID':
         acquirer.ogone_pspid,
         'ORDERID':
         tx_values['reference'],
         'AMOUNT':
         float_repr(float_round(tx_values['amount'], 2) * 100, 0),
         'CURRENCY':
         tx_values['currency'] and tx_values['currency'].name or '',
         'LANGUAGE':
         partner_values['lang'],
         'CN':
         partner_values['name'],
         'EMAIL':
         partner_values['email'],
         'OWNERZIP':
         partner_values['zip'],
         'OWNERADDRESS':
         partner_values['address'],
         'OWNERTOWN':
         partner_values['city'],
         'OWNERCTY':
         partner_values['country'] and partner_values['country'].code or '',
         'OWNERTELNO':
         partner_values['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),
     }
     if ogone_tx_values.get('return_url'):
         temp_ogone_tx_values[
             'PARAMPLUS'] = 'return_url=%s' % ogone_tx_values.pop(
                 'return_url')
     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 partner_values, ogone_tx_values
Ejemplo n.º 6
0
    def _get_invoices_data(self, cr, uid, ids, field_name, arg, context=None):
        obj = self.pool['account.invoice.report']
        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', '>=', date_begin), ('date', '<=', date_end)]
            values = self.__get_bar_values(cr, uid, obj, created_domain, ['price_total', 'date'], 'price_total', 'date', context=context)
            for value in values:
                value['value'] = float_repr(value.get('value', 0), precision_digits=self.pool['decimal.precision'].precision_get(cr, uid, 'Account'))
            res[id] = json.dumps(values)
        return res
 def get_possible_payment_orders_for_statement_line(self, this):
     """find orders that might be candidates for matching a statement
     line"""
     digits = self.env['decimal.precision'].precision_get('Account')
     self.env.cr.execute(
         '''with order_sums as (
             select order_id, sum(amount_currency) as amount
             from payment_line
             join payment_order o on o.id=order_id
             where o.state in ('sent', 'done')
             group by order_id)
         select order_id from order_sums where amount = %s''',
         (Decimal(float_repr(abs(this.amount), digits)), ))
     order_ids = [i for i, in self.env.cr.fetchall()]
     # verify that this ids are accessible to the user
     domain = [
         ('id', 'in', order_ids),
     ]
     return self.env['payment.order'].search(domain)
Ejemplo n.º 8
0
    def ogonedadi_form_generate_values(self, cr, uid, id, partner_values, tx_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)

        ogonedadi_tx_values = dict(tx_values)
        # AMOUNT calculation changed! see: https://github.com/odoo/odoo/commit/7c2521a79bc9443adab1bc63007e70661a8c22b7
        temp_ogonedadi_tx_values = {
            'PSPID': acquirer.ogonedadi_pspid,
            'ORDERID': tx_values['reference'],
            'AMOUNT': float_repr(float_round(tx_values['amount'], 2) * 100, 0),
            'CURRENCY': tx_values['currency'] and tx_values['currency'].name or '',
            'LANGUAGE': partner_values['lang'],
            'CN': partner_values['name'],
            'EMAIL': partner_values['email'],
            'OWNERZIP': partner_values['zip'],
            'OWNERADDRESS': partner_values['address'],
            'OWNERTOWN': partner_values['city'],
            'OWNERCTY': partner_values['country'] and partner_values['country'].code or '',
            'OWNERTELNO': partner_values['phone'],
            'ACCEPTURL': '%s' % urlparse.urljoin(base_url, OgonedadiController._accept_url),
            'DECLINEURL': '%s' % urlparse.urljoin(base_url, OgonedadiController._decline_url),
            'EXCEPTIONURL': '%s' % urlparse.urljoin(base_url, OgonedadiController._exception_url),
            'CANCELURL': '%s' % urlparse.urljoin(base_url, OgonedadiController._cancel_url),
        }
        if ogonedadi_tx_values.get('return_url'):
            temp_ogonedadi_tx_values['PARAMPLUS'] = 'return_url=%s' % ogonedadi_tx_values.pop('return_url')

        # By Mike: extra values to submit to ogone if set in payment.acquirer form
        if acquirer.ogonedadi_pm:
            temp_ogonedadi_tx_values['PM'] = acquirer.ogonedadi_pm
        if acquirer.ogonedadi_brand:
            temp_ogonedadi_tx_values['BRAND'] = acquirer.ogonedadi_brand
        if acquirer.ogonedadi_tp:
            temp_ogonedadi_tx_values['TP'] = acquirer.ogonedadi_tp

        shasign = self._ogonedadi_generate_shasign(acquirer, 'in', temp_ogonedadi_tx_values)
        temp_ogonedadi_tx_values['SHASIGN'] = shasign

        ogonedadi_tx_values.update(temp_ogonedadi_tx_values)
        return partner_values, ogonedadi_tx_values
Ejemplo n.º 9
0
    def ogonedadi_form_generate_values(self,
                                       cr,
                                       uid,
                                       id,
                                       partner_values,
                                       tx_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)

        ogonedadi_tx_values = dict(tx_values)
        # AMOUNT calculation changed! see: https://github.com/odoo/odoo/commit/7c2521a79bc9443adab1bc63007e70661a8c22b7
        temp_ogonedadi_tx_values = {
            'PSPID':
            acquirer.ogonedadi_pspid,
            'ORDERID':
            tx_values['reference'],
            'AMOUNT':
            float_repr(float_round(tx_values['amount'], 2) * 100, 0),
            'CURRENCY':
            tx_values['currency'] and tx_values['currency'].name or '',
            'LANGUAGE':
            partner_values['lang'],
            'CN':
            partner_values['name'],
            'EMAIL':
            partner_values['email'],
            'OWNERZIP':
            partner_values['zip'],
            'OWNERADDRESS':
            partner_values['address'],
            'OWNERTOWN':
            partner_values['city'],
            'OWNERCTY':
            partner_values['country'] and partner_values['country'].code or '',
            'OWNERTELNO':
            partner_values['phone'],
            'ACCEPTURL':
            '%s' % urlparse.urljoin(base_url, OgonedadiController._accept_url),
            'DECLINEURL':
            '%s' %
            urlparse.urljoin(base_url, OgonedadiController._decline_url),
            'EXCEPTIONURL':
            '%s' %
            urlparse.urljoin(base_url, OgonedadiController._exception_url),
            'CANCELURL':
            '%s' % urlparse.urljoin(base_url, OgonedadiController._cancel_url),
        }
        if ogonedadi_tx_values.get('return_url'):
            temp_ogonedadi_tx_values[
                'PARAMPLUS'] = 'return_url=%s' % ogonedadi_tx_values.pop(
                    'return_url')

        # By Mike: extra values to submit to ogone if set in payment.acquirer form
        if acquirer.ogonedadi_pm:
            temp_ogonedadi_tx_values['PM'] = acquirer.ogonedadi_pm
        if acquirer.ogonedadi_brand:
            temp_ogonedadi_tx_values['BRAND'] = acquirer.ogonedadi_brand
        if acquirer.ogonedadi_tp:
            temp_ogonedadi_tx_values['TP'] = acquirer.ogonedadi_tp

        shasign = self._ogonedadi_generate_shasign(acquirer, 'in',
                                                   temp_ogonedadi_tx_values)
        temp_ogonedadi_tx_values['SHASIGN'] = shasign

        ogonedadi_tx_values.update(temp_ogonedadi_tx_values)
        return partner_values, ogonedadi_tx_values