-
Notifications
You must be signed in to change notification settings - Fork 41
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
1 parent
d53b227
commit d1505d3
Showing
17 changed files
with
248 additions
and
4 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
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,34 @@ | ||
.. image:: https://img.shields.io/badge/licence-LGPL--3-blue.svg | ||
:alt: License LGPL-3 | ||
|
||
==================== | ||
RMA Product Exchange | ||
==================== | ||
|
||
This module allows you to: | ||
|
||
#. to exchange one product for another in an RMA. | ||
|
||
Usage | ||
===== | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues | ||
<https://github.com/Eficent/stock-rma/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 | ||
======= | ||
|
||
Contributors | ||
------------ | ||
|
||
* Chafique DELLI <[email protected]> | ||
|
||
Maintainer | ||
---------- | ||
|
||
This module is maintained by Eficent |
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,2 @@ | ||
from . import models | ||
from . import wizards |
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 @@ | ||
# Copyright 2024 Akretion | ||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) | ||
|
||
{ | ||
"name": "RMA Product Exchange", | ||
"version": "16.0.1.0.0", | ||
"license": "LGPL-3", | ||
"category": "RMA", | ||
"summary": "Manage RMA for product exchange", | ||
"author": "Akretion, ForgeFlow", | ||
"website": "https://github.com/ForgeFlow/stock-rma", | ||
"depends": [ | ||
"rma", | ||
], | ||
"data": [ | ||
"views/rma_order_view.xml", | ||
"views/rma_operation_view.xml", | ||
"views/rma_order_line_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,3 @@ | ||
from . import rma_order_line | ||
from . import rma_operation | ||
from . import procurement_group |
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,20 @@ | ||
# Copyright 2024 Akretion | ||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) | ||
from odoo import api, models | ||
|
||
|
||
class ProcurementGroup(models.Model): | ||
_inherit = "procurement.group" | ||
|
||
@api.model | ||
def run(self, procurements, raise_user_error=True): | ||
if self.env.context.get("rma_item"): | ||
new_procurements = [] | ||
for procurement in procurements: | ||
new_procurements.append( | ||
procurement._replace( | ||
product_id=self._context.get("rma_item").product_id | ||
) | ||
) | ||
procurements = new_procurements | ||
return super().run(procurements, raise_user_error=raise_user_error) |
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,11 @@ | ||
# Copyright 2024 Akretion | ||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) | ||
from odoo import fields, models | ||
|
||
|
||
class RmaOperation(models.Model): | ||
_inherit = "rma.operation" | ||
|
||
product_exchange = fields.Boolean( | ||
help="Check if you wish to authorize product exchange.", default=False | ||
) |
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,13 @@ | ||
# Copyright 2024 Akretion | ||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) | ||
from odoo import fields, models | ||
|
||
|
||
class RmaOrderLine(models.Model): | ||
_inherit = "rma.order.line" | ||
|
||
new_product_id = fields.Many2one( | ||
comodel_name="product.product", | ||
tracking=True, | ||
) | ||
product_exchange = fields.Boolean(related="operation_id.product_exchange") |
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 @@ | ||
from . import test_rma_product_exchange |
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,28 @@ | ||
# Copyright 2024 Akretion | ||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) | ||
|
||
from odoo.addons.rma.tests.test_rma import TestRma | ||
|
||
|
||
class TestRmaProductExchange(TestRma): | ||
@classmethod | ||
def setUpClass(cls): | ||
super().setUpClass() | ||
|
||
def test_customer_rma_with_product_exchange(self): | ||
self.rma_cust_replace_op_id.product_exchange = True | ||
self.rma_customer_id.rma_line_ids.delivery_policy = "ordered" | ||
self.rma_customer_id.rma_line_ids[0].new_product_id = self.product_id | ||
self.rma_customer_id.rma_line_ids.action_rma_to_approve() | ||
wizard = self.rma_make_picking.with_context( | ||
**{ | ||
"active_ids": self.rma_customer_id.rma_line_ids.ids, | ||
"active_model": "rma.order.line", | ||
"picking_type": "outgoing", | ||
"active_id": 1, | ||
} | ||
).create({}) | ||
wizard._create_picking() | ||
res = self.rma_customer_id.action_view_out_shipments() | ||
picking = self.env["stock.picking"].browse(res["res_id"]) | ||
self.assertEqual(picking.move_ids[0].product_id, self.product_id) |
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,24 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<odoo> | ||
|
||
<record id="rma_operation_tree" model="ir.ui.view"> | ||
<field name="model">rma.operation</field> | ||
<field name="inherit_id" ref="rma.rma_operation_tree" /> | ||
<field name="arch" type="xml"> | ||
<field name="delivery_policy" position="after"> | ||
<field name="product_exchange" optional="show" /> | ||
</field> | ||
</field> | ||
</record> | ||
|
||
<record id="rma_operation_form" model="ir.ui.view"> | ||
<field name="model">rma.operation</field> | ||
<field name="inherit_id" ref="rma.rma_operation_form" /> | ||
<field name="arch" type="xml"> | ||
<xpath expr="//group[@name='policies']" position="inside"> | ||
<field name="product_exchange" /> | ||
</xpath> | ||
</field> | ||
</record> | ||
|
||
</odoo> |
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" encoding="utf-8" ?> | ||
<odoo> | ||
|
||
<record id="view_rma_line_form" model="ir.ui.view"> | ||
<field name="model">rma.order.line</field> | ||
<field name="inherit_id" ref="rma.view_rma_line_form" /> | ||
<field name="arch" type="xml"> | ||
<xpath | ||
expr="//group[@name='product']/field[@name='product_id']" | ||
position="after" | ||
> | ||
<field name="product_exchange" invisible="True" /> | ||
<field | ||
name="new_product_id" | ||
attrs="{'invisible':['|',('operation_id', '=', False),('product_exchange', '=', False)]}" | ||
/> | ||
</xpath> | ||
</field> | ||
</record> | ||
|
||
</odoo> |
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,19 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<odoo> | ||
<record id="view_rma_form" model="ir.ui.view"> | ||
<field name="model">rma.order</field> | ||
<field name="inherit_id" ref="rma.view_rma_form" /> | ||
<field name="arch" type="xml"> | ||
<xpath | ||
expr="//field[@name='rma_line_ids']/tree/field[@name='product_id']" | ||
position="after" | ||
> | ||
<field name="product_exchange" invisible="True" /> | ||
<field | ||
name="new_product_id" | ||
attrs="{'invisible':['|',('operation_id', '=', False),('product_exchange', '=', False)]}" | ||
/> | ||
</xpath> | ||
</field> | ||
</record> | ||
</odoo> |
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 @@ | ||
from . import rma_make_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,36 @@ | ||
# Copyright (C) 2024 Akretion | ||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) | ||
|
||
from odoo import api, models | ||
|
||
|
||
class RmaMakePicking(models.TransientModel): | ||
_inherit = "rma_make_picking.wizard" | ||
|
||
@api.returns("rma.order.line") | ||
def _prepare_item(self, line): | ||
values = super()._prepare_item(line) | ||
if ( | ||
self.env.context.get("picking_type") == "outgoing" | ||
and line.product_exchange | ||
and line.new_product_id | ||
): | ||
values["product_id"] = line.new_product_id.id | ||
return values | ||
|
||
@api.model | ||
def _create_procurement(self, item, picking_type): | ||
if self.env.context.get("picking_type") == "outgoing": | ||
self = self.with_context(rma_item=item) | ||
return super()._create_procurement(item, picking_type) | ||
|
||
@api.model | ||
def _get_product(self, item): | ||
product = super()._get_product(item) | ||
if ( | ||
self.env.context.get("picking_type") == "outgoing" | ||
and item.line_id.product_exchange | ||
and item.line_id.new_product_id | ||
): | ||
product = item.line_id.new_product_id | ||
return product |
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 @@ | ||
../../../../rma_product_exchange |
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, | ||
) |