-
-
Notifications
You must be signed in to change notification settings - Fork 992
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
6 changed files
with
132 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,53 @@ | ||
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg | ||
:alt: License: AGPL-3 | ||
|
||
===================================================== | ||
Sale Payment Method - Selection for Automatic Payment | ||
===================================================== | ||
|
||
* Adds an selection to payment methods to configure when an automatic payment is allowed to be created. | ||
|
||
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 | ||
|
||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues | ||
<https://github.com/OCA/sale-workflow/issues>`_. In case of trouble, please | ||
check there if your issue has already been reported. If you spotted it first, | ||
help us smashing it by providing a detailed and welcomed feedback. | ||
|
||
Credits | ||
======= | ||
|
||
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,6 @@ | ||
# -*- coding: utf-8 -*- | ||
# © initOS GmbH 2016 | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from . import payment_method | ||
from . import sale |
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,16 @@ | ||
# -*- coding: utf-8 -*- | ||
# © initOS GmbH 2016 | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
{'name': 'Sale Payment Method - Selection for Automatic Payment', | ||
'version': '8.0.1.0.0', | ||
'category': '', | ||
'depends': ['sale_payment_method', | ||
], | ||
'author': "initOS GmbH, Odoo Community Association (OCA) ", | ||
'license': 'AGPL-3', | ||
'data': ['payment_method_view.xml', | ||
], | ||
'installable': True, | ||
'application': 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,22 @@ | ||
# -*- coding: utf-8 -*- | ||
# © initOS GmbH 2016 | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from openerp import models, api, fields, _ | ||
|
||
|
||
class PaymentMethod(models.Model): | ||
_inherit = 'payment.method' | ||
|
||
@api.model | ||
def _get_allow_automatic_payment_selection(self): | ||
return [('never', _('never')), | ||
('none', _('no limitation')), | ||
] | ||
|
||
allow_automatic_payment = fields.Selection( | ||
'_get_allow_automatic_payment_selection', | ||
string='Allow Automatic Payment', | ||
default='none', | ||
required=True, | ||
) |
15 changes: 15 additions & 0 deletions
15
sale_payment_method_auto_pay_selection/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,15 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<openerp> | ||
<data> | ||
<record id="payment_method_view_form" model="ir.ui.view"> | ||
<field name="name">sale_payment_method.payment_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="allow_automatic_payment"/> | ||
</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,20 @@ | ||
# -*- 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.multi | ||
def automatic_payment(self, amount=None): | ||
""" Add some limitations to the creation of automatic_payments. | ||
""" | ||
self.ensure_one() | ||
# do nothing when it isn't allow | ||
if self.payment_method_id\ | ||
and self.payment_method_id.allow_automatic_payment == 'never': | ||
return True | ||
return super(SaleOrder, self).automatic_payment(amount=amount) |