From e97eaf9963bfd398b0794f9ae06374f4ac97b024 Mon Sep 17 00:00:00 2001 From: mjavint Date: Thu, 14 Nov 2024 13:03:47 -0500 Subject: [PATCH 1/4] [ADD] Add recurring payments with stripe --- recurring_payments_stripe/__init__.py | 3 + recurring_payments_stripe/__manifest__.py | 19 +++++ recurring_payments_stripe/models/__init__.py | 3 + .../models/account_move.py | 64 +++++++++++++++++ .../models/sale_subscription.py | 44 ++++++++++++ .../security/ir.model.access.csv | 2 + .../views/sale_subscription_views.xml | 18 +++++ recurring_payments_stripe/wizard/__init__.py | 2 + .../sale_subscription_payment_wizard.py | 72 +++++++++++++++++++ .../sale_subscription_payment_wizard.xml | 37 ++++++++++ 10 files changed, 264 insertions(+) create mode 100644 recurring_payments_stripe/__init__.py create mode 100644 recurring_payments_stripe/__manifest__.py create mode 100644 recurring_payments_stripe/models/__init__.py create mode 100644 recurring_payments_stripe/models/account_move.py create mode 100644 recurring_payments_stripe/models/sale_subscription.py create mode 100644 recurring_payments_stripe/security/ir.model.access.csv create mode 100644 recurring_payments_stripe/views/sale_subscription_views.xml create mode 100644 recurring_payments_stripe/wizard/__init__.py create mode 100644 recurring_payments_stripe/wizard/sale_subscription_payment_wizard.py create mode 100644 recurring_payments_stripe/wizard/sale_subscription_payment_wizard.xml diff --git a/recurring_payments_stripe/__init__.py b/recurring_payments_stripe/__init__.py new file mode 100644 index 0000000000..408a6001bd --- /dev/null +++ b/recurring_payments_stripe/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- +from . import models +from . import wizard diff --git a/recurring_payments_stripe/__manifest__.py b/recurring_payments_stripe/__manifest__.py new file mode 100644 index 0000000000..d6339d88f8 --- /dev/null +++ b/recurring_payments_stripe/__manifest__.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +{ + "name": "Recurring Payments with Stripe", + "version": "16.0.1.0.0", + "summary": """ Recurring Payments with Stripe """, + "author": "Binhex, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/contract", + "license": "AGPL-3", + "category": "Subscription Management", + "depends": ["subscription_oca", "payment_stripe", "payment"], + "data": [ + "views/sale_subscription_views.xml", + "wizard/sale_subscription_payment_wizard.xml", + "security/ir.model.access.csv" + ], + "application": True, + "installable": True, + "auto_install": False, +} diff --git a/recurring_payments_stripe/models/__init__.py b/recurring_payments_stripe/models/__init__.py new file mode 100644 index 0000000000..82c93204e4 --- /dev/null +++ b/recurring_payments_stripe/models/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- +from . import sale_subscription +from . import account_move diff --git a/recurring_payments_stripe/models/account_move.py b/recurring_payments_stripe/models/account_move.py new file mode 100644 index 0000000000..7a30b07c4f --- /dev/null +++ b/recurring_payments_stripe/models/account_move.py @@ -0,0 +1,64 @@ +# -*- coding: utf-8 -*- +import logging +import stripe + +from odoo import models, fields, api, _ +from odoo.exceptions import UserError, ValidationError + +_logger = logging.getLogger(__name__) + + +class AccountMove(models.Model): + _inherit = "account.move" + + def stripe_pay_invoice(self): + """Paga la factura en Stripe si `is_recurrent` está activado en la suscripción.""" + for invoice in self: + subscription = invoice.invoice_origin and self.env[ + "sale.subscription" + ].search([("code", "=", invoice.invoice_origin)], limit=1) + if ( + subscription + and subscription.is_recurrent + and subscription.stripe_customer + ): + provider = self.env["payment.provider"].search( + [("code", "=", "stripe")], + ) + stripe.api_key = provider.stripe_secret_key + try: + # Crea un PaymentIntent en Stripe para el monto de la factura + payment_intent = stripe.PaymentIntent.create( + amount=int( + invoice.amount_total * 100 + ), # Stripe maneja montos en centavos + currency=invoice.currency_id.name.lower(), + customer=subscription.stripe_customer, + payment_method="pm_1QL6VqRwXzxKyS2wEWj2Js5U", + payment_method_types=["card"], + description=f"Odoo Invoice {invoice.name}", + metadata={"odoo_invoice_id": invoice.id}, + ) + + # Confirmar el pago y actualizar el estado de la factura en Odoo + if payment_intent["status"] == "succeeded": + invoice.action_post() + invoice.payment_state = "paid" + else: + raise Exception( + f"Error en el pago de Stripe: {payment_intent['status']}" + ) + + except stripe.error.StripeError as e: + raise UserError(f"Stripe error: {e.user_message or str(e)}") + + def action_post(self): + """Sobreescribe el método `action_post` para procesar el pago automático si `is_recurrent` está activo.""" + res = super(AccountMove, self).action_post() + for invoice in self: + subscription = self.env["sale.subscription"].search( + [("code", "=", invoice.invoice_origin)], limit=1 + ) + if subscription and subscription.is_recurrent: + invoice.stripe_pay_invoice() + return res diff --git a/recurring_payments_stripe/models/sale_subscription.py b/recurring_payments_stripe/models/sale_subscription.py new file mode 100644 index 0000000000..72f6750378 --- /dev/null +++ b/recurring_payments_stripe/models/sale_subscription.py @@ -0,0 +1,44 @@ +# -*- coding: utf-8 -*- +import logging +import stripe + +from odoo import models, fields, api, _ +from odoo.exceptions import UserError, ValidationError + +_logger = logging.getLogger(__name__) + + +class SaleSubscription(models.Model): + _inherit = "sale.subscription" + + is_recurrent = fields.Boolean(string="Pago Automático Recurrente") + # ID del cliente en Stripe + stripe_customer = fields.Char(string="Stripe Customer ID") + + def _get_client_stripe(self, secret_key): + client = stripe.StripeClient(secret_key) + return client + + def create_stripe_customer(self): + """Crea o recupera el cliente de Stripe asociado a la suscripción.""" + provider = self.env["payment.provider"].search( + [("code", "=", "stripe")], + ) + stripe.api_key = provider.stripe_secret_key + + client = self._get_client_stripe(provider.stripe_secret_key) + + if not self.stripe_customer: + customer = stripe.Customer.create( + email=self.partner_id.email, + name=self.partner_id.name, + metadata={"odoo_subscription_id": self.id}, + ) + self.stripe_customer = customer["id"] + return self.stripe_customer + + @api.onchange("is_recurrent") + def _onchange_is_recurrent(self): + for record in self: + if record.is_recurrent: + record.create_stripe_customer() diff --git a/recurring_payments_stripe/security/ir.model.access.csv b/recurring_payments_stripe/security/ir.model.access.csv new file mode 100644 index 0000000000..1b4b0ce2a6 --- /dev/null +++ b/recurring_payments_stripe/security/ir.model.access.csv @@ -0,0 +1,2 @@ +id,name,model_id/id,group_id/id,perm_read,perm_write,perm_create,perm_unlink +access_sale_subscription_payment_wizard_manager,sale_subscription_payment_wizard_manager,model_sale_subscription_payment_wizard,,1,1,1,1 diff --git a/recurring_payments_stripe/views/sale_subscription_views.xml b/recurring_payments_stripe/views/sale_subscription_views.xml new file mode 100644 index 0000000000..a223bbb835 --- /dev/null +++ b/recurring_payments_stripe/views/sale_subscription_views.xml @@ -0,0 +1,18 @@ + + + + + + sale.subscription.form + sale.subscription + + + + + + + + + + + diff --git a/recurring_payments_stripe/wizard/__init__.py b/recurring_payments_stripe/wizard/__init__.py new file mode 100644 index 0000000000..15e249b83d --- /dev/null +++ b/recurring_payments_stripe/wizard/__init__.py @@ -0,0 +1,2 @@ +# -*- coding: utf-8 -*- +from . import sale_subscription_payment_wizard diff --git a/recurring_payments_stripe/wizard/sale_subscription_payment_wizard.py b/recurring_payments_stripe/wizard/sale_subscription_payment_wizard.py new file mode 100644 index 0000000000..7dbcf3da1a --- /dev/null +++ b/recurring_payments_stripe/wizard/sale_subscription_payment_wizard.py @@ -0,0 +1,72 @@ +from odoo import models, fields, api +from odoo.exceptions import UserError +import stripe + + +class SaleSubscriptionPaymentWizard(models.TransientModel): + _name = "sale.subscription.payment.wizard" + _description = "Wizard para Tokenizar Método de Pago de Suscripción" + + subscription_id = fields.Many2one( + "sale.subscription", string="Suscripción", required=True + ) + card_number = fields.Char(string="Número de Tarjeta", required=True) + card_exp_month = fields.Char(string="Mes de Expiración (MM)", required=True) + card_exp_year = fields.Char(string="Año de Expiración (YYYY)", required=True) + card_cvc = fields.Char(string="CVC", required=True) + + @api.model + def default_get(self, fields): + res = super(SaleSubscriptionPaymentWizard, self).default_get(fields) + subscription_id = self.env.context.get("active_id") + if subscription_id: + res["subscription_id"] = subscription_id + return res + + def action_create_token(self): + """Crea un token en Stripe usando los datos de la tarjeta y lo guarda en la suscripción.""" + provider = self.env["payment.provider"].search( + [("code", "=", "stripe")], + ) + stripe.api_key = provider.stripe_secret_key + + # Intenta crear un token en Stripe + try: + token = stripe.Token.create( + card={ + "number": self.card_number, + "exp_month": self.card_exp_month, + "exp_year": self.card_exp_year, + "cvc": self.card_cvc, + }, + ) + + # Vincular el token de tarjeta con el cliente en Stripe + subscription = self.subscription_id + if not subscription.stripe_customer: + customer = stripe.Customer.create( + email=subscription.partner_id.email, + name=subscription.partner_id.name, + ) + subscription.stripe_customer = customer["id"] + + # Crear y vincular el método de pago a la suscripción + payment_method = stripe.PaymentMethod.create( + type="card", + card={"token": token.id}, + ) + stripe.PaymentMethod.attach( + payment_method.id, customer=subscription.stripe_customer + ) + stripe.Customer.modify( + subscription.stripe_customer, + invoice_settings={"default_payment_method": payment_method.id}, + ) + + # Guardar detalles del método de pago en la suscripción + subscription.stripe_payment_method_id = payment_method.id + subscription.card_last4 = token.card.last4 + subscription.card_brand = token.card.brand + + except stripe.error.StripeError as e: + raise UserError(f"Error en Stripe: {e.user_message or str(e)}") diff --git a/recurring_payments_stripe/wizard/sale_subscription_payment_wizard.xml b/recurring_payments_stripe/wizard/sale_subscription_payment_wizard.xml new file mode 100644 index 0000000000..c174291520 --- /dev/null +++ b/recurring_payments_stripe/wizard/sale_subscription_payment_wizard.xml @@ -0,0 +1,37 @@ + + + + + + sale.subscription.payment.wizard.form + sale.subscription.payment.wizard + +
+ + + + + + + +
+
+
+
+
+ + + + Sale Subscription Payment Wizard + ir.actions.act_window + sale.subscription.payment.wizard + form + + new + + +
From e47bd6c8fddd58f3fcd575fda57d7e0e2d8dc815 Mon Sep 17 00:00:00 2001 From: mjavint Date: Thu, 14 Nov 2024 16:09:48 -0500 Subject: [PATCH 2/4] [FIX] Fixed recurring payments --- recurring_payments_stripe/__init__.py | 1 - recurring_payments_stripe/__manifest__.py | 3 +- recurring_payments_stripe/data/ir_cron.xml | 16 ++ .../models/account_move.py | 163 ++++++++++++++---- .../models/sale_subscription.py | 12 +- .../security/ir.model.access.csv | 2 - .../views/sale_subscription_views.xml | 2 +- recurring_payments_stripe/wizard/__init__.py | 2 - .../sale_subscription_payment_wizard.py | 72 -------- .../sale_subscription_payment_wizard.xml | 37 ---- 10 files changed, 155 insertions(+), 155 deletions(-) create mode 100644 recurring_payments_stripe/data/ir_cron.xml delete mode 100644 recurring_payments_stripe/security/ir.model.access.csv delete mode 100644 recurring_payments_stripe/wizard/__init__.py delete mode 100644 recurring_payments_stripe/wizard/sale_subscription_payment_wizard.py delete mode 100644 recurring_payments_stripe/wizard/sale_subscription_payment_wizard.xml diff --git a/recurring_payments_stripe/__init__.py b/recurring_payments_stripe/__init__.py index 408a6001bd..a0fdc10fe1 100644 --- a/recurring_payments_stripe/__init__.py +++ b/recurring_payments_stripe/__init__.py @@ -1,3 +1,2 @@ # -*- coding: utf-8 -*- from . import models -from . import wizard diff --git a/recurring_payments_stripe/__manifest__.py b/recurring_payments_stripe/__manifest__.py index d6339d88f8..d5245e666a 100644 --- a/recurring_payments_stripe/__manifest__.py +++ b/recurring_payments_stripe/__manifest__.py @@ -10,8 +10,7 @@ "depends": ["subscription_oca", "payment_stripe", "payment"], "data": [ "views/sale_subscription_views.xml", - "wizard/sale_subscription_payment_wizard.xml", - "security/ir.model.access.csv" + "data/ir_cron.xml", ], "application": True, "installable": True, diff --git a/recurring_payments_stripe/data/ir_cron.xml b/recurring_payments_stripe/data/ir_cron.xml new file mode 100644 index 0000000000..b33eeb57bf --- /dev/null +++ b/recurring_payments_stripe/data/ir_cron.xml @@ -0,0 +1,16 @@ + + + + + Procesar Facturas Vencidas para Suscripciones + Recurrentes + + code + model.cron_process_due_invoices() + 1 + days + -1 + True + + + diff --git a/recurring_payments_stripe/models/account_move.py b/recurring_payments_stripe/models/account_move.py index 7a30b07c4f..cc1bec6ac0 100644 --- a/recurring_payments_stripe/models/account_move.py +++ b/recurring_payments_stripe/models/account_move.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- import logging import stripe +from datetime import date from odoo import models, fields, api, _ from odoo.exceptions import UserError, ValidationError @@ -11,54 +12,158 @@ class AccountMove(models.Model): _inherit = "account.move" - def stripe_pay_invoice(self): - """Paga la factura en Stripe si `is_recurrent` está activado en la suscripción.""" + # def stripe_pay_invoice(self): + # """Paga la factura en Stripe si `is_recurrent` está activado en la suscripción.""" + # for invoice in self: + # subscription = invoice.invoice_date and self.env[ + # "sale.subscription" + # ].search([("code", "=", invoice.invoice_date)], limit=1) + # if ( + # subscription + # and subscription.is_recurrent + # and subscription.stripe_customer + # ): + # provider = self.env["payment.provider"].search( + # [("code", "=", "stripe")], + # ) + # stripe.api_key = provider.stripe_secret_key + # token = self.env["payment.token"].search( + # [("provider_id", "=", provider.id)] + # ) + # try: + # # Crea un PaymentIntent en Stripe para el monto de la factura + # payment_intent = stripe.PaymentIntent.create( + # # Stripe maneja montos en centavos + # amount=int(invoice.amount_total * 100), + # currency=invoice.currency_id.name.lower(), + # customer=token.provider_ref, + # payment_method=token.stripe_payment_method, + # payment_method_types=["card"], + # # Para pagos automáticos sin intervención del usuario + # off_session=True, + # # Confirmar el PaymentIntent inmediatamente + # confirm=True, + # metadata={"odoo_invoice_id": invoice.id}, + # ) + + # # Confirmar el pago y actualizar el estado de la factura en Odoo + # if payment_intent["status"] == "succeeded": + # invoice.action_post() + # invoice.payment_state = "paid" + # else: + # raise Exception( + # f"Error en el pago de Stripe: {payment_intent['status']}" + # ) + + # except stripe.StripeError as e: + # raise UserError(f"Stripe error: {e.user_message or str(e)}") + + # def action_post(self): + # """Sobreescribe el método `action_post` para procesar el pago automático si `is_recurrent` está activo.""" + # res = super(AccountMove, self).action_post() + # for invoice in self: + # subscription = self.env["sale.subscription"].search( + # [("code", "=", invoice.invoice_date)], limit=1 + # ) + # if subscription and subscription.is_recurrent: + # invoice.stripe_pay_invoice() + # return res + + def action_register_payment(self): + """Sobreescribe `action_register_payment` para procesar automáticamente el pago con Stripe en suscripciones.""" for invoice in self: - subscription = invoice.invoice_origin and self.env[ - "sale.subscription" - ].search([("code", "=", invoice.invoice_origin)], limit=1) - if ( - subscription - and subscription.is_recurrent - and subscription.stripe_customer - ): + # Buscar la suscripción asociada a la factura, si existe + subscription = self.env["sale.subscription"].search( + [("code", "=", invoice.invoice_origin)], limit=1 + ) + + # Verificar si la suscripción es recurrente y tiene método de pago en Stripe + if subscription and subscription.is_recurrent: provider = self.env["payment.provider"].search( [("code", "=", "stripe")], ) stripe.api_key = provider.stripe_secret_key + token = self.env["payment.token"].search( + [("provider_id", "=", provider.id)] + ) try: - # Crea un PaymentIntent en Stripe para el monto de la factura + # Crear el PaymentIntent en Stripe y confirmarlo inmediatamente payment_intent = stripe.PaymentIntent.create( - amount=int( - invoice.amount_total * 100 - ), # Stripe maneja montos en centavos + # Stripe usa centavos + amount=int(invoice.amount_total * 100), currency=invoice.currency_id.name.lower(), - customer=subscription.stripe_customer, - payment_method="pm_1QL6VqRwXzxKyS2wEWj2Js5U", - payment_method_types=["card"], - description=f"Odoo Invoice {invoice.name}", + customer=token.provider_ref, + payment_method=token.stripe_payment_method, + # Para pagos automáticos sin intervención del usuario + off_session=True, + # Confirmar el PaymentIntent inmediatamente + confirm=True, metadata={"odoo_invoice_id": invoice.id}, ) - # Confirmar el pago y actualizar el estado de la factura en Odoo + # Manejar el resultado del PaymentIntent if payment_intent["status"] == "succeeded": - invoice.action_post() + # Si el pago es exitoso, registrar el pago en la factura + Payment = self.env["account.payment"].sudo() + payment_vals = { + "journal_id": self.env["account.journal"] + .search([("type", "=", "bank")], limit=1) + .id, + "amount": invoice.amount_total, + "payment_type": "inbound", + "partner_type": "customer", + "partner_id": invoice.partner_id.id, + "payment_method_id": self.env.ref( + "account.account_payment_method_manual_in" + ).id, + "ref": f"Stripe PaymentIntent {payment_intent['id']}", + } + payment = Payment.create(payment_vals) + payment.action_post() invoice.payment_state = "paid" + elif payment_intent["status"] == "requires_action": + raise UserError( + "El pago requiere autenticación adicional (3D Secure)." + ) else: - raise Exception( + raise UserError( f"Error en el pago de Stripe: {payment_intent['status']}" ) - except stripe.error.StripeError as e: - raise UserError(f"Stripe error: {e.user_message or str(e)}") + except stripe.StripeError as e: + raise UserError(f"Error de Stripe: {e.user_message or str(e)}") - def action_post(self): - """Sobreescribe el método `action_post` para procesar el pago automático si `is_recurrent` está activo.""" - res = super(AccountMove, self).action_post() - for invoice in self: + else: + # Si no es una suscripción recurrente o no tiene método de pago en Stripe, llama al método original + return super(AccountMove, self).action_register_payment() + + @api.model + def cron_process_due_invoices(self): + """Procesa el pago de facturas vencidas para suscripciones recurrentes.""" + # Obtener la fecha de hoy + today = date.today() + + # Buscar facturas de suscripciones recurrentes que vencen hoy y están abiertas + invoices = self.search( + [ + ("state", "=", "posted"), + ("payment_state", "=", "not_paid"), + ] + ) + + for invoice in invoices: + # Buscar la suscripción asociada a la factura subscription = self.env["sale.subscription"].search( [("code", "=", invoice.invoice_origin)], limit=1 ) + + # Verificar si es una suscripción recurrente con Stripe if subscription and subscription.is_recurrent: - invoice.stripe_pay_invoice() - return res + try: + # Intentar registrar el pago en la factura + invoice.action_register_payment() + except Exception as e: + # Capturar excepciones en caso de error en el registro de pago + _logger.error( + f"Error al procesar el pago de la factura {invoice.id}: {str(e)}" + ) diff --git a/recurring_payments_stripe/models/sale_subscription.py b/recurring_payments_stripe/models/sale_subscription.py index 72f6750378..d03a64cb0c 100644 --- a/recurring_payments_stripe/models/sale_subscription.py +++ b/recurring_payments_stripe/models/sale_subscription.py @@ -15,10 +15,6 @@ class SaleSubscription(models.Model): # ID del cliente en Stripe stripe_customer = fields.Char(string="Stripe Customer ID") - def _get_client_stripe(self, secret_key): - client = stripe.StripeClient(secret_key) - return client - def create_stripe_customer(self): """Crea o recupera el cliente de Stripe asociado a la suscripción.""" provider = self.env["payment.provider"].search( @@ -26,13 +22,11 @@ def create_stripe_customer(self): ) stripe.api_key = provider.stripe_secret_key - client = self._get_client_stripe(provider.stripe_secret_key) - if not self.stripe_customer: customer = stripe.Customer.create( - email=self.partner_id.email, - name=self.partner_id.name, - metadata={"odoo_subscription_id": self.id}, + email=self.env.user.email, + name=self.env.user.name, + metadata={"odoo_subscription": self.id}, ) self.stripe_customer = customer["id"] return self.stripe_customer diff --git a/recurring_payments_stripe/security/ir.model.access.csv b/recurring_payments_stripe/security/ir.model.access.csv deleted file mode 100644 index 1b4b0ce2a6..0000000000 --- a/recurring_payments_stripe/security/ir.model.access.csv +++ /dev/null @@ -1,2 +0,0 @@ -id,name,model_id/id,group_id/id,perm_read,perm_write,perm_create,perm_unlink -access_sale_subscription_payment_wizard_manager,sale_subscription_payment_wizard_manager,model_sale_subscription_payment_wizard,,1,1,1,1 diff --git a/recurring_payments_stripe/views/sale_subscription_views.xml b/recurring_payments_stripe/views/sale_subscription_views.xml index a223bbb835..e00c2949fb 100644 --- a/recurring_payments_stripe/views/sale_subscription_views.xml +++ b/recurring_payments_stripe/views/sale_subscription_views.xml @@ -9,7 +9,7 @@ - + diff --git a/recurring_payments_stripe/wizard/__init__.py b/recurring_payments_stripe/wizard/__init__.py deleted file mode 100644 index 15e249b83d..0000000000 --- a/recurring_payments_stripe/wizard/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -# -*- coding: utf-8 -*- -from . import sale_subscription_payment_wizard diff --git a/recurring_payments_stripe/wizard/sale_subscription_payment_wizard.py b/recurring_payments_stripe/wizard/sale_subscription_payment_wizard.py deleted file mode 100644 index 7dbcf3da1a..0000000000 --- a/recurring_payments_stripe/wizard/sale_subscription_payment_wizard.py +++ /dev/null @@ -1,72 +0,0 @@ -from odoo import models, fields, api -from odoo.exceptions import UserError -import stripe - - -class SaleSubscriptionPaymentWizard(models.TransientModel): - _name = "sale.subscription.payment.wizard" - _description = "Wizard para Tokenizar Método de Pago de Suscripción" - - subscription_id = fields.Many2one( - "sale.subscription", string="Suscripción", required=True - ) - card_number = fields.Char(string="Número de Tarjeta", required=True) - card_exp_month = fields.Char(string="Mes de Expiración (MM)", required=True) - card_exp_year = fields.Char(string="Año de Expiración (YYYY)", required=True) - card_cvc = fields.Char(string="CVC", required=True) - - @api.model - def default_get(self, fields): - res = super(SaleSubscriptionPaymentWizard, self).default_get(fields) - subscription_id = self.env.context.get("active_id") - if subscription_id: - res["subscription_id"] = subscription_id - return res - - def action_create_token(self): - """Crea un token en Stripe usando los datos de la tarjeta y lo guarda en la suscripción.""" - provider = self.env["payment.provider"].search( - [("code", "=", "stripe")], - ) - stripe.api_key = provider.stripe_secret_key - - # Intenta crear un token en Stripe - try: - token = stripe.Token.create( - card={ - "number": self.card_number, - "exp_month": self.card_exp_month, - "exp_year": self.card_exp_year, - "cvc": self.card_cvc, - }, - ) - - # Vincular el token de tarjeta con el cliente en Stripe - subscription = self.subscription_id - if not subscription.stripe_customer: - customer = stripe.Customer.create( - email=subscription.partner_id.email, - name=subscription.partner_id.name, - ) - subscription.stripe_customer = customer["id"] - - # Crear y vincular el método de pago a la suscripción - payment_method = stripe.PaymentMethod.create( - type="card", - card={"token": token.id}, - ) - stripe.PaymentMethod.attach( - payment_method.id, customer=subscription.stripe_customer - ) - stripe.Customer.modify( - subscription.stripe_customer, - invoice_settings={"default_payment_method": payment_method.id}, - ) - - # Guardar detalles del método de pago en la suscripción - subscription.stripe_payment_method_id = payment_method.id - subscription.card_last4 = token.card.last4 - subscription.card_brand = token.card.brand - - except stripe.error.StripeError as e: - raise UserError(f"Error en Stripe: {e.user_message or str(e)}") diff --git a/recurring_payments_stripe/wizard/sale_subscription_payment_wizard.xml b/recurring_payments_stripe/wizard/sale_subscription_payment_wizard.xml deleted file mode 100644 index c174291520..0000000000 --- a/recurring_payments_stripe/wizard/sale_subscription_payment_wizard.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - sale.subscription.payment.wizard.form - sale.subscription.payment.wizard - -
- - - - - - - -
-
-
-
-
- - - - Sale Subscription Payment Wizard - ir.actions.act_window - sale.subscription.payment.wizard - form - - new - - -
From e72ee4b3df4f19a56222b3862449d6a8b7801e51 Mon Sep 17 00:00:00 2001 From: mjavint Date: Thu, 28 Nov 2024 15:00:56 -0500 Subject: [PATCH 3/4] [FIX] Resolved all suggestion --- recurring_payments_stripe/__manifest__.py | 1 - recurring_payments_stripe/data/ir_cron.xml | 3 +- .../models/account_move.py | 125 ++++-------------- .../models/sale_subscription.py | 48 ++++--- .../views/sale_subscription_views.xml | 6 +- 5 files changed, 53 insertions(+), 130 deletions(-) diff --git a/recurring_payments_stripe/__manifest__.py b/recurring_payments_stripe/__manifest__.py index d5245e666a..bca6e36757 100644 --- a/recurring_payments_stripe/__manifest__.py +++ b/recurring_payments_stripe/__manifest__.py @@ -12,7 +12,6 @@ "views/sale_subscription_views.xml", "data/ir_cron.xml", ], - "application": True, "installable": True, "auto_install": False, } diff --git a/recurring_payments_stripe/data/ir_cron.xml b/recurring_payments_stripe/data/ir_cron.xml index b33eeb57bf..d6580b1969 100644 --- a/recurring_payments_stripe/data/ir_cron.xml +++ b/recurring_payments_stripe/data/ir_cron.xml @@ -2,8 +2,7 @@ - Procesar Facturas Vencidas para Suscripciones - Recurrentes + Process Overdue Invoices for Subscriptions code model.cron_process_due_invoices() diff --git a/recurring_payments_stripe/models/account_move.py b/recurring_payments_stripe/models/account_move.py index cc1bec6ac0..2535853585 100644 --- a/recurring_payments_stripe/models/account_move.py +++ b/recurring_payments_stripe/models/account_move.py @@ -1,10 +1,9 @@ # -*- coding: utf-8 -*- import logging import stripe -from datetime import date -from odoo import models, fields, api, _ -from odoo.exceptions import UserError, ValidationError +from odoo import models, api +from odoo.exceptions import UserError _logger = logging.getLogger(__name__) @@ -12,82 +11,24 @@ class AccountMove(models.Model): _inherit = "account.move" - # def stripe_pay_invoice(self): - # """Paga la factura en Stripe si `is_recurrent` está activado en la suscripción.""" - # for invoice in self: - # subscription = invoice.invoice_date and self.env[ - # "sale.subscription" - # ].search([("code", "=", invoice.invoice_date)], limit=1) - # if ( - # subscription - # and subscription.is_recurrent - # and subscription.stripe_customer - # ): - # provider = self.env["payment.provider"].search( - # [("code", "=", "stripe")], - # ) - # stripe.api_key = provider.stripe_secret_key - # token = self.env["payment.token"].search( - # [("provider_id", "=", provider.id)] - # ) - # try: - # # Crea un PaymentIntent en Stripe para el monto de la factura - # payment_intent = stripe.PaymentIntent.create( - # # Stripe maneja montos en centavos - # amount=int(invoice.amount_total * 100), - # currency=invoice.currency_id.name.lower(), - # customer=token.provider_ref, - # payment_method=token.stripe_payment_method, - # payment_method_types=["card"], - # # Para pagos automáticos sin intervención del usuario - # off_session=True, - # # Confirmar el PaymentIntent inmediatamente - # confirm=True, - # metadata={"odoo_invoice_id": invoice.id}, - # ) - - # # Confirmar el pago y actualizar el estado de la factura en Odoo - # if payment_intent["status"] == "succeeded": - # invoice.action_post() - # invoice.payment_state = "paid" - # else: - # raise Exception( - # f"Error en el pago de Stripe: {payment_intent['status']}" - # ) - - # except stripe.StripeError as e: - # raise UserError(f"Stripe error: {e.user_message or str(e)}") - - # def action_post(self): - # """Sobreescribe el método `action_post` para procesar el pago automático si `is_recurrent` está activo.""" - # res = super(AccountMove, self).action_post() - # for invoice in self: - # subscription = self.env["sale.subscription"].search( - # [("code", "=", invoice.invoice_date)], limit=1 - # ) - # if subscription and subscription.is_recurrent: - # invoice.stripe_pay_invoice() - # return res - def action_register_payment(self): - """Sobreescribe `action_register_payment` para procesar automáticamente el pago con Stripe en suscripciones.""" + """ + Override `action_register_payment` to automatically process Stripe + payment on subscriptions. + """ for invoice in self: - # Buscar la suscripción asociada a la factura, si existe - subscription = self.env["sale.subscription"].search( - [("code", "=", invoice.invoice_origin)], limit=1 - ) + # Find the subscription associated with the invoice, if it exists + subscription = invoice.subscription_id - # Verificar si la suscripción es recurrente y tiene método de pago en Stripe - if subscription and subscription.is_recurrent: - provider = self.env["payment.provider"].search( - [("code", "=", "stripe")], - ) + # Check if the subscription is recurring and has a payment method + if subscription and subscription.charge_automatically: + provider = subscription.provider_id stripe.api_key = provider.stripe_secret_key token = self.env["payment.token"].search( [("provider_id", "=", provider.id)] ) try: - # Crear el PaymentIntent en Stripe y confirmarlo inmediatamente + # Create the PaymentIntent and confirm it immediately payment_intent = stripe.PaymentIntent.create( # Stripe usa centavos amount=int(invoice.amount_total * 100), @@ -98,12 +39,12 @@ def action_register_payment(self): off_session=True, # Confirmar el PaymentIntent inmediatamente confirm=True, - metadata={"odoo_invoice_id": invoice.id}, + metadata={"odoo_invoice_id": str(invoice.id)}, ) # Manejar el resultado del PaymentIntent if payment_intent["status"] == "succeeded": - # Si el pago es exitoso, registrar el pago en la factura + # If the payment is successful, record the payment on the invoice Payment = self.env["account.payment"].sudo() payment_vals = { "journal_id": self.env["account.journal"] @@ -123,47 +64,31 @@ def action_register_payment(self): invoice.payment_state = "paid" elif payment_intent["status"] == "requires_action": raise UserError( - "El pago requiere autenticación adicional (3D Secure)." + "Payment requires additional authentication (3D Secure)." ) else: raise UserError( - f"Error en el pago de Stripe: {payment_intent['status']}" + f"Stripe payment error: {payment_intent['status']}" ) except stripe.StripeError as e: - raise UserError(f"Error de Stripe: {e.user_message or str(e)}") + raise UserError(f"Stripe error: {e.user_message or str(e)}") else: - # Si no es una suscripción recurrente o no tiene método de pago en Stripe, llama al método original return super(AccountMove, self).action_register_payment() @api.model def cron_process_due_invoices(self): - """Procesa el pago de facturas vencidas para suscripciones recurrentes.""" - # Obtener la fecha de hoy - today = date.today() - - # Buscar facturas de suscripciones recurrentes que vencen hoy y están abiertas - invoices = self.search( - [ - ("state", "=", "posted"), - ("payment_state", "=", "not_paid"), - ] - ) + """Process payment of overdue invoices for recurring subscriptions.""" - for invoice in invoices: - # Buscar la suscripción asociada a la factura - subscription = self.env["sale.subscription"].search( - [("code", "=", invoice.invoice_origin)], limit=1 - ) + for invoice in self: + # Find the subscription associated with the invoice + subscription = invoice.subscription_id - # Verificar si es una suscripción recurrente con Stripe - if subscription and subscription.is_recurrent: + # Check if it's a recurring subscription with Stripe + if subscription and subscription.charge_automatically: try: - # Intentar registrar el pago en la factura + # Register the payment invoice.action_register_payment() except Exception as e: - # Capturar excepciones en caso de error en el registro de pago - _logger.error( - f"Error al procesar el pago de la factura {invoice.id}: {str(e)}" - ) + _logger.error(f"Error Processing Due Invoices: {str(e)}") diff --git a/recurring_payments_stripe/models/sale_subscription.py b/recurring_payments_stripe/models/sale_subscription.py index d03a64cb0c..30bef18952 100644 --- a/recurring_payments_stripe/models/sale_subscription.py +++ b/recurring_payments_stripe/models/sale_subscription.py @@ -1,38 +1,36 @@ # -*- coding: utf-8 -*- -import logging import stripe -from odoo import models, fields, api, _ -from odoo.exceptions import UserError, ValidationError - -_logger = logging.getLogger(__name__) +from odoo import models, fields, api class SaleSubscription(models.Model): _inherit = "sale.subscription" - is_recurrent = fields.Boolean(string="Pago Automático Recurrente") - # ID del cliente en Stripe + charge_automatically = fields.Boolean(string="Charge Automatically") stripe_customer = fields.Char(string="Stripe Customer ID") + provider_id = fields.Many2one( + string="Provider_id", + domain=[("code", "=", "stripe")], + comodel_name="payment.provider", + ) def create_stripe_customer(self): - """Crea o recupera el cliente de Stripe asociado a la suscripción.""" - provider = self.env["payment.provider"].search( - [("code", "=", "stripe")], - ) - stripe.api_key = provider.stripe_secret_key - - if not self.stripe_customer: - customer = stripe.Customer.create( - email=self.env.user.email, - name=self.env.user.name, - metadata={"odoo_subscription": self.id}, - ) - self.stripe_customer = customer["id"] - return self.stripe_customer - - @api.onchange("is_recurrent") - def _onchange_is_recurrent(self): + provider = self.provider_id + if provider: + stripe.api_key = provider.stripe_secret_key + + if not self.stripe_customer: + customer = stripe.Customer.create( + email=self.env.user.email, + name=self.env.user.name, + metadata={"odoo_subscription": str(self.id)}, + ) + self.stripe_customer = customer["id"] + return self.stripe_customer + + @api.onchange("charge_automatically") + def _onchange_charge_automatically(self): for record in self: - if record.is_recurrent: + if record.charge_automatically: record.create_stripe_customer() diff --git a/recurring_payments_stripe/views/sale_subscription_views.xml b/recurring_payments_stripe/views/sale_subscription_views.xml index e00c2949fb..dfca8d901b 100644 --- a/recurring_payments_stripe/views/sale_subscription_views.xml +++ b/recurring_payments_stripe/views/sale_subscription_views.xml @@ -8,8 +8,10 @@ - - + + From ea7a9b2dd1f08f17d7b199492f59657c5827cd78 Mon Sep 17 00:00:00 2001 From: mjavint Date: Thu, 28 Nov 2024 15:51:41 -0500 Subject: [PATCH 4/4] [ADD] Add precommit rules --- contract_sale/README.rst | 2 +- contract_sale/readme/CONFIGURE.rst | 0 contract_sale/readme/CREDITS.rst | 0 contract_sale/readme/DEVELOP.rst | 0 contract_sale/readme/HISTORY.rst | 0 contract_sale/readme/INSTALL.rst | 0 contract_sale/readme/ROADMAP.rst | 0 contract_sale/static/description/index.html | 13 +- recurring_payments_stripe/README.rst | 70 +++ recurring_payments_stripe/__init__.py | 1 - recurring_payments_stripe/__manifest__.py | 1 - recurring_payments_stripe/data/ir_cron.xml | 26 +- recurring_payments_stripe/models/__init__.py | 1 - .../models/account_move.py | 4 +- .../models/sale_subscription.py | 3 +- .../readme/CONFIGURE.rst | 0 .../readme/CONTRIBUTORS.rst | 0 recurring_payments_stripe/readme/CREDITS.rst | 0 .../readme/DESCRIPTION.rst | 0 recurring_payments_stripe/readme/DEVELOP.rst | 0 recurring_payments_stripe/readme/HISTORY.rst | 0 recurring_payments_stripe/readme/INSTALL.rst | 0 recurring_payments_stripe/readme/ROADMAP.rst | 0 recurring_payments_stripe/readme/USAGE.rst | 0 .../static/description/index.html | 415 ++++++++++++++++++ .../views/sale_subscription_views.xml | 8 +- .../odoo/addons/recurring_payments_stripe | 1 + setup/recurring_payments_stripe/setup.py | 6 + 28 files changed, 521 insertions(+), 30 deletions(-) create mode 100644 contract_sale/readme/CONFIGURE.rst create mode 100644 contract_sale/readme/CREDITS.rst create mode 100644 contract_sale/readme/DEVELOP.rst create mode 100644 contract_sale/readme/HISTORY.rst create mode 100644 contract_sale/readme/INSTALL.rst create mode 100644 contract_sale/readme/ROADMAP.rst create mode 100644 recurring_payments_stripe/README.rst create mode 100644 recurring_payments_stripe/readme/CONFIGURE.rst create mode 100644 recurring_payments_stripe/readme/CONTRIBUTORS.rst create mode 100644 recurring_payments_stripe/readme/CREDITS.rst create mode 100644 recurring_payments_stripe/readme/DESCRIPTION.rst create mode 100644 recurring_payments_stripe/readme/DEVELOP.rst create mode 100644 recurring_payments_stripe/readme/HISTORY.rst create mode 100644 recurring_payments_stripe/readme/INSTALL.rst create mode 100644 recurring_payments_stripe/readme/ROADMAP.rst create mode 100644 recurring_payments_stripe/readme/USAGE.rst create mode 100644 recurring_payments_stripe/static/description/index.html create mode 120000 setup/recurring_payments_stripe/odoo/addons/recurring_payments_stripe create mode 100644 setup/recurring_payments_stripe/setup.py diff --git a/contract_sale/README.rst b/contract_sale/README.rst index e125136f45..2930853090 100644 --- a/contract_sale/README.rst +++ b/contract_sale/README.rst @@ -7,7 +7,7 @@ Contract from Sale !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !! source digest: sha256:00fb3cdc565442ffcd3351e97d0516ce6f4ceb55402981b183f7e717a1e23173 + !! source digest: sha256:c2e49dd78cebc553bbe7e5bfa2c8658e29e120878e688512e9599b43144815dd !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png diff --git a/contract_sale/readme/CONFIGURE.rst b/contract_sale/readme/CONFIGURE.rst new file mode 100644 index 0000000000..e69de29bb2 diff --git a/contract_sale/readme/CREDITS.rst b/contract_sale/readme/CREDITS.rst new file mode 100644 index 0000000000..e69de29bb2 diff --git a/contract_sale/readme/DEVELOP.rst b/contract_sale/readme/DEVELOP.rst new file mode 100644 index 0000000000..e69de29bb2 diff --git a/contract_sale/readme/HISTORY.rst b/contract_sale/readme/HISTORY.rst new file mode 100644 index 0000000000..e69de29bb2 diff --git a/contract_sale/readme/INSTALL.rst b/contract_sale/readme/INSTALL.rst new file mode 100644 index 0000000000..e69de29bb2 diff --git a/contract_sale/readme/ROADMAP.rst b/contract_sale/readme/ROADMAP.rst new file mode 100644 index 0000000000..e69de29bb2 diff --git a/contract_sale/static/description/index.html b/contract_sale/static/description/index.html index 2fec06806d..c4924509c2 100644 --- a/contract_sale/static/description/index.html +++ b/contract_sale/static/description/index.html @@ -8,10 +8,11 @@ /* :Author: David Goodger (goodger@python.org) -:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $ +:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $ :Copyright: This stylesheet has been placed in the public domain. Default cascading style sheet for the HTML output of Docutils. +Despite the name, some widely supported CSS2 features are used. See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to customize this style sheet. @@ -274,7 +275,7 @@ margin-left: 2em ; margin-right: 2em } -pre.code .ln { color: grey; } /* line numbers */ +pre.code .ln { color: gray; } /* line numbers */ pre.code, code { background-color: #eeeeee } pre.code .comment, code .comment { color: #5C6576 } pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold } @@ -300,7 +301,7 @@ span.pre { white-space: pre } -span.problematic { +span.problematic, pre.problematic { color: red } span.section-subtitle { @@ -366,7 +367,7 @@

Contract from Sale

!! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -!! source digest: sha256:00fb3cdc565442ffcd3351e97d0516ce6f4ceb55402981b183f7e717a1e23173 +!! source digest: sha256:c2e49dd78cebc553bbe7e5bfa2c8658e29e120878e688512e9599b43144815dd !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->

Production/Stable License: AGPL-3 OCA/contract Translate me on Weblate Try me on Runboat

This module allows access to contracts for sale employees without account @@ -428,7 +429,9 @@

Contributors

Maintainers

This module is maintained by the OCA.

-Odoo Community Association + +Odoo Community Association +

OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.

diff --git a/recurring_payments_stripe/README.rst b/recurring_payments_stripe/README.rst new file mode 100644 index 0000000000..31fcb6beb7 --- /dev/null +++ b/recurring_payments_stripe/README.rst @@ -0,0 +1,70 @@ +============================== +Recurring Payments with Stripe +============================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:7aacc5b46917b14e43404143f0ccd1519d1411d580330b8eb8a8ef608fe3a5a1 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fcontract-lightgray.png?logo=github + :target: https://github.com/OCA/contract/tree/16.0/recurring_payments_stripe + :alt: OCA/contract +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/contract-16-0/contract-16-0-recurring_payments_stripe + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/contract&target_branch=16.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + + +**Table of contents** + +.. contents:: + :local: + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Binhex + +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +This module is part of the `OCA/contract `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/recurring_payments_stripe/__init__.py b/recurring_payments_stripe/__init__.py index a0fdc10fe1..0650744f6b 100644 --- a/recurring_payments_stripe/__init__.py +++ b/recurring_payments_stripe/__init__.py @@ -1,2 +1 @@ -# -*- coding: utf-8 -*- from . import models diff --git a/recurring_payments_stripe/__manifest__.py b/recurring_payments_stripe/__manifest__.py index bca6e36757..ca812198c9 100644 --- a/recurring_payments_stripe/__manifest__.py +++ b/recurring_payments_stripe/__manifest__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- { "name": "Recurring Payments with Stripe", "version": "16.0.1.0.0", diff --git a/recurring_payments_stripe/data/ir_cron.xml b/recurring_payments_stripe/data/ir_cron.xml index d6580b1969..ff41276318 100644 --- a/recurring_payments_stripe/data/ir_cron.xml +++ b/recurring_payments_stripe/data/ir_cron.xml @@ -1,15 +1,13 @@ - - - - - Process Overdue Invoices for Subscriptions - - code - model.cron_process_due_invoices() - 1 - days - -1 - True - - + + + + Process Overdue Invoices for Subscriptions + + code + model.cron_process_due_invoices() + 1 + days + -1 + True + diff --git a/recurring_payments_stripe/models/__init__.py b/recurring_payments_stripe/models/__init__.py index 82c93204e4..fe83caa1a8 100644 --- a/recurring_payments_stripe/models/__init__.py +++ b/recurring_payments_stripe/models/__init__.py @@ -1,3 +1,2 @@ -# -*- coding: utf-8 -*- from . import sale_subscription from . import account_move diff --git a/recurring_payments_stripe/models/account_move.py b/recurring_payments_stripe/models/account_move.py index 2535853585..14d29e011e 100644 --- a/recurring_payments_stripe/models/account_move.py +++ b/recurring_payments_stripe/models/account_move.py @@ -1,8 +1,8 @@ -# -*- coding: utf-8 -*- import logging + import stripe -from odoo import models, api +from odoo import api, models from odoo.exceptions import UserError _logger = logging.getLogger(__name__) diff --git a/recurring_payments_stripe/models/sale_subscription.py b/recurring_payments_stripe/models/sale_subscription.py index 30bef18952..ccc60eaf70 100644 --- a/recurring_payments_stripe/models/sale_subscription.py +++ b/recurring_payments_stripe/models/sale_subscription.py @@ -1,7 +1,6 @@ -# -*- coding: utf-8 -*- import stripe -from odoo import models, fields, api +from odoo import api, fields, models class SaleSubscription(models.Model): diff --git a/recurring_payments_stripe/readme/CONFIGURE.rst b/recurring_payments_stripe/readme/CONFIGURE.rst new file mode 100644 index 0000000000..e69de29bb2 diff --git a/recurring_payments_stripe/readme/CONTRIBUTORS.rst b/recurring_payments_stripe/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000000..e69de29bb2 diff --git a/recurring_payments_stripe/readme/CREDITS.rst b/recurring_payments_stripe/readme/CREDITS.rst new file mode 100644 index 0000000000..e69de29bb2 diff --git a/recurring_payments_stripe/readme/DESCRIPTION.rst b/recurring_payments_stripe/readme/DESCRIPTION.rst new file mode 100644 index 0000000000..e69de29bb2 diff --git a/recurring_payments_stripe/readme/DEVELOP.rst b/recurring_payments_stripe/readme/DEVELOP.rst new file mode 100644 index 0000000000..e69de29bb2 diff --git a/recurring_payments_stripe/readme/HISTORY.rst b/recurring_payments_stripe/readme/HISTORY.rst new file mode 100644 index 0000000000..e69de29bb2 diff --git a/recurring_payments_stripe/readme/INSTALL.rst b/recurring_payments_stripe/readme/INSTALL.rst new file mode 100644 index 0000000000..e69de29bb2 diff --git a/recurring_payments_stripe/readme/ROADMAP.rst b/recurring_payments_stripe/readme/ROADMAP.rst new file mode 100644 index 0000000000..e69de29bb2 diff --git a/recurring_payments_stripe/readme/USAGE.rst b/recurring_payments_stripe/readme/USAGE.rst new file mode 100644 index 0000000000..e69de29bb2 diff --git a/recurring_payments_stripe/static/description/index.html b/recurring_payments_stripe/static/description/index.html new file mode 100644 index 0000000000..d9629f4109 --- /dev/null +++ b/recurring_payments_stripe/static/description/index.html @@ -0,0 +1,415 @@ + + + + + +Recurring Payments with Stripe + + + +
+

Recurring Payments with Stripe

+ + +

Beta License: AGPL-3 OCA/contract Translate me on Weblate Try me on Runboat

+

Table of contents

+ +
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Binhex
  • +
+
+
+

Maintainers

+

This module is maintained by the OCA.

+ +Odoo Community Association + +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

This module is part of the OCA/contract project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/recurring_payments_stripe/views/sale_subscription_views.xml b/recurring_payments_stripe/views/sale_subscription_views.xml index dfca8d901b..bdfc7c87c0 100644 --- a/recurring_payments_stripe/views/sale_subscription_views.xml +++ b/recurring_payments_stripe/views/sale_subscription_views.xml @@ -1,4 +1,4 @@ - + @@ -9,9 +9,11 @@ - + attrs="{'invisible': [('charge_automatically', '=', False)]}" + /> diff --git a/setup/recurring_payments_stripe/odoo/addons/recurring_payments_stripe b/setup/recurring_payments_stripe/odoo/addons/recurring_payments_stripe new file mode 120000 index 0000000000..0bdeb61a53 --- /dev/null +++ b/setup/recurring_payments_stripe/odoo/addons/recurring_payments_stripe @@ -0,0 +1 @@ +../../../../recurring_payments_stripe \ No newline at end of file diff --git a/setup/recurring_payments_stripe/setup.py b/setup/recurring_payments_stripe/setup.py new file mode 100644 index 0000000000..28c57bb640 --- /dev/null +++ b/setup/recurring_payments_stripe/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)