Skip to content

Commit

Permalink
Merge 2061884 into 1a31422
Browse files Browse the repository at this point in the history
  • Loading branch information
lepistone committed Dec 24, 2015
2 parents 1a31422 + 2061884 commit c943f0b
Show file tree
Hide file tree
Showing 8 changed files with 280 additions and 0 deletions.
80 changes: 80 additions & 0 deletions sale_quick_payment/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
.. 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 Quick Payment
==================

Sale Quick Payment gives the possibility to pay a sale order from the
sale order itself.

The payment will be linked to the sale order.

If you install the module Sale Automatic Workflow, you can forbid the
validation of an unpaid order and the invoice will be automatically
reconciled with the payment.

This module was originally designed for the e-commerce sector, but it
does not preclude to use it in other sectors.


Configuration
=============

To configure this module, you need to to configure the payment methods which
come from the `sale_payment_method` module.

Usage
=====

Use the "Register Payments" button on the sale order to flag the order as
paid.

.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/sale-workflow-167/8.0

For further information, please visit:

* https://www.odoo.com/forum/help-1

Known issues / Roadmap
======================

* none for now.

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
`here <https://github.com/OCA/sale-workflow/issues/new?body=module:%20sale_quick_payment%0Aversion:%208.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.


Credits
=======

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

* Sébastien BEAU <sebastien.beau@akretion.com>
* Guewen Baconnier <guewen.baconnier@camptocamp.com>
* Mart Raudsepp <mart@stipit.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 http://odoo-community.org.
22 changes: 22 additions & 0 deletions sale_quick_payment/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# sale_quick_payment for OpenERP
# Copyright (C) 2011 Akretion Sébastien BEAU <sebastien.beau@akretion.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################

from . import wizard
38 changes: 38 additions & 0 deletions sale_quick_payment/__openerp__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# sale_payment_method for OpenERP
# Copyright (C) 2011 Akretion Sébastien BEAU <sebastien.beau@akretion.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################


{
'name': 'Sale Quick Payment',
'version': '8.0.3.0.0',
'category': 'Generic Modules/Others',
'license': 'AGPL-3',
'author': "Akretion,Odoo Community Association (OCA)",
'website': 'http://www.akretion.com/',
'depends': ['sale_payment_method',
'sale_exceptions',
],
'data': ['wizard/pay_sale_order.xml',
'sale_view.xml',
'settings/sale.exception.csv',
],
'installable': True,
}
27 changes: 27 additions & 0 deletions sale_quick_payment/sale_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
sale_quick_payment for OpenERP
Copyright (C) 2011 Akretion Sébastien BEAU <sebastien.beau@akretion.com>
The licence is in the file __openerp__.py
-->

<openerp>
<data>

<!-- INHERITED VIEW FOR THE OBJECT : sale_order -->

<record id="sale_order_view_form" model="ir.ui.view">
<field name="name">sale_quick_payment.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">
<button name="print_quotation" position="after">
<button name="%(open_pay_sale_order)d"
string="Register Payments"
type="action" states="draft,sent"/>
</button>
</field>
</record>

</data>
</openerp>
3 changes: 3 additions & 0 deletions sale_quick_payment/settings/sale.exception.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
id,name,description,sequence,model,code
must_be_paid,Sale order must be paid before validation,The sale order must be paid before the validation. Please fix it,50,sale.order,"if order.residual > 0:
failed = True"
1 change: 1 addition & 0 deletions sale_quick_payment/wizard/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import pay_sale_order
74 changes: 74 additions & 0 deletions sale_quick_payment/wizard/pay_sale_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# sale_quick_payment for OpenERP
# Copyright (C) 2011 Akretion Sébastien BEAU <sebastien.beau@akretion.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################

from openerp import api, fields, models
import openerp.addons.decimal_precision as dp


class PaySaleOrder(models.TransientModel):
_name = 'pay.sale.order'
_description = 'Wizard to generate a payment from the sale order'

@api.model
def _default_journal_id(self):
context = self.env.context
if not context.get('active_id'):
return False
order = self.env['sale.order'].browse(context['active_id'])
if order.payment_method_id:
return order.payment_method_id.journal_id.id
return False

journal_id = fields.Many2one('account.journal', 'Journal',
default=_default_journal_id)

@api.model
def _default_amount(self):
context = self.env.context
if not context.get('active_id'):
return False
return self.env['sale.order'].browse(context['active_id']).residual

amount = fields.Float('Amount', digits=dp.get_precision('Sale Price'),
default=_default_amount)

date = fields.Datetime('Payment Date', default=fields.Datetime.now)

description = fields.Char('Description', size=64)

@api.multi
def pay_sale_order(self):
""" Pay the sale order """
self.ensure_one()
order = self.env['sale.order'].browse(self.env.context['active_id'])
order.add_payment(self.journal_id.id,
self.amount,
date=self.date,
description=self.description)
return True

@api.multi
def pay_sale_order_and_confirm(self):
""" Pay the sale order """
self.ensure_one()
self.pay_sale_order()
order = self.env['sale.order'].browse(self.env.context['active_id'])
return order.action_button_confirm()
35 changes: 35 additions & 0 deletions sale_quick_payment/wizard/pay_sale_order.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record model="ir.ui.view" id="pay_sale_order_view">
<field name="name">pay.sale.order.view</field>
<field name="model">pay.sale.order</field>
<field name="arch" type="xml">
<form string="Pay Sale Order" version="7.0">
<group>
<field name="description" string="Description"/>
<field name="journal_id" string="Journal"/>
<field name="amount" string="Paid Amount"/>
<field name="date" string="Date"/>
</group>
<footer>
<button string="Pay" name="pay_sale_order" type="object" class="oe_highlight"/>
or
<button string="Pay And Confirm Order" name="pay_sale_order_and_confirm" type="object" class="oe_highlight"/>
or
<button string="Cancel" class="oe_link" special="cancel"/>
</footer>
</form>
</field>
</record>

<record id="open_pay_sale_order" model="ir.actions.act_window">
<field name="name">Pay Sale Order</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">pay.sale.order</field>
<field name="view_type">form</field>
<field name="target">new</field>
<field name="view_id" ref="pay_sale_order_view"/>
</record>
</data>
</openerp>

0 comments on commit c943f0b

Please sign in to comment.