-
-
Notifications
You must be signed in to change notification settings - Fork 987
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
244 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg | ||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html | ||
:alt: License: AGPL-3 | ||
|
||
====================================== | ||
Sale Payment Method - Payment Acquirer | ||
====================================== | ||
|
||
* this module adds acquirer_id to sale payment method and links between them | ||
|
||
Installation | ||
============ | ||
|
||
* No thing is required to install this module | ||
|
||
Usage | ||
===== | ||
|
||
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas | ||
:alt: Try me on Runbot | ||
:target: https://runbot.odoo-community.org/runbot/167/8.0 | ||
|
||
Contributors | ||
------------ | ||
|
||
* Katja Matthes <katja.matthes@initos.com> | ||
* Rami Alwafaie <rami.alwafaie@initos.com> | ||
|
||
Sponsors | ||
-------- | ||
|
||
* Sponsored by Nitrokey: www.nitrokey.com | ||
|
||
Maintainer | ||
---------- | ||
|
||
.. image:: https://odoo-community.org/logo.png | ||
:alt: Odoo Community Association | ||
:target: https://odoo-community.org | ||
|
||
This module is maintained by the OCA. | ||
|
||
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. | ||
|
||
To contribute to this module, please visit https://odoo-community.org. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# -*- coding: utf-8 -*- | ||
# © initOS GmbH 2016 | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from . import payment_method | ||
from . import payment_acquirer | ||
from . import payment_transaction | ||
from . import sale | ||
from . import controller |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# -*- coding: utf-8 -*- | ||
# © initOS GmbH 2016 | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
{ | ||
"name": "Sale Payment Method - Payment Acquirer", | ||
"version": "8.0.1.0.0", | ||
"depends": ["payment", | ||
"sale_payment_method", | ||
"sale", | ||
"website_sale", | ||
], | ||
'author': 'initOS GmbH, Odoo Community Association (OCA)', | ||
"category": "", | ||
"summary": "", | ||
'license': 'AGPL-3', | ||
'data': ['payment_method_view.xml', | ||
'payment_acquirer_view.xml', | ||
'sale_view.xml', | ||
], | ||
'images': [], | ||
'demo': [ | ||
], | ||
'test': [ | ||
], | ||
'installable': True, | ||
'auto_install': False, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# -*- coding: utf-8 -*- | ||
# © initOS GmbH 2016 | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from openerp.addons.website_sale.controllers.main import website_sale | ||
from openerp import http | ||
from openerp.http import request | ||
|
||
|
||
class website_sale_customization(website_sale): | ||
|
||
# change the payment method if we choose the acquirer id from the website | ||
@http.route(['/shop/payment/transaction/<int:acquirer_id>'], | ||
type='json', auth="public", website=True) | ||
def payment_transaction(self, acquirer_id): | ||
|
||
res = super(website_sale_customization, self).\ | ||
payment_transaction(acquirer_id) | ||
if acquirer_id: | ||
context, registry = request.context | ||
order = request.website.sale_get_order(context=context) | ||
order.onchange_payment_acquirer_id() | ||
order.onchange_payment_method_set_workflow() | ||
return res |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# -*- coding: utf-8 -*- | ||
# © initOS GmbH 2016 | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from openerp import models, fields | ||
|
||
|
||
class PaymentAcquirer(models.Model): | ||
_inherit = 'payment.acquirer' | ||
|
||
payment_method_id = fields.Many2one('payment.method', | ||
'Payment Method', | ||
) |
15 changes: 15 additions & 0 deletions
15
sale_payment_method_payment_acquirer/payment_acquirer_view.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<openerp> | ||
<data noupdate="0"> | ||
<record id="payment_acquirer_view_form" model="ir.ui.view"> | ||
<field name="name">paymennt.acquirer.extension_method.view_form</field> | ||
<field name="model">payment.acquirer</field> | ||
<field name="inherit_id" ref="payment.acquirer_form" /> | ||
<field name="arch" type="xml"> | ||
<field name="validation" position="after"> | ||
<field name="payment_method_id" /> | ||
</field> | ||
</field> | ||
</record> | ||
</data> | ||
</openerp> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# -*- coding: utf-8 -*- | ||
# © initOS GmbH 2016 | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from openerp import models, fields | ||
|
||
|
||
class PaymentMethod(models.Model): | ||
_inherit = 'payment.method' | ||
|
||
acquirer_id = fields.One2many('payment.acquirer', | ||
'payment_method_id', | ||
'Acquirer', | ||
required=False,) |
26 changes: 26 additions & 0 deletions
26
sale_payment_method_payment_acquirer/payment_method_view.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<openerp> | ||
<data noupdate="0"> | ||
<record id="payment_method_acquirer_view_form" model="ir.ui.view"> | ||
<field name="name">sale.acquirer.extension_method.view_form</field> | ||
<field name="model">payment.method</field> | ||
<field name="inherit_id" ref="sale_payment_method.payment_method_view_form" /> | ||
<field name="arch" type="xml"> | ||
<field name="journal_id" position="after"> | ||
<field name="acquirer_id" readonly="1" /> | ||
</field> | ||
</field> | ||
</record> | ||
|
||
<record id="payment_method_acquirer_view_tree" model="ir.ui.view"> | ||
<field name="name">sale_acquirer_extension.payment_method.view_tree</field> | ||
<field name="model">payment.method</field> | ||
<field name="inherit_id" ref="sale_payment_method.payment_method_view_tree" /> | ||
<field name="arch" type="xml"> | ||
<field name="payment_term_id" position="after"> | ||
<field name="acquirer_id" readonly="1" /> | ||
</field> | ||
</field> | ||
</record> | ||
</data> | ||
</openerp> |
35 changes: 35 additions & 0 deletions
35
sale_payment_method_payment_acquirer/payment_transaction.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# -*- coding: utf-8 -*- | ||
# © initOS GmbH 2016 | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from openerp import models | ||
from openerp import SUPERUSER_ID | ||
|
||
|
||
class PaymentTransaction(models.Model): | ||
_inherit = 'payment.transaction' | ||
|
||
def form_feedback(self, cr, uid, data, acquirer_name, context=None): | ||
""" Override to create automatic payments for order, | ||
if transaction is done. """ | ||
|
||
res = super(PaymentTransaction, self).\ | ||
form_feedback(cr, uid, data, acquirer_name, context=context) | ||
# Order already confirmed. (cmp. module website_sale) | ||
|
||
tx = None | ||
# fetch the tx, check its state, confirm the potential SO | ||
tx_find_method_name = '_%s_form_get_tx_from_data' % acquirer_name | ||
if hasattr(self, tx_find_method_name): | ||
tx = getattr(self, tx_find_method_name)(cr, | ||
uid, | ||
data, | ||
context=context) | ||
if tx and tx.state == 'done' and tx.sale_order_id: | ||
self.pool['sale.order'].automatic_payment(cr, | ||
SUPERUSER_ID, | ||
[tx.sale_order_id.id], | ||
context=context, | ||
amount=tx.amount) | ||
|
||
return res |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# -*- coding: utf-8 -*- | ||
# © initOS GmbH 2016 | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from openerp import models, api | ||
|
||
|
||
class SaleOrder(models.Model): | ||
_inherit = 'sale.order' | ||
|
||
@api.onchange('payment_acquirer_id') | ||
def onchange_payment_acquirer_id(self): | ||
# change payment method according to payment_acquirer_id | ||
if not self.payment_acquirer_id: | ||
return | ||
method = self.payment_acquirer_id.payment_method_id | ||
if method: | ||
self.payment_method_id = method |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<openerp> | ||
<data noupdate="0"> | ||
<record id="sale_order_view_form2" model="ir.ui.view"> | ||
<field name="name">sale.order.view_form</field> | ||
<field name="model">sale.order</field> | ||
<field name="inherit_id" ref="sale_payment_method.sale_order_view_form" /> | ||
<field name="arch" type="xml"> | ||
<field name="payment_method_id" position="after"> | ||
<field name="payment_acquirer_id" /> | ||
</field> | ||
</field> | ||
</record> | ||
</data> | ||
</openerp> |