diff --git a/stock_picking_return_refund_option/README.rst b/stock_picking_return_refund_option/README.rst new file mode 100644 index 00000000000..73de5cda68e --- /dev/null +++ b/stock_picking_return_refund_option/README.rst @@ -0,0 +1,148 @@ +================================== +Stock Picking Return Refund Option +================================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:faadfb1fb3ffb287a70b251e5ae89daa22f18cce203e1e3878cfbf21a6c5fc3e + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png + :target: https://odoo-community.org/page/development-status + :alt: Production/Stable +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Faccount--invoicing-lightgray.png?logo=github + :target: https://github.com/OCA/account-invoicing/tree/18.0/stock_picking_return_refund_option + :alt: OCA/account-invoicing +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/account-invoicing-18-0/account-invoicing-18-0-stock_picking_return_refund_option + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/account-invoicing&target_branch=18.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module extends the functionality of sales and purchase orders to +support modify stock move field to_refund after it has been confirmed. + +**Table of contents** + +.. contents:: + :local: + +Installation +============ + +1. This module requires the additional installation of sale_stock or + purchase modules for enabling the features it contains. + +Usage +===== + +To use this module, when some customer returns some refundable products +to you after you created an invoice, you need to: + +For a sale order: + +1. Go to *Sales > Sales Orders > Create*. +2. Choose a customer and add a product whose *Invoicing Policy* is + *Delivered quantities*, and input some quantity to sell. +3. Confirm the sale. +4. Go to *Delivery > Validate > Apply*. +5. Return to the sale order. +6. Press *Create Invoice > Invoiceable lines > Create and View + Invoices*. +7. The created invoice's amount is the same you sold. +8. Return to the sale order. +9. Go to *Delivery > Return*. +10. Set *Quantity* to a lower quantity than the sold one, and enable *To + Refund*. +11. Press *Return > Validate > Apply*. +12. Return to the sale order. +13. Press *Create Invoice > Invoiceable lines (deduct down payments) > + Create and View Invoices*. +14. A refund is created for the quantity you returned before. + +For allowing to refund quantities after the picking has been confirmed +if you did not check 'to refund' in wizard, you can change the value of +'Refund Options' field. + +To use this module, when you return some refundable products to your +supplier after you created an invoice, you need to: + +1. Go to *Purchase > Purchase Orders > Create*. +2. Choose a supplier and add a product whose *Invoicing Policy* is + *Delivered quantities*, and input some quantity to buy. +3. Confirm the order. +4. Go to *Delivery > Validate > Apply*. +5. Return to the purchase order. +6. Press on smart button "Invoices" and create one. +7. The created invoice's amount is the same you sold. +8. Return to the purchase order. +9. Go to *Delivery > Return*. +10. Set *Quantity* to a lower quantity than you bought, and enable *To + Refund*. +11. Press *Return > Validate > Apply*. +12. Return to the purchase order. + +For allowing to refund quantities after the picking has been confirmed +if you did not check 'to refund' in wizard, you can change the value of +'Refund Options' field. + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* Tecnativa + +Contributors +------------ + +- `Tecnativa `__: + + - Sergio Teruel + - César A. Sánchez + - Carlos Roca + +Maintainers +----------- + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +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. + +.. |maintainer-sergio-teruel| image:: https://github.com/sergio-teruel.png?size=40px + :target: https://github.com/sergio-teruel + :alt: sergio-teruel + +Current `maintainer `__: + +|maintainer-sergio-teruel| + +This module is part of the `OCA/account-invoicing `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/stock_picking_return_refund_option/__init__.py b/stock_picking_return_refund_option/__init__.py new file mode 100644 index 00000000000..31660d6a965 --- /dev/null +++ b/stock_picking_return_refund_option/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import models diff --git a/stock_picking_return_refund_option/__manifest__.py b/stock_picking_return_refund_option/__manifest__.py new file mode 100644 index 00000000000..ed75bd4c039 --- /dev/null +++ b/stock_picking_return_refund_option/__manifest__.py @@ -0,0 +1,17 @@ +# Copyright 2018 Tecnativa - Sergio Teruel +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +{ + "name": "Stock Picking Return Refund Option", + "summary": "Update the refund options in pickings", + "version": "18.0.1.0.0", + "development_status": "Production/Stable", + "category": "Sales", + "website": "https://github.com/OCA/account-invoicing", + "author": "Tecnativa, Odoo Community Association (OCA)", + "license": "AGPL-3", + "application": False, + "installable": True, + "depends": ["stock_account", "purchase_stock", "sale_stock"], + "data": ["views/stock_picking_view.xml"], + "maintainers": ["sergio-teruel"], +} diff --git a/stock_picking_return_refund_option/i18n/ca.po b/stock_picking_return_refund_option/i18n/ca.po new file mode 100644 index 00000000000..dbef59ce70d --- /dev/null +++ b/stock_picking_return_refund_option/i18n/ca.po @@ -0,0 +1,58 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_picking_return_refund_option +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2022-08-09 10:06+0000\n" +"Last-Translator: jabelchi \n" +"Language-Team: none\n" +"Language: ca\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.3.2\n" + +#. module: stock_picking_return_refund_option +#: model:ir.model.fields,field_description:stock_picking_return_refund_option.field_stock_picking__is_return +msgid "Is Return" +msgstr "És devolució" + +#. module: stock_picking_return_refund_option +#: model:ir.model.fields.selection,name:stock_picking_return_refund_option.selection__stock_picking__to_refund_lines__no_refund +msgid "No Refund" +msgstr "" + +#. module: stock_picking_return_refund_option +#: model:ir.model.fields,field_description:stock_picking_return_refund_option.field_stock_picking__to_refund_lines +#: model_terms:ir.ui.view,arch_db:stock_picking_return_refund_option.view_picking_form +msgid "Refund Options" +msgstr "Opcions de devolució" + +#. module: stock_picking_return_refund_option +#: model:ir.model,name:stock_picking_return_refund_option.model_stock_move +msgid "Stock Move" +msgstr "Moviment d'estoc" + +#. module: stock_picking_return_refund_option +#: model:ir.model.fields,help:stock_picking_return_refund_option.field_stock_picking__to_refund_lines +msgid "" +"This field allow modify 'to_refund' field value in all stock moves from this " +"picking after it has been confirmed.to_refund: set all stock moves to True " +"value and recompute delivered quantities in sale order.\n" +"no_refund: set all stock moves to False value and recompute delivered " +"quantities in sale/purchase order." +msgstr "" + +#. module: stock_picking_return_refund_option +#: model:ir.model.fields.selection,name:stock_picking_return_refund_option.selection__stock_picking__to_refund_lines__to_refund +msgid "To Refund" +msgstr "" + +#. module: stock_picking_return_refund_option +#: model:ir.model,name:stock_picking_return_refund_option.model_stock_picking +msgid "Transfer" +msgstr "" diff --git a/stock_picking_return_refund_option/i18n/es.po b/stock_picking_return_refund_option/i18n/es.po new file mode 100644 index 00000000000..d1d21bb32c7 --- /dev/null +++ b/stock_picking_return_refund_option/i18n/es.po @@ -0,0 +1,70 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_picking_return_refund_option +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 11.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2019-12-04 17:16+0000\n" +"PO-Revision-Date: 2019-12-04 18:17+0100\n" +"Last-Translator: \n" +"Language-Team: \n" +"Language: es_ES\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"X-Generator: Poedit 2.0.6\n" + +#. module: stock_picking_return_refund_option +#: model:ir.model.fields,field_description:stock_picking_return_refund_option.field_stock_picking__is_return +msgid "Is Return" +msgstr "Es devolución" + +#. module: stock_picking_return_refund_option +#: model:ir.model.fields.selection,name:stock_picking_return_refund_option.selection__stock_picking__to_refund_lines__no_refund +msgid "No Refund" +msgstr "No abonar" + +#. module: stock_picking_return_refund_option +#: model:ir.model.fields,field_description:stock_picking_return_refund_option.field_stock_picking__to_refund_lines +#: model_terms:ir.ui.view,arch_db:stock_picking_return_refund_option.view_picking_form +msgid "Refund Options" +msgstr "Opciones de devolución" + +#. module: stock_picking_return_refund_option +#: model:ir.model,name:stock_picking_return_refund_option.model_stock_move +msgid "Stock Move" +msgstr "Movimiento de stock" + +#. module: stock_picking_return_refund_option +#: model:ir.model.fields,help:stock_picking_return_refund_option.field_stock_picking__to_refund_lines +msgid "" +"This field allow modify 'to_refund' field value in all stock moves from this " +"picking after it has been confirmed.to_refund: set all stock moves to True " +"value and recompute delivered quantities in sale order.\n" +"no_refund: set all stock moves to False value and recompute delivered " +"quantities in sale/purchase order." +msgstr "" +"Este campo permite modificar el valor del campo 'para abonar en el pedido' " +"de todos los movimientos de stock del albarán después de que haya sido " +"confirmado.\n" +"Para abonar en el pedido: Actualiza todos los movimientos de stock con el " +"valor a 'verdadero' y recalcula las unidades entregadas del pedido de " +"venta.\n" +"No abonar en el pedido: Actualiza todos los movimientos de stock con el " +"valor a 'falso' y recalcula las unidades entregadas del pedido de venta." + +#. module: stock_picking_return_refund_option +#: model:ir.model.fields.selection,name:stock_picking_return_refund_option.selection__stock_picking__to_refund_lines__to_refund +msgid "To Refund" +msgstr "Para abonar" + +#. module: stock_picking_return_refund_option +#: model:ir.model,name:stock_picking_return_refund_option.model_stock_picking +msgid "Transfer" +msgstr "Transferir" + +#~ msgid "Return Picking" +#~ msgstr "Albarán de devolución" diff --git a/stock_picking_return_refund_option/i18n/it.po b/stock_picking_return_refund_option/i18n/it.po new file mode 100644 index 00000000000..234da6d33ff --- /dev/null +++ b/stock_picking_return_refund_option/i18n/it.po @@ -0,0 +1,61 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_picking_return_refund_option +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2024-02-27 18:35+0000\n" +"Last-Translator: mymage \n" +"Language-Team: none\n" +"Language: it\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.17\n" + +#. module: stock_picking_return_refund_option +#: model:ir.model.fields,field_description:stock_picking_return_refund_option.field_stock_picking__is_return +msgid "Is Return" +msgstr "È un reso" + +#. module: stock_picking_return_refund_option +#: model:ir.model.fields.selection,name:stock_picking_return_refund_option.selection__stock_picking__to_refund_lines__no_refund +msgid "No Refund" +msgstr "Non rimborsato" + +#. module: stock_picking_return_refund_option +#: model:ir.model.fields,field_description:stock_picking_return_refund_option.field_stock_picking__to_refund_lines +#: model_terms:ir.ui.view,arch_db:stock_picking_return_refund_option.view_picking_form +msgid "Refund Options" +msgstr "Opzioni rimborso" + +#. module: stock_picking_return_refund_option +#: model:ir.model,name:stock_picking_return_refund_option.model_stock_move +msgid "Stock Move" +msgstr "Movimento di magazzino" + +#. module: stock_picking_return_refund_option +#: model:ir.model.fields,help:stock_picking_return_refund_option.field_stock_picking__to_refund_lines +msgid "" +"This field allow modify 'to_refund' field value in all stock moves from this picking after it has been confirmed.to_refund: set all stock moves to True value and recompute delivered quantities in sale order.\n" +"no_refund: set all stock moves to False value and recompute delivered quantities in sale/purchase order." +msgstr "" +"Questo campo consente di modificare il valore del campo 'to_refund' in tutti " +"i movimenti di magazzino da questo prelievo dopo che è stato confermato. " +"To_refund: imposta il valore a True in tutti i movimenti di magazzino e " +"ricalcola le quantità consegnate nell'ordine di vendita. \n" +"No_refund: imposta il valore a False in tutti i movimenti di magazzino e " +"ricalcola le quantità consegnate nell'ordine di vendita/acquisto." + +#. module: stock_picking_return_refund_option +#: model:ir.model.fields.selection,name:stock_picking_return_refund_option.selection__stock_picking__to_refund_lines__to_refund +msgid "To Refund" +msgstr "Da rimborsare" + +#. module: stock_picking_return_refund_option +#: model:ir.model,name:stock_picking_return_refund_option.model_stock_picking +msgid "Transfer" +msgstr "Trasferimento" diff --git a/stock_picking_return_refund_option/i18n/stock_picking_return_refund_option.pot b/stock_picking_return_refund_option/i18n/stock_picking_return_refund_option.pot new file mode 100644 index 00000000000..435144ddd16 --- /dev/null +++ b/stock_picking_return_refund_option/i18n/stock_picking_return_refund_option.pot @@ -0,0 +1,52 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_picking_return_refund_option +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \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: stock_picking_return_refund_option +#: model:ir.model.fields,field_description:stock_picking_return_refund_option.field_stock_picking__is_return +msgid "Is Return" +msgstr "" + +#. module: stock_picking_return_refund_option +#: model:ir.model.fields.selection,name:stock_picking_return_refund_option.selection__stock_picking__to_refund_lines__no_refund +msgid "No Refund" +msgstr "" + +#. module: stock_picking_return_refund_option +#: model:ir.model.fields,field_description:stock_picking_return_refund_option.field_stock_picking__to_refund_lines +#: model_terms:ir.ui.view,arch_db:stock_picking_return_refund_option.view_picking_form +msgid "Refund Options" +msgstr "" + +#. module: stock_picking_return_refund_option +#: model:ir.model,name:stock_picking_return_refund_option.model_stock_move +msgid "Stock Move" +msgstr "" + +#. module: stock_picking_return_refund_option +#: model:ir.model.fields,help:stock_picking_return_refund_option.field_stock_picking__to_refund_lines +msgid "" +"This field allow modify 'to_refund' field value in all stock moves from this picking after it has been confirmed.to_refund: set all stock moves to True value and recompute delivered quantities in sale order.\n" +"no_refund: set all stock moves to False value and recompute delivered quantities in sale/purchase order." +msgstr "" + +#. module: stock_picking_return_refund_option +#: model:ir.model.fields.selection,name:stock_picking_return_refund_option.selection__stock_picking__to_refund_lines__to_refund +msgid "To Refund" +msgstr "" + +#. module: stock_picking_return_refund_option +#: model:ir.model,name:stock_picking_return_refund_option.model_stock_picking +msgid "Transfer" +msgstr "" diff --git a/stock_picking_return_refund_option/models/__init__.py b/stock_picking_return_refund_option/models/__init__.py new file mode 100644 index 00000000000..fb771183179 --- /dev/null +++ b/stock_picking_return_refund_option/models/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from . import stock_move +from . import stock_picking diff --git a/stock_picking_return_refund_option/models/stock_move.py b/stock_picking_return_refund_option/models/stock_move.py new file mode 100644 index 00000000000..f14309f2a3c --- /dev/null +++ b/stock_picking_return_refund_option/models/stock_move.py @@ -0,0 +1,14 @@ +# Copyright 2021 Tecnativa - Sergio Teruel +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo import models + + +class StockMove(models.Model): + _inherit = "stock.move" + + def write(self, vals): + res = super().write(vals) + if "to_refund" in vals: + self.picking_id.set_delivered_qty() + self.picking_id.set_received_qty() + return res diff --git a/stock_picking_return_refund_option/models/stock_picking.py b/stock_picking_return_refund_option/models/stock_picking.py new file mode 100644 index 00000000000..fb9088975ec --- /dev/null +++ b/stock_picking_return_refund_option/models/stock_picking.py @@ -0,0 +1,77 @@ +# Copyright 2018 Tecnativa - Sergio Teruel +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo import api, fields, models + + +class StockPicking(models.Model): + _inherit = "stock.picking" + + to_refund_lines = fields.Selection( + selection=[("to_refund", "To Refund"), ("no_refund", "No Refund")], + compute="_compute_to_refund_lines", + inverse="_inverse_to_refund_lines", + string="Refund Options", + help="This field allow modify 'to_refund' field value in all " + "stock moves from this picking after it has been confirmed." + "to_refund: set all stock moves to True value and recompute " + "delivered quantities in sale order.\n" + "no_refund: set all stock moves to False value and recompute " + "delivered quantities in sale/purchase order.", + ) + is_return = fields.Boolean(compute="_compute_is_return") + + @api.depends("move_ids.to_refund") + def _compute_to_refund_lines(self): + for picking in self: + moves_to_refund = picking.move_ids.filtered(lambda mv: mv.to_refund) + if not moves_to_refund: + picking.to_refund_lines = "no_refund" + elif len(moves_to_refund) == len(picking.move_ids): + picking.to_refund_lines = "to_refund" + else: + picking.to_refund_lines = False + + def _inverse_to_refund_lines(self): + """ + Set to_refund stock_move field: + All lines to True. + All lines to False. + Each line to original value selected in return wizard by user. + """ + self._update_stock_moves() + self.set_delivered_qty() + self.set_received_qty() + + def _compute_is_return(self): + for picking in self: + picking.is_return = any(x.origin_returned_move_id for x in picking.move_ids) + + def _update_stock_moves(self): + for pick in self.filtered("to_refund_lines"): + pick.move_ids.write({"to_refund": pick.to_refund_lines == "to_refund"}) + + def set_delivered_qty(self): + """ + Check if exists sale_line_id field in stock.move model that has been + added by sale_stock module, this module has not dependency of this, + Update sale order line qty_delivered for allow do a refund invoice + """ + if hasattr(self.env["stock.move"], "sale_line_id") and self.sale_id: + # The sale_stock module is installed + so_lines = self.mapped("move_ids.sale_line_id").filtered( + lambda x: x.product_id.invoice_policy in ("order", "delivery") + ) + so_lines._compute_qty_delivered() + + def set_received_qty(self): + """ + Check if exists purchase_line_id field in stock.move model that has + been added by purchase module, this module has not dependency of this, + Update purchase order line qty_received for allow do a refund invoice. + """ + if hasattr(self.env["stock.move"], "purchase_line_id") and self.purchase_id: + # The purchase module is installed + po_lines = self.mapped("move_ids.purchase_line_id").filtered( + lambda x: x.product_id.invoice_policy in ("order", "delivery") + ) + po_lines._compute_qty_received() diff --git a/stock_picking_return_refund_option/pyproject.toml b/stock_picking_return_refund_option/pyproject.toml new file mode 100644 index 00000000000..4231d0cccb3 --- /dev/null +++ b/stock_picking_return_refund_option/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/stock_picking_return_refund_option/readme/CONTRIBUTORS.md b/stock_picking_return_refund_option/readme/CONTRIBUTORS.md new file mode 100644 index 00000000000..f87d237cda2 --- /dev/null +++ b/stock_picking_return_refund_option/readme/CONTRIBUTORS.md @@ -0,0 +1,4 @@ +- [Tecnativa](https://www.tecnativa.com): + - Sergio Teruel + - César A. Sánchez + - Carlos Roca diff --git a/stock_picking_return_refund_option/readme/DESCRIPTION.md b/stock_picking_return_refund_option/readme/DESCRIPTION.md new file mode 100644 index 00000000000..acbfbd782d8 --- /dev/null +++ b/stock_picking_return_refund_option/readme/DESCRIPTION.md @@ -0,0 +1,2 @@ +This module extends the functionality of sales and purchase orders to +support modify stock move field to_refund after it has been confirmed. diff --git a/stock_picking_return_refund_option/readme/INSTALL.md b/stock_picking_return_refund_option/readme/INSTALL.md new file mode 100644 index 00000000000..e0a53774323 --- /dev/null +++ b/stock_picking_return_refund_option/readme/INSTALL.md @@ -0,0 +1,2 @@ +1. This module requires the additional installation of sale_stock or + purchase modules for enabling the features it contains. diff --git a/stock_picking_return_refund_option/readme/USAGE.md b/stock_picking_return_refund_option/readme/USAGE.md new file mode 100644 index 00000000000..6f24ebe6dc9 --- /dev/null +++ b/stock_picking_return_refund_option/readme/USAGE.md @@ -0,0 +1,49 @@ +To use this module, when some customer returns some refundable products +to you after you created an invoice, you need to: + +For a sale order: + +1. Go to *Sales \> Sales Orders \> Create*. +2. Choose a customer and add a product whose *Invoicing Policy* is + *Delivered quantities*, and input some quantity to sell. +3. Confirm the sale. +4. Go to *Delivery \> Validate \> Apply*. +5. Return to the sale order. +6. Press *Create Invoice \> Invoiceable lines \> Create and View + Invoices*. +7. The created invoice's amount is the same you sold. +8. Return to the sale order. +9. Go to *Delivery \> Return*. +10. Set *Quantity* to a lower quantity than the sold one, and enable *To + Refund*. +11. Press *Return \> Validate \> Apply*. +12. Return to the sale order. +13. Press *Create Invoice \> Invoiceable lines (deduct down payments) \> + Create and View Invoices*. +14. A refund is created for the quantity you returned before. + +For allowing to refund quantities after the picking has been confirmed +if you did not check 'to refund' in wizard, you can change the value of +'Refund Options' field. + +To use this module, when you return some refundable products to your +supplier after you created an invoice, you need to: + +1. Go to *Purchase \> Purchase Orders \> Create*. +2. Choose a supplier and add a product whose *Invoicing Policy* is + *Delivered quantities*, and input some quantity to buy. +3. Confirm the order. +4. Go to *Delivery \> Validate \> Apply*. +5. Return to the purchase order. +6. Press on smart button "Invoices" and create one. +7. The created invoice's amount is the same you sold. +8. Return to the purchase order. +9. Go to *Delivery \> Return*. +10. Set *Quantity* to a lower quantity than you bought, and enable *To + Refund*. +11. Press *Return \> Validate \> Apply*. +12. Return to the purchase order. + +For allowing to refund quantities after the picking has been confirmed +if you did not check 'to refund' in wizard, you can change the value of +'Refund Options' field. diff --git a/stock_picking_return_refund_option/static/description/icon.png b/stock_picking_return_refund_option/static/description/icon.png new file mode 100644 index 00000000000..3a0328b516c Binary files /dev/null and b/stock_picking_return_refund_option/static/description/icon.png differ diff --git a/stock_picking_return_refund_option/static/description/index.html b/stock_picking_return_refund_option/static/description/index.html new file mode 100644 index 00000000000..fb4dadaf0a4 --- /dev/null +++ b/stock_picking_return_refund_option/static/description/index.html @@ -0,0 +1,490 @@ + + + + + +Stock Picking Return Refund Option + + + +
+

Stock Picking Return Refund Option

+ + +

Production/Stable License: AGPL-3 OCA/account-invoicing Translate me on Weblate Try me on Runboat

+

This module extends the functionality of sales and purchase orders to +support modify stock move field to_refund after it has been confirmed.

+

Table of contents

+ +
+

Installation

+
    +
  1. This module requires the additional installation of sale_stock or +purchase modules for enabling the features it contains.
  2. +
+
+
+

Usage

+

To use this module, when some customer returns some refundable products +to you after you created an invoice, you need to:

+

For a sale order:

+
    +
  1. Go to Sales > Sales Orders > Create.
  2. +
  3. Choose a customer and add a product whose Invoicing Policy is +Delivered quantities, and input some quantity to sell.
  4. +
  5. Confirm the sale.
  6. +
  7. Go to Delivery > Validate > Apply.
  8. +
  9. Return to the sale order.
  10. +
  11. Press Create Invoice > Invoiceable lines > Create and View +Invoices.
  12. +
  13. The created invoice’s amount is the same you sold.
  14. +
  15. Return to the sale order.
  16. +
  17. Go to Delivery > Return.
  18. +
  19. Set Quantity to a lower quantity than the sold one, and enable To +Refund.
  20. +
  21. Press Return > Validate > Apply.
  22. +
  23. Return to the sale order.
  24. +
  25. Press Create Invoice > Invoiceable lines (deduct down payments) > +Create and View Invoices.
  26. +
  27. A refund is created for the quantity you returned before.
  28. +
+

For allowing to refund quantities after the picking has been confirmed +if you did not check ‘to refund’ in wizard, you can change the value of +‘Refund Options’ field.

+

To use this module, when you return some refundable products to your +supplier after you created an invoice, you need to:

+
    +
  1. Go to Purchase > Purchase Orders > Create.
  2. +
  3. Choose a supplier and add a product whose Invoicing Policy is +Delivered quantities, and input some quantity to buy.
  4. +
  5. Confirm the order.
  6. +
  7. Go to Delivery > Validate > Apply.
  8. +
  9. Return to the purchase order.
  10. +
  11. Press on smart button “Invoices” and create one.
  12. +
  13. The created invoice’s amount is the same you sold.
  14. +
  15. Return to the purchase order.
  16. +
  17. Go to Delivery > Return.
  18. +
  19. Set Quantity to a lower quantity than you bought, and enable To +Refund.
  20. +
  21. Press Return > Validate > Apply.
  22. +
  23. Return to the purchase order.
  24. +
+

For allowing to refund quantities after the picking has been confirmed +if you did not check ‘to refund’ in wizard, you can change the value of +‘Refund Options’ field.

+
+
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Tecnativa
  • +
+
+
+

Contributors

+
    +
  • Tecnativa:
      +
    • Sergio Teruel
    • +
    • César A. Sánchez
    • +
    • Carlos Roca
    • +
    +
  • +
+
+
+

Maintainers

+

This module is maintained by the OCA.

+ +Odoo Community Association + +

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.

+

Current maintainer:

+

sergio-teruel

+

This module is part of the OCA/account-invoicing project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/stock_picking_return_refund_option/tests/__init__.py b/stock_picking_return_refund_option/tests/__init__.py new file mode 100644 index 00000000000..6b1250c3288 --- /dev/null +++ b/stock_picking_return_refund_option/tests/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import test_stock_picking_return_refund_options diff --git a/stock_picking_return_refund_option/tests/test_stock_picking_return_refund_options.py b/stock_picking_return_refund_option/tests/test_stock_picking_return_refund_options.py new file mode 100644 index 00000000000..8249dba8cee --- /dev/null +++ b/stock_picking_return_refund_option/tests/test_stock_picking_return_refund_options.py @@ -0,0 +1,140 @@ +# Copyright 2018 Tecnativa - Sergio Teruel +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo.tests import Form +from odoo.tests.common import TransactionCase, tagged + + +@tagged("post_install", "-at_install") +class TestSaleOrderLineInput(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.env = cls.env( + context=dict( + cls.env.context, + mail_create_nolog=True, + mail_create_nosubscribe=True, + mail_notrack=True, + no_reset_password=True, + tracking_disable=True, + ) + ) + cls.partner = cls.env["res.partner"].create( + {"name": "Test", "customer_rank": 1, "supplier_rank": 1} + ) + cls.product = cls.env["product.product"].create( + { + "name": "test_product", + "type": "consu", + "is_storable": True, + "invoice_policy": "delivery", + } + ) + cls.product2 = cls.env["product.product"].create( + { + "name": "test_product_2", + "type": "consu", + "is_storable": True, + "invoice_policy": "delivery", + } + ) + with Form(cls.env["sale.order"]) as order_form: + order_form.partner_id = cls.partner + with order_form.order_line.new() as line_form: + line_form.product_id = cls.product + line_form.product_uom_qty = 1 + with order_form.order_line.new() as line_form: + line_form.product_id = cls.product2 + line_form.product_uom_qty = 1 + cls.order = order_form.save() + cls.order.action_confirm() + cls.picking = cls.order.picking_ids + move_line_vals_list = [] + for move in cls.picking.move_ids: + move_line_vals = move._prepare_move_line_vals() + move_line_vals["quantity"] = 1 + move_line_vals_list.append(move_line_vals) + cls.env["stock.move.line"].create(move_line_vals_list) + cls.picking.button_validate() + cls.order._create_invoices() + + def get_return_picking_wizard(self, picking): + stock_return_picking_form = Form( + self.env["stock.return.picking"].with_context( + active_ids=picking.ids, + active_id=picking.ids[0], + active_model="stock.picking", + ) + ) + return stock_return_picking_form.save() + + def return_picking_wiz(self, picking): + wizard = self.get_return_picking_wizard(picking) + wizard.product_return_moves.write({"quantity": 1.0, "to_refund": False}) + return wizard + + def test_return_to_refund_values(self): + return_wizard = self.return_picking_wiz(self.picking) + return_pick = self.picking.browse( + return_wizard.action_create_returns()["res_id"] + ) + return_pick.move_line_ids.write({"quantity": 1.0}) + return_pick.button_validate() + self.assertEqual(return_pick.to_refund_lines, "no_refund") + return_pick.move_ids.write({"to_refund": True}) + self.assertEqual(return_pick.to_refund_lines, "to_refund") + return_pick.move_ids[:1].write({"to_refund": False}) + self.assertFalse(return_pick.to_refund_lines) + + def test_return_so_wo_to_refund(self): + # Return some items, after SO was invoiced + return_wizard = self.return_picking_wiz(self.picking) + return_pick = self.picking.browse( + return_wizard.action_create_returns()["res_id"] + ) + return_pick.move_line_ids.write({"quantity": 1.0}) + return_pick.button_validate() + self.assertEqual(self.order.invoice_status, "invoiced") + + return_pick.to_refund_lines = "to_refund" + self.assertEqual(self.order.invoice_status, "to invoice") + + return_pick.to_refund_lines = "no_refund" + self.assertEqual(self.order.invoice_status, "invoiced") + + return_pick.to_refund_lines = False + self.assertEqual(self.order.invoice_status, "invoiced") + self.assertTrue(return_pick.is_return) + self.assertFalse(self.picking.is_return) + + def test_return_po_wo_to_refund(self): + if not self.env.registry.models.get("purchase.order", False): + return True + order_form = Form(self.env["purchase.order"]) + order_form.partner_id = self.partner + with order_form.order_line.new() as line_form: + line_form.product_id = self.product + line_form.product_qty = 1 + po_order = order_form.save() + po_order.button_confirm() + picking = po_order.picking_ids[:] + move_line_vals = picking.move_ids._prepare_move_line_vals() + move_line_vals["quantity"] = 1 + self.env["stock.move.line"].create(move_line_vals) + picking.button_validate() + self.assertEqual(po_order.invoice_status, "to invoice") + # Return the picking without refund + return_wizard = self.return_picking_wiz(picking) + return_pick = self.picking.browse( + return_wizard.action_create_returns()["res_id"] + ) + move_line_vals = return_pick.move_ids._prepare_move_line_vals() + move_line_vals["quantity"] = 1 + self.env["stock.move.line"].create(move_line_vals) + return_pick.button_validate() + # Now set to be refunded + return_pick.to_refund_lines = "to_refund" + self.assertEqual(po_order.invoice_status, "no") + # And again to not be refunded + return_pick.to_refund_lines = "no_refund" + self.assertEqual(po_order.invoice_status, "to invoice") diff --git a/stock_picking_return_refund_option/views/stock_picking_view.xml b/stock_picking_return_refund_option/views/stock_picking_view.xml new file mode 100644 index 00000000000..7a626d3ecd0 --- /dev/null +++ b/stock_picking_return_refund_option/views/stock_picking_view.xml @@ -0,0 +1,26 @@ + + + + + + stock.picking + + + + + + + + + + + +