Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions rma_sale/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"views/sale_portal_template.xml",
"views/res_config_settings_views.xml",
"wizard/sale_order_rma_wizard_views.xml",
"wizard/rma_sale_order_link_wizard.xml",
],
"assets": {
"web.assets_frontend": [
Expand Down
49 changes: 49 additions & 0 deletions rma_sale/i18n/fr.po
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ msgid "Allowed Quantity"
msgstr ""

#. module: rma_sale
#: model_terms:ir.ui.view,arch_db:rma_sale.rma_sale_order_link_wizard_form_view
#: model_terms:ir.ui.view,arch_db:rma_sale.sale_order_rma_wizard_form_view
msgid "Cancel"
msgstr "Annuler"
Expand Down Expand Up @@ -158,6 +159,11 @@ msgstr "Sociétés"
msgid "Config Settings"
msgstr "Paramètres de configuration"

#. module: rma_sale
#: model_terms:ir.ui.view,arch_db:rma_sale.rma_sale_order_link_wizard_form_view
msgid "Confirm"
msgstr "Confirmer"

#. module: rma_sale
#: model:ir.model.fields,help:rma_sale.field_sale_order_line_rma_wizard__uom_category_id
msgid ""
Expand All @@ -182,12 +188,14 @@ msgid "Create RMAs"
msgstr "Créer RMA"

#. module: rma_sale
#: model:ir.model.fields,field_description:rma_sale.field_rma_sale_order_link_wizard__create_uid
#: model:ir.model.fields,field_description:rma_sale.field_sale_order_line_rma_wizard__create_uid
#: model:ir.model.fields,field_description:rma_sale.field_sale_order_rma_wizard__create_uid
msgid "Created by"
msgstr "Créé par"

#. module: rma_sale
#: model:ir.model.fields,field_description:rma_sale.field_rma_sale_order_link_wizard__create_date
#: model:ir.model.fields,field_description:rma_sale.field_sale_order_line_rma_wizard__create_date
#: model:ir.model.fields,field_description:rma_sale.field_sale_order_rma_wizard__create_date
msgid "Created on"
Expand All @@ -198,6 +206,11 @@ msgstr "Créé le"
msgid "Custom Description"
msgstr "Description personnalisée"

#. module: rma_sale
#: model:ir.model.fields,field_description:rma_sale.field_rma_sale_order_link_wizard__partner_id
msgid "Customer"
msgstr "Client"

#. module: rma_sale
#: model_terms:ir.ui.view,arch_db:rma_sale.sale_rma_request_form
msgid "Delivery"
Expand All @@ -219,6 +232,7 @@ msgid "Different Return Product"
msgstr ""

#. module: rma_sale
#: model:ir.model.fields,field_description:rma_sale.field_rma_sale_order_link_wizard__display_name
#: model:ir.model.fields,field_description:rma_sale.field_sale_order_line_rma_wizard__display_name
#: model:ir.model.fields,field_description:rma_sale.field_sale_order_rma_wizard__display_name
msgid "Display Name"
Expand All @@ -241,6 +255,7 @@ msgid "Full page RMA creation"
msgstr "Création RMA pleine page"

#. module: rma_sale
#: model:ir.model.fields,field_description:rma_sale.field_rma_sale_order_link_wizard__id
#: model:ir.model.fields,field_description:rma_sale.field_sale_order_line_rma_wizard__id
#: model:ir.model.fields,field_description:rma_sale.field_sale_order_rma_wizard__id
msgid "ID"
Expand All @@ -266,18 +281,21 @@ msgid "Journal Entry"
msgstr "Pièce comptable"

#. module: rma_sale
#: model:ir.model.fields,field_description:rma_sale.field_rma_sale_order_link_wizard____last_update
#: model:ir.model.fields,field_description:rma_sale.field_sale_order_line_rma_wizard____last_update
#: model:ir.model.fields,field_description:rma_sale.field_sale_order_rma_wizard____last_update
msgid "Last Modified on"
msgstr "Dernière modification le"

#. module: rma_sale
#: model:ir.model.fields,field_description:rma_sale.field_rma_sale_order_link_wizard__write_uid
#: model:ir.model.fields,field_description:rma_sale.field_sale_order_line_rma_wizard__write_uid
#: model:ir.model.fields,field_description:rma_sale.field_sale_order_rma_wizard__write_uid
msgid "Last Updated by"
msgstr "Dernière modification par"

#. module: rma_sale
#: model:ir.model.fields,field_description:rma_sale.field_rma_sale_order_link_wizard__write_date
#: model:ir.model.fields,field_description:rma_sale.field_sale_order_line_rma_wizard__write_date
#: model:ir.model.fields,field_description:rma_sale.field_sale_order_rma_wizard__write_date
msgid "Last Updated on"
Expand All @@ -288,6 +306,14 @@ msgstr ""
msgid "Lines"
msgstr "Lignes"

#. module: rma_sale
#. odoo-python
#: code:addons/rma_sale/models/rma.py:0
#: model_terms:ir.ui.view,arch_db:rma_sale.rma_view_form
#, python-format
msgid "Link to sale order"
msgstr "Lier à la commande client"

#. module: rma_sale
#: model:ir.model.fields,field_description:rma_sale.field_sale_order_line_rma_wizard__move_id
msgid "Move"
Expand Down Expand Up @@ -386,6 +412,16 @@ msgstr ""
msgid "Return Product"
msgstr ""

#. module: rma_sale
#: model:ir.model.fields,field_description:rma_sale.field_rma_sale_order_link_wizard__rma_id
msgid "Rma"
msgstr ""

#. module: rma_sale
#: model_terms:ir.ui.view,arch_db:rma_sale.rma_sale_order_link_wizard_form_view
msgid "Rma Sale Order Link Wizard"
msgstr ""

#. module: rma_sale
#: model:ir.model.fields,field_description:rma_sale.field_rma__sale_line_id
#: model:ir.model.fields,field_description:rma_sale.field_sale_order_line_rma_wizard__sale_line_id
Expand All @@ -394,9 +430,17 @@ msgstr "Ligne de commande"

#. module: rma_sale
#: model:ir.model.fields,field_description:rma_sale.field_rma__order_id
#: model:ir.model.fields,field_description:rma_sale.field_rma_sale_order_link_wizard__sale_order_id
msgid "Sale Order"
msgstr "Bon de commande"

#. module: rma_sale
#. odoo-python
#: code:addons/rma_sale/wizard/rma_sale_order_link_wizard.py:0
#, python-format
msgid "Sale Order %(order)s linked manually."
msgstr "Commande client %(order)s liée manuellement."

#. module: rma_sale
#: model:ir.model,name:rma_sale.model_sale_order_line_rma_wizard
msgid "Sale Order Line Rma Wizard"
Expand Down Expand Up @@ -489,6 +533,11 @@ msgstr "Sera utilisé pour retourner les marchandises une fois le RMA terminé"
msgid "Wizard"
msgstr ""

#. module: rma_sale
#: model:ir.model,name:rma_sale.model_rma_sale_order_link_wizard
msgid "Wizard to link existing rma to sale order"
msgstr ""

#. module: rma_sale
#: model_terms:ir.ui.view,arch_db:rma_sale.sale_rma_request_form
msgid ""
Expand Down
13 changes: 12 additions & 1 deletion rma_sale/models/rma.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Copyright 2023 Tecnativa - Pedro M. Baeza
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import api, fields, models
from odoo import _, api, fields, models
from odoo.tools import float_compare


Expand Down Expand Up @@ -219,3 +219,14 @@ def create_replace(self, scheduled_date, warehouse, product, qty, uom):
new_moves = self.delivery_move_ids - moves_before
new_moves.picking_id.sale_id = False
return res

def action_link_to_sale_order(self):
self.ensure_one()
return {
"name": _("Link to sale order"),
"type": "ir.actions.act_window",
"view_mode": "form",
"res_model": "rma.sale.order.link.wizard",
"target": "new",
"context": {"default_rma_id": self.id, **self.env.context},
}
1 change: 1 addition & 0 deletions rma_sale/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_sale_order_rma_wizard_user_all,sale.order.rma.wizard.user.all,model_sale_order_rma_wizard,rma.rma_group_user_all,1,1,1,1
access_sale_order_line_rma_wizard_user_all,sale.order.line.rma.wizard.user.all,model_sale_order_line_rma_wizard,rma.rma_group_user_all,1,1,1,1
access_rma_sale_order_link_wizard_user_all,sale.order.rma.wizard.user.all,model_rma_sale_order_link_wizard,rma.rma_group_user_all,1,1,1,1
21 changes: 21 additions & 0 deletions rma_sale/tests/test_rma_sale.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,3 +336,24 @@ def test_grouping_reception(self):
rmas = self.env["rma"].search(wizard.create_and_open_rma()["domain"])
self.assertEqual(len(rmas.reception_move_id.group_id), 1)
self.assertEqual(len(rmas.reception_move_id.picking_id), 1)

def test_link_to_sale_order(self):
rma_vals = {
"partner_id": self.partner.id,
"product_id": self.product_1.id,
"product_uom_qty": 5,
"location_id": self.sale_order.warehouse_id.rma_loc_id.id,
"operation_id": self.operation.id,
}
rma = self.env["rma"].create(rma_vals)
rma.action_confirm()
action = rma.action_link_to_sale_order()
wizard = (
self.env[action.get("res_model")]
.with_context(**action.get("context"))
.create({"sale_order_id": self.sale_order.id})
)
self.assertEqual(wizard.rma_id, rma)
self.assertFalse(rma.order_id)
wizard.action_link_rma_to_sale_order()
self.assertEqual(rma.order_id, self.sale_order)
8 changes: 8 additions & 0 deletions rma_sale/views/rma_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@
<field name="model">rma</field>
<field name="inherit_id" ref="rma.rma_view_form" />
<field name="arch" type="xml">
<header position="inside">
<button
name="action_link_to_sale_order"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
name="action_link_to_sale_order"
name="action_link_to_sale_order"
groups="sales_team.group_sale_salesman"

type="object"
string="Link to sale order"
attrs="{'invisible': [('move_id', '!=', False)]}"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
attrs="{'invisible': [('move_id', '!=', False)]}"
attrs="{'invisible': ['|', ('id', '=', False),('order_id', '!=', False)]}"

/>
</header>
<field name="partner_invoice_id" position="after">
<field
name="order_id"
Expand Down
1 change: 1 addition & 0 deletions rma_sale/wizard/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@

from . import sale_order_rma_wizard
from . import stock_picking_return
from . import rma_sale_order_link_wizard
29 changes: 29 additions & 0 deletions rma_sale/wizard/rma_sale_order_link_wizard.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Copyright 2026 ACSONE SA/NV
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import _, fields, models


class RmaSaleOrderLinkWizard(models.TransientModel):

_name = "rma.sale.order.link.wizard"
_description = "Wizard to link existing rma to sale order"

rma_id = fields.Many2one(comodel_name="rma")
partner_id = fields.Many2one(related="rma_id.partner_id")
sale_order_id = fields.Many2one(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my opinion, the best approach would be to select sales order lines (by filtering by product) and, within the action_link_rma_to_sale_order() method, also define the appropriate move_id to ensure that all data is consistent.

comodel_name="sale.order",
string="Sale Order",
required=True,
ondelete="cascade",
domain="[('partner_id', '=', partner_id), ('state', 'in', ('sale', 'done'))]",
)

def action_link_rma_to_sale_order(self):
self.ensure_one()
self.rma_id.order_id = self.sale_order_id
self.rma_id.message_post(
body=_(
"Sale Order %(order)s linked manually.", order=self.sale_order_id.name
)
)
30 changes: 30 additions & 0 deletions rma_sale/wizard/rma_sale_order_link_wizard.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2026 ACSONE SA/NV
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
<odoo>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

<record model="ir.ui.view" id="rma_sale_order_link_wizard_form_view">
<field name="model">rma.sale.order.link.wizard</field>
<field name="arch" type="xml">
<form string="Rma Sale Order Link Wizard">
<group>
<field name="rma_id" invisible="1" />
<field name="partner_id" readonly="True" />
<field name="sale_order_id" />
</group>
<footer>
<button
name="action_link_rma_to_sale_order"
string="Confirm"
class="btn-primary"
type="object"
/>
<button string="Cancel" class="btn-default" special="cancel" />
</footer>
</form>
</field>
</record>



Comment on lines +27 to +29
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

</odoo>
Loading