-
-
Notifications
You must be signed in to change notification settings - Fork 699
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by pedrobaeza
- Loading branch information
Showing
19 changed files
with
1,067 additions
and
0 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
setup/stock_picking_return_refund_option/odoo/addons/stock_picking_return_refund_option
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 @@ | ||
../../../../stock_picking_return_refund_option |
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,6 @@ | ||
import setuptools | ||
|
||
setuptools.setup( | ||
setup_requires=['setuptools-odoo'], | ||
odoo_addon=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,140 @@ | ||
================================== | ||
Stock Picking Return Refund Option | ||
================================== | ||
|
||
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |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/13.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-13-0/account-invoicing-13-0-stock_picking_return_refund_option | ||
:alt: Translate me on Weblate | ||
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png | ||
:target: https://runbot.odoo-community.org/runbot/95/13.0 | ||
:alt: Try me on Runbot | ||
|
||
|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 | ||
============ | ||
|
||
#. 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: | ||
|
||
#. Go to *Sales > Sales Orders > Create*. | ||
#. Choose a customer and add a product whose *Invoicing Policy* is *Delivered | ||
quantities*, and input some quantity to sell. | ||
#. Confirm the sale. | ||
#. Go to *Delivery > Validate > Apply*. | ||
#. Return to the sale order. | ||
#. Press *Create Invoice > Invoiceable lines > Create and View Invoices*. | ||
#. The created invoice's amount is the same you sold. | ||
#. Return to the sale order. | ||
#. Go to *Delivery > Return*. | ||
#. Set *Quantity* to a lower quantity than the sold one, and enable | ||
*To Refund*. | ||
#. Press *Return > Validate > Apply*. | ||
#. Return to the sale order. | ||
#. Press *Create Invoice > Invoiceable lines (deduct down payments) > | ||
Create and View Invoices*. | ||
#. 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: | ||
|
||
#. Go to *Purchase > Purchase Orders > Create*. | ||
#. Choose a supplier and add a product whose *Invoicing Policy* is *Delivered | ||
quantities*, and input some quantity to buy. | ||
#. Confirm the order. | ||
#. Go to *Delivery > Validate > Apply*. | ||
#. Return to the purchase order. | ||
#. Press on smart button "Invoices" and create one. | ||
#. The created invoice's amount is the same you sold. | ||
#. Return to the purchase order. | ||
#. Go to *Delivery > Return*. | ||
#. Set *Quantity* to a lower quantity than you bought, and enable | ||
*To Refund*. | ||
#. Press *Return > Validate > Apply*. | ||
#. 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 <https://github.com/OCA/account-invoicing/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 <https://github.com/OCA/account-invoicing/issues/new?body=module:%20stock_picking_return_refund_option%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. | ||
|
||
Do not contact contributors directly about support or help with technical issues. | ||
|
||
Credits | ||
======= | ||
|
||
Authors | ||
~~~~~~~ | ||
|
||
* Tecnativa | ||
|
||
Contributors | ||
~~~~~~~~~~~~ | ||
|
||
* Sergio Teruel <[email protected]> | ||
|
||
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 <https://odoo-community.org/page/maintainer-role>`__: | ||
|
||
|maintainer-sergio-teruel| | ||
|
||
This module is part of the `OCA/account-invoicing <https://github.com/OCA/account-invoicing/tree/13.0/stock_picking_return_refund_option>`_ project on GitHub. | ||
|
||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
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,3 @@ | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
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,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": "15.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"], | ||
} |
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,68 @@ | ||
# 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 | ||
#: selection:stock.picking,to_refund_lines:0 | ||
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.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 | ||
#: selection:stock.picking,to_refund_lines:0 | ||
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" | ||
|
||
#~ msgid "Stock Move" | ||
#~ msgstr "Movimiento de stock" |
52 changes: 52 additions & 0 deletions
52
stock_picking_return_refund_option/i18n/stock_picking_return_refund_option.pot
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,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 13.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 "" |
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,3 @@ | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
from . import stock_move | ||
from . import stock_picking |
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,16 @@ | ||
# 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: | ||
for move in self: | ||
if move.picking_id: | ||
move.picking_id.set_delivered_qty() | ||
move.picking_id.set_received_qty() | ||
return res |
80 changes: 80 additions & 0 deletions
80
stock_picking_return_refund_option/models/stock_picking.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,80 @@ | ||
# 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_lines.to_refund") | ||
def _compute_to_refund_lines(self): | ||
for picking in self: | ||
moves_to_refund = picking.move_lines.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_lines): | ||
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. | ||
""" | ||
for picking in self: | ||
picking._update_stock_moves() | ||
picking.set_delivered_qty() | ||
picking.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_lines | ||
) | ||
|
||
def _update_stock_moves(self): | ||
for pick in self.filtered("to_refund_lines"): | ||
pick.move_lines.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_lines.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_lines.purchase_line_id").filtered( | ||
lambda x: x.product_id.invoice_policy in ("order", "delivery") | ||
) | ||
po_lines._compute_qty_received() |
Oops, something went wrong.