Carlos Dauden
8 years ago
6 changed files with 144 additions and 0 deletions
-
66partner_payment_return_risk/README.rst
-
3partner_payment_return_risk/__init__.py
-
19partner_payment_return_risk/__openerp__.py
-
3partner_payment_return_risk/models/__init__.py
-
33partner_payment_return_risk/models/res_partner.py
-
20partner_payment_return_risk/views/res_partner_view.xml
@ -0,0 +1,66 @@ |
|||
.. 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 |
|||
|
|||
=========================== |
|||
Partner Payment Return Risk |
|||
=========================== |
|||
|
|||
Extends Partner Financial Risk to manage payments returns. |
|||
|
|||
If any limit is exceed the partner gets forbidden to confirm sale orders. |
|||
|
|||
|
|||
Usage |
|||
===== |
|||
|
|||
To use this module, you need to: |
|||
|
|||
#. Go to *Customers > Financial Risk* |
|||
#. Set limits and choose options to compute in credit limit. |
|||
#. Create an invoice and pay it. |
|||
#. Create a payment return. |
|||
#. Go to *Sales -> Sales Orders* and create a new Sales Orders. |
|||
|
|||
|
|||
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas |
|||
:alt: Try me on Runbot |
|||
:target: https://runbot.odoo-community.org/runbot/134/9.0 |
|||
|
|||
|
|||
Bug Tracker |
|||
=========== |
|||
|
|||
Bugs are tracked on `GitHub Issues |
|||
<https://github.com/OCA/partner-contact/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 |
|||
======= |
|||
|
|||
Images |
|||
------ |
|||
|
|||
* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_. |
|||
|
|||
Contributors |
|||
------------ |
|||
|
|||
* Carlos Dauden - Tecnativa <carlos.dauden@tecnativa.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. |
@ -0,0 +1,3 @@ |
|||
# -*- coding: utf-8 -*- |
|||
|
|||
from . import models |
@ -0,0 +1,19 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# © 2016 Carlos Dauden - Tecnativa <carlos.dauden@tecnativa.com> |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
{ |
|||
'name': 'Partner Payment Return Risk', |
|||
'version': '9.0.1.0.0', |
|||
'author': 'Tecnativa, ' |
|||
'Odoo Community Association (OCA)', |
|||
'category': 'Sales Management', |
|||
'license': 'AGPL-3', |
|||
'depends': [ |
|||
'partner_financial_risk', |
|||
'account_payment_return', |
|||
], |
|||
'data': [ |
|||
'views/res_partner_view.xml', |
|||
], |
|||
'installable': True, |
|||
} |
@ -0,0 +1,3 @@ |
|||
# -*- coding: utf-8 -*- |
|||
|
|||
from . import res_partner |
@ -0,0 +1,33 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# © 2016 Carlos Dauden <carlos.dauden@tecnativa.com> |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
|
|||
from openerp import api, fields, models |
|||
|
|||
|
|||
class ResPartner(models.Model): |
|||
_inherit = 'res.partner' |
|||
|
|||
risk_payment_return_include = fields.Boolean( |
|||
string='Include Payments Returns', help='Full risk computation') |
|||
risk_payment_return_limit = fields.Monetary( |
|||
string='Limit Payments Returns', help='Set 0 if it is not locked') |
|||
risk_payment_return = fields.Monetary( |
|||
compute='_compute_risk_payment_return', store=True, |
|||
string='Total Returned Invoices', |
|||
help='Total returned invoices in Open state') |
|||
|
|||
@api.multi |
|||
@api.depends('invoice_ids.state', 'invoice_ids.returned_payment') |
|||
def _compute_risk_payment_return(self): |
|||
for partner in self: |
|||
invoices = partner.invoice_ids.filtered( |
|||
lambda x: x.returned_payment and x.state == 'open') |
|||
partner.risk_payment_return = sum(invoices.mapped('residual')) |
|||
|
|||
@api.model |
|||
def _risk_field_list(self): |
|||
res = super(ResPartner, self)._risk_field_list() |
|||
res.append(('risk_payment_return', 'risk_payment_return_limit', |
|||
'risk_payment_return_include')) |
|||
return res |
@ -0,0 +1,20 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<!-- © 2016 Carlos Dauden <carlos.dauden@tecnativa.com> |
|||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl-3). --> |
|||
<odoo> |
|||
<record id="res_partner_view_risk" model="ir.ui.view"> |
|||
<field name="model">res.partner</field> |
|||
<field name="inherit_id" ref="partner_financial_risk.res_partner_view_risk"/> |
|||
<field name="arch" type="xml"> |
|||
<field name="risk_invoice_unpaid" position="after"> |
|||
<field name="risk_payment_return_include" |
|||
attrs="{'readonly': [('risk_allow_edit', '=', False)]}"/> |
|||
<field name="risk_payment_return" nolabel="1"/> |
|||
</field> |
|||
<field name="risk_invoice_unpaid_limit" position="after"> |
|||
<field name="risk_payment_return_limit" |
|||
attrs="{'readonly': [('risk_allow_edit', '=', False)]}"/> |
|||
</field> |
|||
</field> |
|||
</record> |
|||
</odoo> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue