-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IMP] sale_order_manual_close: new control before finish sale order w…
…orkflow
- Loading branch information
agaldona
authored and
Daniel-CA
committed
May 23, 2016
1 parent
79995aa
commit ebabe07
Showing
7 changed files
with
267 additions
and
20 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 |
---|---|---|
@@ -1,15 +1,22 @@ | ||
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg | ||
:alt: License: AGPL-3 | ||
|
||
======================= | ||
Sale order manual close | ||
======================= | ||
|
||
This module allows to force manually ending of sale orders. | ||
The wizard will raise an error. | ||
- If the order is in state 'draft', 'cancel' or 'done'. | ||
- If the order has some picking not finished. | ||
- If the order has some invoice not finished. | ||
|
||
Credits | ||
======= | ||
|
||
Contributors | ||
------------ | ||
* Daniel Campos <[email protected]> | ||
* Ainara Galdona <[email protected]> | ||
* Pedro M. Baeza <[email protected]> | ||
* Ana Juaristi <[email protected]> |
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 |
---|---|---|
@@ -1,5 +1,4 @@ | ||
|
||
# -*- encoding: utf-8 -*- | ||
# -*- coding: utf-8 -*- | ||
############################################################################## | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
|
@@ -19,13 +18,16 @@ | |
|
||
{ | ||
"name": "Sale Order manual close", | ||
"version": "1.0", | ||
"version": "8.0.1.0.0", | ||
'author': 'OdooMRP team', | ||
'website': "http://www.odoomrp.com", | ||
'contributors': ["Daniel Campos <[email protected]>", | ||
"Ainara Galdona <[email protected]>", | ||
"Pedro M. Baeza <[email protected]>", | ||
"Ana Juaristi <[email protected]>"], | ||
"depends": ['sale'], | ||
"depends": ['sale', | ||
'sale_stock' | ||
], | ||
"category": "Custom Modules", | ||
"data": ['wizard/saleorder_wiz_view.xml'], | ||
"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,95 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * sale_order_manual_close | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 8.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2015-12-01 13:04+0000\n" | ||
"PO-Revision-Date: 2015-12-01 13:04+0000\n" | ||
"Last-Translator: <>\n" | ||
"Language-Team: \n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: \n" | ||
"Plural-Forms: \n" | ||
|
||
#. module: sale_order_manual_close | ||
#: view:wizard.saleorder.wf:sale_order_manual_close.view_saleorder_wf | ||
msgid "Accept" | ||
msgstr "Aceptar" | ||
|
||
#. module: sale_order_manual_close | ||
#: view:wizard.saleorder.wf:sale_order_manual_close.view_saleorder_wf | ||
msgid "Cancel" | ||
msgstr "Cancelar" | ||
|
||
#. module: sale_order_manual_close | ||
#: code:addons/sale_order_manual_close/wizard/saleorder_wf.py:19 | ||
#, python-format | ||
msgid "Cannot process already processed or in 'draft' state order." | ||
msgstr "No se puede procesar un pedido procesado o en estado 'borrador'." | ||
|
||
#. module: sale_order_manual_close | ||
#: field:wizard.saleorder.wf,create_uid:0 | ||
msgid "Created by" | ||
msgstr "Creado por" | ||
|
||
#. module: sale_order_manual_close | ||
#: field:wizard.saleorder.wf,create_date:0 | ||
msgid "Created on" | ||
msgstr "Creado el" | ||
|
||
#. module: sale_order_manual_close | ||
#: model:ir.actions.act_window,name:sale_order_manual_close.saleorder_wf | ||
msgid "End Sale Order Workflow" | ||
msgstr "Finalizar flujo de pedido de venta" | ||
|
||
#. module: sale_order_manual_close | ||
#: view:wizard.saleorder.wf:sale_order_manual_close.view_saleorder_wf | ||
msgid "Finish selected Sale Orders?" | ||
msgstr "¿Quieres finalizar los pedidos de venta seleccionados?" | ||
|
||
#. module: sale_order_manual_close | ||
#: field:wizard.saleorder.wf,id:0 | ||
msgid "ID" | ||
msgstr "ID" | ||
|
||
#. module: sale_order_manual_close | ||
#: field:wizard.saleorder.wf,write_uid:0 | ||
msgid "Last Updated by" | ||
msgstr "Última actualización por" | ||
|
||
#. module: sale_order_manual_close | ||
#: field:wizard.saleorder.wf,write_date:0 | ||
msgid "Last Updated on" | ||
msgstr "Última actualización el" | ||
|
||
#. module: sale_order_manual_close | ||
#: view:wizard.saleorder.wf:sale_order_manual_close.view_saleorder_wf | ||
msgid "Sale Order Process" | ||
msgstr "Procesar pedidos de venta" | ||
|
||
#. module: sale_order_manual_close | ||
#: code:addons/sale_order_manual_close/wizard/saleorder_wf.py:26 | ||
#, python-format | ||
msgid "The order has no processed invoices." | ||
msgstr "El pedido tiene facturas no procesadas." | ||
|
||
#. module: sale_order_manual_close | ||
#: code:addons/sale_order_manual_close/wizard/saleorder_wf.py:23 | ||
#, python-format | ||
msgid "The order has no processed picking." | ||
msgstr "El pedido tiene albaranes no procesados." | ||
|
||
#. module: sale_order_manual_close | ||
#: model:ir.model,name:sale_order_manual_close.model_wizard_saleorder_wf | ||
msgid "Wizard Sale Order Workflow Finish" | ||
msgstr "Asistente para cerrar el flujo de pedido de venta" | ||
|
||
#. module: sale_order_manual_close | ||
#: view:wizard.saleorder.wf:sale_order_manual_close.view_saleorder_wf | ||
msgid "or" | ||
msgstr "o" | ||
|
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,5 @@ | ||
# -*- coding: utf-8 -*- | ||
# (c) 2015 Ainara Galdona - AvanzOSC | ||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html | ||
|
||
from . import test_sale_order_manual_close |
135 changes: 135 additions & 0 deletions
135
sale_order_manual_close/tests/test_sale_order_manual_close.py
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,135 @@ | ||
# -*- coding: utf-8 -*- | ||
# (c) 2015 Ainara Galdona - AvanzOSC | ||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html | ||
|
||
import openerp.tests.common as common | ||
from openerp import exceptions, fields, _ | ||
|
||
|
||
class TestSaleOrderManualClose(common.TransactionCase): | ||
|
||
def setUp(self): | ||
super(TestSaleOrderManualClose, self).setUp() | ||
self.sale_model = self.env['sale.order'] | ||
self.finish_wk_model = self.env['wizard.saleorder.wf'] | ||
uom_unit_id = self.ref('product.product_uom_unit') | ||
line1 = {'name': 'Laptop E5023', | ||
'product_id': self.ref('product.product_product_25'), | ||
'product_uom_qty': 3, | ||
'product_uos_qty': 3, | ||
'product_uom': uom_unit_id, | ||
'price_unit': 2950.00 | ||
} | ||
line2 = {'name': 'Pen drive, 16GB', | ||
'product_id': self.ref('product.product_product_30'), | ||
'product_uom_qty': 5, | ||
'product_uos_qty': 5, | ||
'product_uom': uom_unit_id, | ||
'price_unit': 145.00 | ||
} | ||
line3 = {'name': 'Headset USB', | ||
'product_id': self.ref('product.product_product_33'), | ||
'product_uom_qty': 2, | ||
'product_uos_qty': 2, | ||
'product_uom': uom_unit_id, | ||
'price_unit': 65.00 | ||
} | ||
partner_id = self.ref('base.res_partner_2') | ||
sale_vals = { | ||
'partner_id': partner_id, | ||
'partner_invoice_id': partner_id, | ||
'partner_shipping_id': partner_id, | ||
'user_id': self.ref('base.user_demo'), | ||
'pricelist_id': self.ref('product.list0'), | ||
'section_id': self.ref('sales_team.section_sales_department'), | ||
'date_order': fields.Date.today(), | ||
'order_line': [(0, 0, line1), (0, 0, line2), (0, 0, line3)], | ||
'order_policy': 'manual' | ||
} | ||
self.order = self.sale_model.create(sale_vals) | ||
|
||
def test_draft_order_finish(self): | ||
try: | ||
self.finish_wk_model.with_context( | ||
active_model='sale.order', active_id=self.order.id, | ||
active_ids=[self.order.id]).saleorder_finish_wf() | ||
except exceptions.Warning as e: | ||
self.assertEqual(e.message, _("Cannot process already processed or" | ||
" in 'draft' state order."), | ||
"The order is not in draft state.") | ||
|
||
def test_cancel_order_finish(self): | ||
self.order.signal_workflow('cancel') | ||
try: | ||
self.finish_wk_model.with_context( | ||
active_model='sale.order', active_id=self.order.id, | ||
active_ids=[self.order.id]).saleorder_finish_wf() | ||
except exceptions.Warning as e: | ||
self.assertEqual(e.message, _("Cannot process already processed or" | ||
" in 'draft' state order."), | ||
"The order is not in cancel state.") | ||
|
||
def test_confirm_order_finish_error(self): | ||
self.order.action_button_confirm() | ||
try: | ||
self.finish_wk_model.with_context( | ||
active_model='sale.order', active_id=self.order.id, | ||
active_ids=[self.order.id]).saleorder_finish_wf() | ||
except exceptions.Warning as e: | ||
self.assertEqual(e.message, | ||
_("The order has no processed picking."), | ||
"All pickings are canceled or processed.") | ||
|
||
def test_confirm_order_picking_raise_finish(self): | ||
self.order.action_button_confirm() | ||
self.order.action_invoice_create() | ||
self.order.invoice_ids.signal_workflow('invoice_cancel') | ||
try: | ||
self.finish_wk_model.with_context( | ||
active_model='sale.order', active_id=self.order.id, | ||
active_ids=[self.order.id]).saleorder_finish_wf() | ||
except exceptions.Warning as e: | ||
self.assertEqual(e.message, | ||
_("The order has no processed picking."), | ||
"All pickings are canceled or processed.") | ||
|
||
def test_confirm_order_invoice_raise_finish(self): | ||
self.order.action_button_confirm() | ||
self.order.action_invoice_create() | ||
self.order.picking_ids.action_cancel() | ||
try: | ||
self.finish_wk_model.with_context( | ||
active_model='sale.order', active_id=self.order.id, | ||
active_ids=[self.order.id]).saleorder_finish_wf() | ||
except exceptions.Warning as e: | ||
self.assertEqual(e.message, | ||
_("The order has no processed invoices."), | ||
"All invoices are canceled or processed.") | ||
|
||
def test_confirm_order_ok_finish(self): | ||
self.order.action_button_confirm() | ||
self.order.action_invoice_create() | ||
self.order.invoice_ids.signal_workflow('invoice_cancel') | ||
self.order.picking_ids.action_cancel() | ||
self.finish_wk_model.with_context( | ||
active_model='sale.order', active_id=self.order.id, | ||
active_ids=[self.order.id]).saleorder_finish_wf() | ||
self.assertEqual(self.order.state, 'done', | ||
"Orders workflow is not finished.") | ||
|
||
def test_order_already_processed_finish(self): | ||
self.order.action_button_confirm() | ||
self.order.action_invoice_create() | ||
self.order.invoice_ids.signal_workflow('invoice_cancel') | ||
self.order.picking_ids.action_cancel() | ||
self.finish_wk_model.with_context( | ||
active_model='sale.order', active_id=self.order.id, | ||
active_ids=[self.order.id]).saleorder_finish_wf() | ||
try: | ||
self.finish_wk_model.with_context( | ||
active_model='sale.order', active_id=self.order.id, | ||
active_ids=[self.order.id]).saleorder_finish_wf() | ||
except exceptions.Warning as e: | ||
self.assertEqual(e.message, _("Cannot process already processed or" | ||
" in 'draft' state order."), | ||
"The order is not already processed.") |
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
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