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
13 changed files
with
395 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,7 @@ | ||
# -*- coding: utf-8 -*- | ||
################################################################ | ||
# License, author and contributors information in: # | ||
# __openerp__.py file at the root folder of this module. # | ||
################################################################ | ||
|
||
from . import models |
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,43 @@ | ||
# -*- coding: utf-8 -*- | ||
############################################################################## | ||
# | ||
# Mandate module for openERP | ||
# Copyright (C) 2015 Anubía, soluciones en la nube,SL (http://www.anubia.es) | ||
# @author: Juan Formoso <jfv@anubia.es>, | ||
# | ||
# 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 Order Credit Limit Approval', | ||
'summary': 'Need of validation by responsible when sale order exceeds ' | ||
'credit limit', | ||
'version': '0.1', | ||
'license': 'AGPL-3', | ||
'author': 'Juan Formoso <jfv@anubia.es>', | ||
'website': 'http://www.anubia.es', | ||
'category': 'Sale', | ||
'depends': [ | ||
'sale', | ||
], | ||
'data': [ | ||
'views/res_partner_view.xml', | ||
'views/sale_view.xml', | ||
'views/sale_workflow.xml', | ||
], | ||
'demo': [], | ||
'test': [], | ||
'installable': True, | ||
} |
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,83 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * sale_order_credit_limit_approval | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 8.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2016-01-26 11:43+0000\n" | ||
"PO-Revision-Date: 2016-01-26 12:46+0100\n" | ||
"Last-Translator: <>\n" | ||
"Language-Team: \n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: 8bit\n" | ||
"Plural-Forms: \n" | ||
"X-Generator: Poedit 1.5.4\n" | ||
|
||
#. module: sale_order_credit_limit_approval | ||
#: view:sale.order:sale_order_credit_limit_approval.view_order_credit_limit_form | ||
msgid "Approve Sale" | ||
msgstr "Aprobar venta" | ||
|
||
#. module: sale_order_credit_limit_approval | ||
#: field:res.partner,available_credit:0 | ||
msgid "Available credit" | ||
msgstr "Crédito disponible" | ||
|
||
#. module: sale_order_credit_limit_approval | ||
#: view:sale.order:sale_order_credit_limit_approval.view_order_credit_limit_form | ||
msgid "Confirm Sale" | ||
msgstr "Confirmar venta" | ||
|
||
#. module: sale_order_credit_limit_approval | ||
#: code:addons/sale_order_credit_limit_approval/models/sale.py:40 | ||
#, python-format | ||
msgid "Contact credit limit exceeded." | ||
msgstr "El límite del crédito concedido del contacto ha sido sobrepasado." | ||
|
||
#. module: sale_order_credit_limit_approval | ||
#: view:sale.order:sale_order_credit_limit_approval.view_order_credit_limit_form | ||
msgid "Deny order" | ||
msgstr "Denegar venta" | ||
|
||
#. module: sale_order_credit_limit_approval | ||
#: model:ir.model,name:sale_order_credit_limit_approval.model_res_partner | ||
msgid "Partner" | ||
msgstr "Contacto" | ||
|
||
#. module: sale_order_credit_limit_approval | ||
#: model:ir.model,name:sale_order_credit_limit_approval.model_sale_order | ||
msgid "Sales Order" | ||
msgstr "Pedido de venta" | ||
|
||
#. module: sale_order_credit_limit_approval | ||
#: field:res.partner,set_credit_limit:0 | ||
msgid "Set credit limit" | ||
msgstr "Establecer crédito concedido" | ||
|
||
#. module: sale_order_credit_limit_approval | ||
#: view:sale.order:sale_order_credit_limit_approval.view_order_credit_limit_form | ||
msgid "Warning" | ||
msgstr "Aviso" | ||
|
||
#. module: sale_order_credit_limit_approval | ||
#: view:sale.order:sale_order_credit_limit_approval.view_order_credit_limit_form | ||
msgid "base.group_sale_manager" | ||
msgstr "" | ||
|
||
#. module: sale_order_credit_limit_approval | ||
#: view:sale.order:sale_order_credit_limit_approval.view_order_credit_limit_form | ||
msgid "oe_highlight" | ||
msgstr "" | ||
|
||
#. module: sale_order_credit_limit_approval | ||
#: view:sale.order:sale_order_credit_limit_approval.view_order_credit_limit_form | ||
msgid "waiting_for_approval" | ||
msgstr "" | ||
|
||
#. module: sale_order_credit_limit_approval | ||
#: view:res.partner:sale_order_credit_limit_approval.view_set_credit_limit_res_partner_form | ||
msgid "{'invisible': [('set_credit_limit', '=', False)]}" | ||
msgstr "" |
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,8 @@ | ||
# -*- coding: utf-8 -*- | ||
################################################################ | ||
# License, author and contributors information in: # | ||
# __openerp__.py file at the root folder of this module. # | ||
################################################################ | ||
|
||
from . import res_partner | ||
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,29 @@ | ||
# -*- coding: utf-8 -*- | ||
################################################################ | ||
# License, author and contributors information in: # | ||
# __openerp__.py file at the root folder of this module. # | ||
################################################################ | ||
|
||
from openerp import models, fields, api | ||
|
||
|
||
class ResPartner(models.Model): | ||
_inherit = 'res.partner' | ||
|
||
@api.multi | ||
@api.depends('credit', 'credit_limit') | ||
def _compute_available_credit(self): | ||
for partner in self: | ||
available_credit = partner.credit_limit - partner.credit | ||
if partner.set_credit_limit and available_credit > 0: | ||
partner.available_credit = available_credit | ||
|
||
set_credit_limit = fields.Boolean(string='Set credit limit') | ||
|
||
available_credit = fields.Float(string='Available credit', | ||
compute=_compute_available_credit) | ||
|
||
@api.onchange('set_credit_limit') | ||
def onchange_set_credit_limit(self): | ||
if not self.set_credit_limit: | ||
self.credit_limit = 0 |
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,48 @@ | ||
# -*- coding: utf-8 -*- | ||
################################################################ | ||
# License, author and contributors information in: # | ||
# __openerp__.py file at the root folder of this module. # | ||
################################################################ | ||
|
||
from openerp import models, fields, api, _ | ||
import logging | ||
_logger = logging.getLogger(__name__) | ||
|
||
|
||
class SaleOrder(models.Model): | ||
_inherit = 'sale.order' | ||
|
||
def _confirmation_is_allowed(self): | ||
self.ensure_one() | ||
if self.partner_id and self.partner_id.set_credit_limit and ( | ||
(self.amount_total + self.partner_id.credit) > | ||
self.partner_id.credit_limit): | ||
return False | ||
else: | ||
return True | ||
|
||
@api.multi | ||
@api.depends('amount_total', 'partner_id.credit', | ||
'partner_id.credit_limit') | ||
def _compute_confirmation_allowed(self): | ||
for sale_order in self: | ||
sale_order.confirmation_allowed = \ | ||
sale_order._confirmation_is_allowed() | ||
|
||
@api.multi | ||
@api.depends('amount_total', 'partner_id.credit', | ||
'partner_id.credit_limit') | ||
def _compute_warning(self): | ||
for sale_order in self: | ||
if sale_order._confirmation_is_allowed(): | ||
sale_order.credit_limit_warning = '' | ||
else: | ||
sale_order.credit_limit_warning = _( | ||
'Contact credit limit exceeded.') | ||
|
||
confirmation_allowed = fields.Boolean( | ||
string='Confirmation allowed', compute=_compute_confirmation_allowed) | ||
credit_limit_warning = fields.Char(string='Warning', | ||
compute=_compute_warning) | ||
state = fields.Selection( | ||
selection_add=[('waiting_for_approval', 'Waiting for approval')]) |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
78 changes: 78 additions & 0 deletions
78
sale_order_credit_limit_approval/static/description/index.html
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,78 @@ | ||
<section class="oe_container"> | ||
<div class="oe_row oe_spaced"> | ||
<div class="oe_span12"> | ||
<h2 class="oe_slogan">Sale Order Credit Limit Approval</h2> | ||
<p>This module was written to throw a warning when the credit limit of a customer is exceeded in a sale order, in addition to moving in this case the status to a new one named 'Waiting for approval'. If the credit limit of a customer is exceeded, only the sales manager will be able to approve the sale order.</p> | ||
<p>The module also adds a new option to make optional the use of a credit limit, and shows the current state of this if it has been activated.</p> | ||
</div> | ||
</div> | ||
</section> | ||
|
||
<section class="oe_container oe_dark"> | ||
<div class="oe_row oe_spaced"> | ||
<div class="oe_span12"> | ||
<h2 class="oe_slogan">Installation</h2> | ||
</div> | ||
<div class="oe_span12"> | ||
<p class="oe_mt32">To install this module, you need to: | ||
<ul> | ||
<li>Check that you have installed the module <strong>sale</strong>.</li> | ||
</ul> | ||
</p> | ||
</div> | ||
</div> | ||
</section> | ||
|
||
<section class="oe_container oe_dark"> | ||
<div class="oe_row oe_spaced"> | ||
<div class="oe_span12"> | ||
<h2 class="oe_slogan">Usage</h2> | ||
</div> | ||
<div class="oe_span6"> | ||
<p class="oe_mt32">To use this module, you need to: | ||
<ul> | ||
<li>Go to <i>Sales > Sales > Customers</i>, and open any customer.</li> | ||
<li>Go to the <i>Accounting</i> tab, and check the new field <strong>Set credit limit</strong>.</li> | ||
<li>Fill in the <i>Credit limit</i> field with any quantity. You will be able to see how much credit has this customer still available.</li> | ||
<li>Save the new changes.</li> | ||
<li>Go to <i>Sales > Sales > Sales Orders</i>, and create a new sale order.</li> | ||
<li>Add new lines to the order and save it. If the total quantity is equal to or greater than the available credit of the selected customer, a message will appear at the top of the form.</li> | ||
<li>Then you will be able to confirm the sale order, but it will pass to the state <i>Waiting for approval</i>.</li> | ||
<li>When the order is waiting for approval, only a user belonging to the <i>Sales Manager</i> group will be able to approve the sale, clicking on the <i>Approve Sale</i> button.</li> | ||
<li>Once approved, the sale order will follow the standard workflow.</li> | ||
</ul> | ||
</p> | ||
</div> | ||
<div class="oe_span6"> | ||
<div class="oe_demo oe_picture oe_screenshot"> | ||
<img src="../img/screenshot1.png"/> | ||
</div> | ||
<div class="oe_demo oe_picture oe_screenshot"> | ||
<img src="../img/screenshot2.png"/> | ||
</div> | ||
</div> | ||
</div> | ||
</section> | ||
|
||
<section class="oe_container oe_dark"> | ||
<div class="oe_row"> | ||
<div class="oe_span12"> | ||
<h2 class="oe_slogan">Credits</h2> | ||
</div> | ||
<div class="oe_span12"> | ||
<h3>Contributors</h3> | ||
<ul> | ||
<li>Juan Formoso <<a href="mailto:jfv@anubia.es">email.jfv@anubia.es</a>></li> | ||
</ul> | ||
</div> | ||
<div class="oe_span12"> | ||
<h3>Maintainer</h3> | ||
<p> | ||
This module is maintained by the OCA.<br/> | ||
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.<br/> | ||
To contribute to this module, please visit <a href="http://odoo-community.org">http://odoo-community.org</a>.<br/> | ||
<a href="http://odoo-community.org"><img class="oe_picture oe_centered" src="http://odoo-community.org/logo.png"></a> | ||
</p> | ||
</div> | ||
</div> | ||
</section> |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions
21
sale_order_credit_limit_approval/views/res_partner_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,21 @@ | ||
<?xml version="1.0"?> | ||
<openerp> | ||
<data> | ||
<record id="view_set_credit_limit_res_partner_form" model="ir.ui.view" > | ||
<field name="name">set.credit.limit.res.partner.form</field> | ||
<field name="model">res.partner</field> | ||
<field name="inherit_id" ref="account.view_partner_property_form"/> | ||
<field name="arch" type="xml"> | ||
<field name="credit_limit" position="before"> | ||
<field name="set_credit_limit"/> | ||
</field> | ||
<field name="credit_limit" position="attributes"> | ||
<attribute name="attrs">{'invisible': [('set_credit_limit', '=', False)]}</attribute> | ||
</field> | ||
<field name="credit_limit" position="after"> | ||
<field name="available_credit" attrs="{'invisible': [('set_credit_limit', '=', False)]}"/> | ||
</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,35 @@ | ||
<?xml version="1.0"?> | ||
<openerp> | ||
<data> | ||
<record id="view_order_credit_limit_form" model="ir.ui.view" > | ||
<field name="name">order.credit.limit.form</field> | ||
<field name="model">sale.order</field> | ||
<field name="inherit_id" ref="sale.view_order_form"/> | ||
<field name="arch" type="xml"> | ||
<xpath expr="//button[@name='action_button_confirm'][1]" position="attributes"> | ||
<attribute name="string">Approve Sale</attribute> | ||
<attribute name="states">waiting_for_approval</attribute> | ||
<attribute name="groups">base.group_sale_manager</attribute> | ||
<attribute name="class">oe_highlight</attribute> | ||
</xpath> | ||
<xpath expr="//button[@name='action_button_confirm'][2]" position="attributes"> | ||
<attribute name="invisible">1</attribute> | ||
</xpath> | ||
<xpath expr="//button[@name='action_button_confirm'][1]" position="after"> | ||
<button name="move_to_waiting_for_approval" states="draft,sent" string="Confirm Sale" | ||
groups="base.group_user" class="oe_highlight"/> | ||
<button name="deny_order" states="waiting_for_approval" string="Deny order" | ||
groups="base.group_sale_manager"/> | ||
</xpath> | ||
<xpath expr="//sheet/group[1]" position="before"> | ||
<field name="confirmation_allowed" invisible="1"/> | ||
<group name="warning_box" attrs="{'invisible': ['|', ('confirmation_allowed', '=', True), ('state', 'not in', ['cancel', 'draft', 'sent', 'waiting_for_approval'])]}"> | ||
<div class="alert alert-danger"> | ||
<span style="margin-right: 20px;"><strong>Warning</strong></span><field name="credit_limit_warning" nolabel="1" class="oe_inline"/> | ||
</div> | ||
</group> | ||
</xpath> | ||
</field> | ||
</record> | ||
</data> | ||
</openerp> |
Oops, something went wrong.