-
-
Notifications
You must be signed in to change notification settings - Fork 235
[IMP] rma_sale: manually link RMAs to sale orders #585
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 16.0
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -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" | ||||||
| type="object" | ||||||
| string="Link to sale order" | ||||||
| attrs="{'invisible': [('move_id', '!=', False)]}" | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| /> | ||||||
| </header> | ||||||
| <field name="partner_invoice_id" position="after"> | ||||||
| <field | ||||||
| name="order_id" | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,3 +2,4 @@ | |
|
|
||
| from . import sale_order_rma_wizard | ||
| from . import stock_picking_return | ||
| from . import rma_sale_order_link_wizard | ||
| 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( | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
| 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 | ||
| ) | ||
| ) | ||
| 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> | ||||
|
|
||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||
| </odoo> | ||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.