mirror of
https://github.com/OCA/rma.git
synced 2025-02-16 17:11:47 +02:00
[IMP] rma_sale: operation required
The rma operation is required in the portal, and it makes sense for it to be required in the sales wizard as well
This commit is contained in:
committed by
Víctor Martínez
parent
6b1a6e3a85
commit
13ca6ec15f
@@ -17,13 +17,13 @@ Return Merchandise Authorization Management
|
||||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
|
||||
:alt: License: AGPL-3
|
||||
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Frma-lightgray.png?logo=github
|
||||
:target: https://github.com/OCA/rma/tree/17.0/rma
|
||||
:target: https://github.com/OCA/rma/tree/18.0/rma
|
||||
:alt: OCA/rma
|
||||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
|
||||
:target: https://translation.odoo-community.org/projects/rma-17-0/rma-17-0-rma
|
||||
:target: https://translation.odoo-community.org/projects/rma-18-0/rma-18-0-rma
|
||||
: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/rma&target_branch=17.0
|
||||
:target: https://runboat.odoo-community.org/builds?repo=OCA/rma&target_branch=18.0
|
||||
:alt: Try me on Runboat
|
||||
|
||||
|badge1| |badge2| |badge3| |badge4| |badge5|
|
||||
@@ -150,7 +150,7 @@ Bug Tracker
|
||||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/rma/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 <https://github.com/OCA/rma/issues/new?body=module:%20rma%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
|
||||
`feedback <https://github.com/OCA/rma/issues/new?body=module:%20rma%0Aversion:%2018.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.
|
||||
|
||||
@@ -179,6 +179,8 @@ Contributors
|
||||
- Antoni Marroig <amarroig@apsl.net>
|
||||
|
||||
- Michael Tietz (MT Software) mtietz@mt-software.de
|
||||
- Jacques-Etienne Baudoux - BCIM je@bcim.be
|
||||
- Souheil Bejaoui - ACSONE SA/NV souheil.bejaoui@acsone.eu
|
||||
|
||||
Maintainers
|
||||
-----------
|
||||
@@ -204,6 +206,6 @@ Current `maintainers <https://odoo-community.org/page/maintainer-role>`__:
|
||||
|
||||
|maintainer-pedrobaeza| |maintainer-chienandalu|
|
||||
|
||||
This module is part of the `OCA/rma <https://github.com/OCA/rma/tree/17.0/rma>`_ project on GitHub.
|
||||
This module is part of the `OCA/rma <https://github.com/OCA/rma/tree/18.0/rma>`_ project on GitHub.
|
||||
|
||||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
|
||||
|
||||
@@ -856,6 +856,7 @@ class Rma(models.Model):
|
||||
"partner_invoice_id",
|
||||
"product_id",
|
||||
"location_id",
|
||||
"operation_id",
|
||||
]
|
||||
for record in self:
|
||||
desc = ""
|
||||
|
||||
@@ -8,3 +8,5 @@
|
||||
- [APSL-Nagarro](https://www.apsl.tech):
|
||||
- Antoni Marroig \<<amarroig@apsl.net>\>
|
||||
- Michael Tietz (MT Software) <mtietz@mt-software.de>
|
||||
- Jacques-Etienne Baudoux - BCIM <je@bcim.be>
|
||||
- Souheil Bejaoui - ACSONE SA/NV <souheil.bejaoui@acsone.eu>
|
||||
|
||||
@@ -8,10 +8,11 @@
|
||||
|
||||
/*
|
||||
:Author: David Goodger (goodger@python.org)
|
||||
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
|
||||
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
|
||||
:Copyright: This stylesheet has been placed in the public domain.
|
||||
|
||||
Default cascading style sheet for the HTML output of Docutils.
|
||||
Despite the name, some widely supported CSS2 features are used.
|
||||
|
||||
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
|
||||
customize this style sheet.
|
||||
@@ -274,7 +275,7 @@ pre.literal-block, pre.doctest-block, pre.math, pre.code {
|
||||
margin-left: 2em ;
|
||||
margin-right: 2em }
|
||||
|
||||
pre.code .ln { color: grey; } /* line numbers */
|
||||
pre.code .ln { color: gray; } /* line numbers */
|
||||
pre.code, code { background-color: #eeeeee }
|
||||
pre.code .comment, code .comment { color: #5C6576 }
|
||||
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
|
||||
@@ -300,7 +301,7 @@ span.option {
|
||||
span.pre {
|
||||
white-space: pre }
|
||||
|
||||
span.problematic {
|
||||
span.problematic, pre.problematic {
|
||||
color: red }
|
||||
|
||||
span.section-subtitle {
|
||||
@@ -368,7 +369,7 @@ ul.auto-toc {
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
!! source digest: sha256:8f36869aece97a0f6af8aa5d76b446e9cf0bd589d914c1f5e12c628e87317021
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
||||
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Production/Stable" src="https://img.shields.io/badge/maturity-Production%2FStable-green.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/rma/tree/17.0/rma"><img alt="OCA/rma" src="https://img.shields.io/badge/github-OCA%2Frma-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/rma-17-0/rma-17-0-rma"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/rma&target_branch=17.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
|
||||
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Production/Stable" src="https://img.shields.io/badge/maturity-Production%2FStable-green.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/rma/tree/18.0/rma"><img alt="OCA/rma" src="https://img.shields.io/badge/github-OCA%2Frma-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/rma-18-0/rma-18-0-rma"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/rma&target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
|
||||
<p>This module allows you to manage <a class="reference external" href="https://en.wikipedia.org/wiki/Return_merchandise_authorization">Return Merchandise Authorization
|
||||
(RMA)</a>.
|
||||
RMA documents can be created from scratch, from a delivery order or from
|
||||
@@ -503,7 +504,7 @@ inside the warehouse definition.</li>
|
||||
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/rma/issues">GitHub Issues</a>.
|
||||
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
|
||||
<a class="reference external" href="https://github.com/OCA/rma/issues/new?body=module:%20rma%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
|
||||
<a class="reference external" href="https://github.com/OCA/rma/issues/new?body=module:%20rma%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
|
||||
<p>Do not contact contributors directly about support or help with technical issues.</p>
|
||||
</div>
|
||||
<div class="section" id="credits">
|
||||
@@ -531,18 +532,22 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
|
||||
</ul>
|
||||
</li>
|
||||
<li>Michael Tietz (MT Software) <a class="reference external" href="mailto:mtietz@mt-software.de">mtietz@mt-software.de</a></li>
|
||||
<li>Jacques-Etienne Baudoux - BCIM <a class="reference external" href="mailto:je@bcim.be">je@bcim.be</a></li>
|
||||
<li>Souheil Bejaoui - ACSONE SA/NV <a class="reference external" href="mailto:souheil.bejaoui@acsone.eu">souheil.bejaoui@acsone.eu</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="maintainers">
|
||||
<h2><a class="toc-backref" href="#toc-entry-8">Maintainers</a></h2>
|
||||
<p>This module is maintained by the OCA.</p>
|
||||
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
|
||||
<a class="reference external image-reference" href="https://odoo-community.org">
|
||||
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
|
||||
</a>
|
||||
<p>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.</p>
|
||||
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainers</a>:</p>
|
||||
<p><a class="reference external image-reference" href="https://github.com/pedrobaeza"><img alt="pedrobaeza" src="https://github.com/pedrobaeza.png?size=40px" /></a> <a class="reference external image-reference" href="https://github.com/chienandalu"><img alt="chienandalu" src="https://github.com/chienandalu.png?size=40px" /></a></p>
|
||||
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/rma/tree/17.0/rma">OCA/rma</a> project on GitHub.</p>
|
||||
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/rma/tree/18.0/rma">OCA/rma</a> project on GitHub.</p>
|
||||
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -71,8 +71,11 @@ class TestRma(BaseCommon):
|
||||
cls.warehouse = cls.env.ref("stock.warehouse0")
|
||||
# Ensure grouping
|
||||
cls.env.company.rma_return_grouping = True
|
||||
cls.operation = cls.env.ref("rma.rma_operation_replace")
|
||||
|
||||
def _create_rma(self, partner=None, product=None, qty=None, location=None):
|
||||
def _create_rma(
|
||||
self, partner=None, product=None, qty=None, location=None, operation=None
|
||||
):
|
||||
vals = {}
|
||||
if partner:
|
||||
vals["partner_id"] = partner.id
|
||||
@@ -82,14 +85,17 @@ class TestRma(BaseCommon):
|
||||
vals["product_uom_qty"] = qty
|
||||
if location:
|
||||
vals["location_id"] = location.id
|
||||
|
||||
if operation:
|
||||
vals["operation_id"] = operation.id
|
||||
elif operation is None:
|
||||
vals["operation_id"] = self.operation.id
|
||||
vals["user_id"] = self.env.user.id
|
||||
return self.env["rma"].create(vals)
|
||||
|
||||
def _create_confirm_receive(
|
||||
self, partner=None, product=None, qty=None, location=None
|
||||
self, partner=None, product=None, qty=None, location=None, operation=None
|
||||
):
|
||||
rma = self._create_rma(partner, product, qty, location)
|
||||
rma = self._create_rma(partner, product, qty, location, operation)
|
||||
rma.action_confirm()
|
||||
rma.reception_move_id.quantity = rma.product_uom_qty
|
||||
rma.reception_move_id.picking_id.button_validate()
|
||||
@@ -221,19 +227,26 @@ class TestRmaCase(TestRma):
|
||||
self.assertEqual(rma.product_uom, self.product.uom_id)
|
||||
|
||||
def test_ensure_required_fields_on_confirm(self):
|
||||
rma = self._create_rma()
|
||||
rma = self._create_rma(operation=False)
|
||||
with self.assertRaises(ValidationError) as e:
|
||||
rma.action_confirm()
|
||||
self.assertEqual(
|
||||
e.exception.args[0],
|
||||
"Required field(s):\nCustomer\nShipping Address\nInvoice Address\nProduct",
|
||||
"Required field(s):\nCustomer\nShipping Address\nInvoice Address\nProduct"
|
||||
"\nRequested operation",
|
||||
)
|
||||
rma.partner_id = self.partner.id
|
||||
with self.assertRaises(ValidationError) as e:
|
||||
rma.action_confirm()
|
||||
self.assertEqual(e.exception.args[0], "Required field(s):\nProduct")
|
||||
self.assertEqual(
|
||||
e.exception.args[0], "Required field(s):\nProduct\nRequested operation"
|
||||
)
|
||||
rma.product_id = self.product.id
|
||||
rma.location_id = self.rma_loc.id
|
||||
with self.assertRaises(ValidationError) as e:
|
||||
rma.action_confirm()
|
||||
self.assertEqual(e.exception.args[0], "Required field(s):\nRequested operation")
|
||||
rma.operation_id = self.operation
|
||||
rma.action_confirm()
|
||||
self.assertEqual(rma.state, "confirmed")
|
||||
|
||||
@@ -670,6 +683,7 @@ class TestRmaCase(TestRma):
|
||||
)
|
||||
)
|
||||
stock_return_picking_form.create_rma = True
|
||||
stock_return_picking_form.rma_operation_id = self.operation
|
||||
return_wizard = stock_return_picking_form.save()
|
||||
picking_action = return_wizard.create_returns()
|
||||
# Each origin move is linked to a different RMA
|
||||
@@ -698,6 +712,7 @@ class TestRmaCase(TestRma):
|
||||
rma_form.move_id = origin_delivery.move_ids.filtered(
|
||||
lambda r: r.product_id == self.product
|
||||
)
|
||||
rma_form.operation_id = self.operation
|
||||
rma = rma_form.save()
|
||||
rma.action_confirm()
|
||||
rma.reception_move_id.quantity = 10
|
||||
|
||||
@@ -11,6 +11,20 @@ from odoo.tools import float_compare
|
||||
class ReturnPickingLine(models.TransientModel):
|
||||
_inherit = "stock.return.picking.line"
|
||||
|
||||
rma_operation_id = fields.Many2one(
|
||||
comodel_name="rma.operation",
|
||||
string="Operation",
|
||||
compute="_compute_rma_operation_id",
|
||||
store=True,
|
||||
readonly=False,
|
||||
)
|
||||
|
||||
@api.depends("wizard_id.rma_operation_id")
|
||||
def _compute_rma_operation_id(self):
|
||||
for rec in self:
|
||||
if rec.wizard_id.rma_operation_id:
|
||||
rec.rma_operation_id = rec.wizard_id.rma_operation_id
|
||||
|
||||
def _prepare_rma_vals(self):
|
||||
self.ensure_one()
|
||||
return {
|
||||
@@ -19,6 +33,7 @@ class ReturnPickingLine(models.TransientModel):
|
||||
"product_uom_qty": self.quantity,
|
||||
"product_uom": self.product_id.uom_id.id,
|
||||
"location_id": self.wizard_id.location_id.id or self.move_id.location_id.id,
|
||||
"operation_id": self.rma_operation_id.id,
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +45,10 @@ class ReturnPicking(models.TransientModel):
|
||||
rma_location_ids = fields.Many2many(
|
||||
comodel_name="stock.location", compute="_compute_rma_location_id"
|
||||
)
|
||||
rma_operation_id = fields.Many2one(
|
||||
comodel_name="rma.operation",
|
||||
string="Requested operation",
|
||||
)
|
||||
# Expand domain for RMAs
|
||||
location_id = fields.Many2one(
|
||||
domain="create_rma and [('id', 'child_of', rma_location_ids)]"
|
||||
|
||||
@@ -8,12 +8,20 @@
|
||||
<field name="model">stock.return.picking</field>
|
||||
<field name="inherit_id" ref="stock.view_stock_return_picking_form" />
|
||||
<field name="arch" type="xml">
|
||||
<field name="product_return_moves" position="after">
|
||||
<xpath expr="//field[@name='product_return_moves']//tree" position="inside">
|
||||
<field
|
||||
name="rma_operation_id"
|
||||
required="parent.create_rma and quantity>0"
|
||||
column_invisible="not parent.create_rma"
|
||||
/>
|
||||
</xpath>
|
||||
<field name="product_return_moves" position="before">
|
||||
<group name="group_rma">
|
||||
<field
|
||||
name="create_rma"
|
||||
invisible="picking_type_code != 'outgoing'"
|
||||
/>
|
||||
<field name="rma_operation_id" invisible="not create_rma" />
|
||||
<field name="rma_location_ids" invisible="1" />
|
||||
<field name="picking_id" invisible="1" />
|
||||
<field name="picking_type_code" invisible="1" />
|
||||
|
||||
Reference in New Issue
Block a user