Skip to content

Commit

Permalink
Merge adcec75 into 8e9d44d
Browse files Browse the repository at this point in the history
  • Loading branch information
rami-wafaie committed Aug 1, 2016
2 parents 8e9d44d + adcec75 commit c3fd273
Show file tree
Hide file tree
Showing 19 changed files with 511 additions and 0 deletions.
35 changes: 35 additions & 0 deletions sale_payment_method_payment_acquirer/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
.. 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

Contributors
------------

* Katja Matthes <katja.matthes@initos.com>
* Rami Alwafaie <rami.alwafaie@initos.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.
9 changes: 9 additions & 0 deletions sale_payment_method_payment_acquirer/__init__.py
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
33 changes: 33 additions & 0 deletions sale_payment_method_payment_acquirer/__openerp__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# -*- 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',
"description": """
Sale Payment Method - Payment Acquirer
=======================================
* this module adds acquirer_id to sale payment method
""",
'data': ['payment_method_view.xml',
'payment_acquirer_view.xml',
'sale_view.xml',
],
'images': [],
'demo': [
],
'test': [
],
'installable': True,
'auto_install': False,
}
22 changes: 22 additions & 0 deletions sale_payment_method_payment_acquirer/controller.py
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.addons.website_sale.controllers.main import website_sale
from openerp import http
from openerp.http import request, route


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:
cr, uid, context, registry = request.cr, request.uid, request.context, request.registry
order = request.website.sale_get_order(context=context)
order.onchange_payment_acquirer_id()
order.onchange_payment_method_set_workflow()
return res
13 changes: 13 additions & 0 deletions sale_payment_method_payment_acquirer/payment_acquirer.py
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 sale_payment_method_payment_acquirer/payment_acquirer_view.xml
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>
14 changes: 14 additions & 0 deletions sale_payment_method_payment_acquirer/payment_method.py
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 sale_payment_method_payment_acquirer/payment_method_view.xml
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>
30 changes: 30 additions & 0 deletions sale_payment_method_payment_acquirer/payment_transaction.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# -*- 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
18 changes: 18 additions & 0 deletions sale_payment_method_payment_acquirer/sale.py
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
15 changes: 15 additions & 0 deletions sale_payment_method_payment_acquirer/sale_view.xml
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>
49 changes: 49 additions & 0 deletions stock_picking_on_hold/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:alt: License: AGPL-3

===================================================
Sale Payment Method - Hold Pickings (until payment)
===================================================

This module allows to hold the picking until the invoice is paid

Usage
=====

* go to ...
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/186/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
------------

* Thomas Rehn <thomas.rehn@initos.com>
* Katja Matthes <katja.matthes@initos.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.
7 changes: 7 additions & 0 deletions stock_picking_on_hold/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# -*- coding: utf-8 -*-
# © initOS GmbH 2016
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import account_invoice
from . import payment_method
from . import stock
24 changes: 24 additions & 0 deletions stock_picking_on_hold/__openerp__.py
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).

{'name': 'Sale Payment Method - Hold Pickings (until payment)',
'version': '1.0',
'category': 'Warehouse',
'description': """
Sale Payment Method - Hold Pickings (until payment)
===================================================
* This module allows to hold the picking until the invoice is paid
""",
'depends': ['stock',
'sale',
'sale_payment_method_automatic_workflow',
],
'author': "initOS GmbH, Odoo Community Association OCA",
'license': 'AGPL-3',
'data': ['views/stock.xml',
'views/payment_method.xml',
],
'installable': True,
'application': False,
}
27 changes: 27 additions & 0 deletions stock_picking_on_hold/account_invoice.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# -*- coding: utf-8 -*-
# © initOS GmbH 2016
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from openerp import models, api


class AccountInvoice(models.Model):
_inherit = 'account.invoice'

@api.multi
def confirm_paid(self):
"""
When an invoice is paid
a picking that is hold until payment may need a status check.
"""
res = super(AccountInvoice, self).confirm_paid()
# collect all pickings to check
pickings_to_check = self.env['stock.picking']
for invoice in self:
for sale in invoice.sale_ids:
for picking in sale.picking_ids:
if picking.state == 'hold':
pickings_to_check += picking
# trigger availability check
pickings_to_check.action_assign()
return res
15 changes: 15 additions & 0 deletions stock_picking_on_hold/payment_method.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# -*- 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'

hold_picking_until_payment = fields.Boolean(
string='Hold Picking Until Payment',
help="If set to true, pickings will not be automatically confirmed"
"when the invoice has not been paid."
)
Loading

0 comments on commit c3fd273

Please sign in to comment.