mirror of
https://github.com/OCA/rma.git
synced 2025-02-16 17:11:47 +02:00
[MIG] rma: Migration to 14.0
This commit is contained in:
committed by
Florian da Costa
parent
a4f201a8ca
commit
b9538d5c35
@@ -14,13 +14,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/13.0/rma
|
||||
:target: https://github.com/OCA/rma/tree/14.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-13-0/rma-13-0-rma
|
||||
:target: https://translation.odoo-community.org/projects/rma-14-0/rma-14-0-rma
|
||||
:alt: Translate me on Weblate
|
||||
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
|
||||
:target: https://runbot.odoo-community.org/runbot/145/13.0
|
||||
:target: https://runbot.odoo-community.org/runbot/145/14.0
|
||||
:alt: Try me on Runbot
|
||||
|
||||
|badge1| |badge2| |badge3| |badge4| |badge5|
|
||||
@@ -120,7 +120,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 smashing it by providing a detailed and welcomed
|
||||
`feedback <https://github.com/OCA/rma/issues/new?body=module:%20rma%0Aversion:%2013.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:%2014.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.
|
||||
|
||||
@@ -141,6 +141,8 @@ Contributors
|
||||
* Pedro M. Baeza
|
||||
* David Vidal
|
||||
|
||||
* Chafique Delli <chafique.delli@akretion.com>
|
||||
|
||||
Maintainers
|
||||
~~~~~~~~~~~
|
||||
|
||||
@@ -162,6 +164,6 @@ Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
|
||||
|
||||
|maintainer-ernestotejeda|
|
||||
|
||||
This module is part of the `OCA/rma <https://github.com/OCA/rma/tree/13.0/rma>`_ project on GitHub.
|
||||
This module is part of the `OCA/rma <https://github.com/OCA/rma/tree/14.0/rma>`_ project on GitHub.
|
||||
|
||||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
|
||||
|
||||
@@ -46,7 +46,6 @@ class PortalRma(CustomerPortal):
|
||||
if not sortby:
|
||||
sortby = "date"
|
||||
order = searchbar_sortings[sortby]["order"]
|
||||
archive_groups = self._get_archive_groups("rma", domain)
|
||||
if date_begin and date_end:
|
||||
domain += [
|
||||
("create_date", ">", date_begin),
|
||||
@@ -77,7 +76,6 @@ class PortalRma(CustomerPortal):
|
||||
"rmas": rmas,
|
||||
"page_name": "RMA",
|
||||
"pager": pager,
|
||||
"archive_groups": archive_groups,
|
||||
"default_url": "/my/rmas",
|
||||
"searchbar_sortings": searchbar_sortings,
|
||||
"sortby": sortby,
|
||||
@@ -118,7 +116,7 @@ class PortalRma(CustomerPortal):
|
||||
except exceptions.AccessError:
|
||||
return request.redirect("/my")
|
||||
report_sudo = request.env.ref("stock.action_report_delivery").sudo()
|
||||
pdf = report_sudo.render_qweb_pdf([picking_sudo.id])[0]
|
||||
pdf = report_sudo._render_qweb_pdf([picking_sudo.id])[0]
|
||||
pdfhttpheaders = [
|
||||
("Content-Type", "application/pdf"),
|
||||
("Content-Length", len(pdf)),
|
||||
|
||||
@@ -42,7 +42,6 @@
|
||||
<field name="report_template" ref="report_rma_action" />
|
||||
<field name="report_name">${(object.name or '')}</field>
|
||||
<field name="lang">${object.partner_id.lang}</field>
|
||||
<field name="user_signature" eval="True" />
|
||||
<field name="auto_delete" eval="True" />
|
||||
<field name="body_html" type="html">
|
||||
<div style="margin: 0px; padding: 0px;">
|
||||
|
||||
@@ -27,7 +27,7 @@ class AccountMove(models.Model):
|
||||
)
|
||||
)
|
||||
|
||||
def post(self):
|
||||
def action_post(self):
|
||||
"""Avoids to validate a refund with less quantity of product than
|
||||
quantity in the linked RMA.
|
||||
"""
|
||||
@@ -38,7 +38,7 @@ class AccountMove(models.Model):
|
||||
"less than the quantity specified in its linked RMA."
|
||||
)
|
||||
)
|
||||
return super().post()
|
||||
return super().action_post()
|
||||
|
||||
def unlink(self):
|
||||
rma = self.mapped("invoice_line_ids.rma_id")
|
||||
|
||||
@@ -249,6 +249,7 @@ class Rma(models.Model):
|
||||
digits="Product Unit of Measure",
|
||||
compute="_compute_remaining_qty",
|
||||
)
|
||||
uom_category_id = fields.Many2one(related="product_id.uom_id.category_id")
|
||||
# Split fields
|
||||
can_be_split = fields.Boolean(
|
||||
compute="_compute_can_be_split",
|
||||
@@ -481,12 +482,8 @@ class Rma(models.Model):
|
||||
|
||||
@api.onchange("product_id")
|
||||
def _onchange_product_id(self):
|
||||
domain_product_uom = []
|
||||
if self.product_id:
|
||||
# Set UoM and UoM domain (product_uom)
|
||||
domain_product_uom = [
|
||||
("category_id", "=", self.product_id.uom_id.category_id.id)
|
||||
]
|
||||
# Set UoM
|
||||
if not self.product_uom or self.product_id.uom_id.id != self.product_uom.id:
|
||||
self.product_uom = self.product_id.uom_id
|
||||
# Set stock location (location_id)
|
||||
@@ -501,7 +498,6 @@ class Rma(models.Model):
|
||||
[("company_id", "=", company.id)], limit=1
|
||||
)
|
||||
self.location_id = warehouse.rma_loc_id.id
|
||||
return {"domain": {"product_uom": domain_product_uom}}
|
||||
|
||||
# CRUD methods (ORM overrides)
|
||||
@api.model_create_multi
|
||||
@@ -510,9 +506,7 @@ class Rma(models.Model):
|
||||
if vals.get("name", _("New")) == _("New"):
|
||||
ir_sequence = self.env["ir.sequence"]
|
||||
if "company_id" in vals:
|
||||
ir_sequence = ir_sequence.with_context(
|
||||
force_company=vals["company_id"]
|
||||
)
|
||||
ir_sequence = ir_sequence.with_company(vals["company_id"])
|
||||
vals["name"] = ir_sequence.next_by_code("rma")
|
||||
# Assign a default team_id which will be the first in the sequence
|
||||
if "team_id" not in vals:
|
||||
@@ -600,7 +594,7 @@ class Rma(models.Model):
|
||||
origin = ", ".join(rmas.mapped("name"))
|
||||
invoice_form = Form(
|
||||
self.env["account.move"].with_context(
|
||||
default_type="out_refund",
|
||||
default_move_type="out_refund",
|
||||
company_id=rmas[0].company_id.id,
|
||||
),
|
||||
"account.view_move_form",
|
||||
@@ -1056,6 +1050,8 @@ class Rma(models.Model):
|
||||
move_orig_ids=[(4, rma.reception_move_id.id)],
|
||||
company_id=picking.company_id.id,
|
||||
)
|
||||
if "product_qty" in move_vals:
|
||||
move_vals.pop("product_qty")
|
||||
self.env["stock.move"].sudo().create(move_vals)
|
||||
rma.message_post(
|
||||
body=_(
|
||||
@@ -1084,7 +1080,7 @@ class Rma(models.Model):
|
||||
move_form.product_id = self.product_id
|
||||
move_form.product_uom_qty = quantity or self.product_uom_qty
|
||||
move_form.product_uom = uom or self.product_uom
|
||||
move_form.date_expected = scheduled_date
|
||||
move_form.date = scheduled_date
|
||||
|
||||
# Replacing business methods
|
||||
def create_replace(self, scheduled_date, warehouse, product, qty, uom):
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
# Copyright 2020 Tecnativa - Ernesto Tejeda
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
|
||||
import ast
|
||||
|
||||
from odoo import _, fields, models
|
||||
|
||||
|
||||
@@ -51,10 +53,12 @@ class RmaTeam(models.Model):
|
||||
)
|
||||
return team
|
||||
|
||||
def get_alias_model_name(self, vals):
|
||||
return vals.get("alias_model", "rma")
|
||||
|
||||
def get_alias_values(self):
|
||||
values = super().get_alias_values()
|
||||
values["alias_defaults"] = {"team_id": self.id}
|
||||
def _alias_get_creation_values(self):
|
||||
values = super()._alias_get_creation_values()
|
||||
values["alias_model_id"] = self.env.ref("rma.model_rma").id
|
||||
if self.id:
|
||||
values["alias_defaults"] = defaults = ast.literal_eval(
|
||||
self.alias_defaults or "{}"
|
||||
)
|
||||
defaults["team_id"] = self.id
|
||||
return values
|
||||
|
||||
@@ -3,3 +3,5 @@
|
||||
* Ernesto Tejeda
|
||||
* Pedro M. Baeza
|
||||
* David Vidal
|
||||
|
||||
* Chafique Delli <chafique.delli@akretion.com>
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<odoo>
|
||||
<data>
|
||||
<report
|
||||
id="report_rma_action"
|
||||
string="RMA Report"
|
||||
model="rma"
|
||||
report_type="qweb-pdf"
|
||||
file="rma.report_rma"
|
||||
name="rma.report_rma"
|
||||
print_report_name="object._get_report_base_filename()"
|
||||
/>
|
||||
</data>
|
||||
<record id="report_rma_action" model="ir.actions.report">
|
||||
<field name="name">RMA Report</field>
|
||||
<field name="model">rma</field>
|
||||
<field name="report_type">qweb-pdf</field>
|
||||
<field name="report_name">rma.report_rma</field>
|
||||
<field name="report_file">rma.report_rma</field>
|
||||
<field name="print_report_name">(object._get_report_base_filename())</field>
|
||||
</record>
|
||||
</odoo>
|
||||
|
||||
@@ -8,3 +8,5 @@ access_rma_operation_user_own,rma.operation.user.own,model_rma_operation,rma_gro
|
||||
access_rma_operation_manager,rma.operation.manager,model_rma_operation,rma_group_manager,1,1,1,1
|
||||
access_rma_tag_user_own,rma.tag.user.own,model_rma_tag,rma_group_user_own,1,0,0,0
|
||||
access_rma_tag_manager,rma.tag.manager,model_rma_tag,rma_group_manager,1,1,1,1
|
||||
access_rma_delivery_wizard_user_all,rma.delivery.wizard.user.all,model_rma_delivery_wizard,rma_group_user_all,1,1,1,1
|
||||
access_rma_split_wizard_user_all,rma.split.wizard.user.all,model_rma_split_wizard,rma_group_user_all,1,1,1,1
|
||||
|
||||
|
@@ -69,7 +69,7 @@ class TestRma(SavepointCase):
|
||||
rma = self._create_rma(partner, product, qty, location)
|
||||
rma.action_confirm()
|
||||
rma.reception_move_id.quantity_done = rma.product_uom_qty
|
||||
rma.reception_move_id.picking_id.action_done()
|
||||
rma.reception_move_id.picking_id._action_done()
|
||||
return rma
|
||||
|
||||
def _test_readonly_fields(self, rma):
|
||||
@@ -161,7 +161,7 @@ class TestRma(SavepointCase):
|
||||
move.product_uom_qty = 15
|
||||
move.product_uom = uom_ten
|
||||
picking = picking_form.save()
|
||||
picking.action_done()
|
||||
picking._action_done()
|
||||
rma_form.picking_id = picking
|
||||
rma_form.move_id = picking.move_lines
|
||||
self.assertEqual(rma_form.product_id, product_2)
|
||||
@@ -174,12 +174,6 @@ class TestRma(SavepointCase):
|
||||
self.assertEqual(rma_form.product_uom_qty, 15)
|
||||
self.assertNotEqual(rma_form.product_uom, uom_ten)
|
||||
self.assertEqual(rma_form.product_uom, self.product.uom_id)
|
||||
rma = rma_form.save()
|
||||
# If product changes, unit of measure domain should also change
|
||||
domain = rma._onchange_product_id()["domain"]["product_uom"]
|
||||
self.assertListEqual(
|
||||
domain, [("category_id", "=", self.product.uom_id.category_id.id)]
|
||||
)
|
||||
|
||||
def test_ensure_required_fields_on_confirm(self):
|
||||
rma = self._create_rma()
|
||||
@@ -212,9 +206,9 @@ class TestRma(SavepointCase):
|
||||
self._test_readonly_fields(rma)
|
||||
rma.reception_move_id.quantity_done = 9
|
||||
with self.assertRaises(ValidationError):
|
||||
rma.reception_move_id.picking_id.action_done()
|
||||
rma.reception_move_id.picking_id._action_done()
|
||||
rma.reception_move_id.quantity_done = 10
|
||||
rma.reception_move_id.picking_id.action_done()
|
||||
rma.reception_move_id.picking_id._action_done()
|
||||
self.assertEqual(rma.reception_move_id.picking_id.state, "done")
|
||||
self.assertEqual(rma.reception_move_id.quantity_done, 10)
|
||||
self.assertEqual(rma.state, "received")
|
||||
@@ -260,7 +254,7 @@ class TestRma(SavepointCase):
|
||||
self.assertTrue(rma.can_be_returned)
|
||||
self.assertTrue(rma.can_be_replaced)
|
||||
rma.action_refund()
|
||||
self.assertEqual(rma.refund_id.type, "out_refund")
|
||||
self.assertEqual(rma.refund_id.move_type, "out_refund")
|
||||
self.assertEqual(rma.refund_id.state, "draft")
|
||||
self.assertEqual(rma.refund_line_id.product_id, rma.product_id)
|
||||
self.assertEqual(rma.refund_line_id.quantity, 10)
|
||||
@@ -273,11 +267,11 @@ class TestRma(SavepointCase):
|
||||
with refund_form.invoice_line_ids.edit(0) as refund_line:
|
||||
refund_line.quantity = 9
|
||||
with self.assertRaises(ValidationError):
|
||||
rma.refund_id.post()
|
||||
rma.refund_id.action_post()
|
||||
with Form(rma.refund_line_id.move_id) as refund_form:
|
||||
with refund_form.invoice_line_ids.edit(0) as refund_line:
|
||||
refund_line.quantity = 10
|
||||
rma.refund_id.post()
|
||||
rma.refund_id.action_post()
|
||||
self.assertFalse(rma.can_be_refunded)
|
||||
self.assertFalse(rma.can_be_returned)
|
||||
self.assertFalse(rma.can_be_replaced)
|
||||
@@ -356,12 +350,12 @@ class TestRma(SavepointCase):
|
||||
with refund_form.invoice_line_ids.edit(1) as refund_line:
|
||||
refund_line.quantity = 14
|
||||
with self.assertRaises(ValidationError):
|
||||
refund_1.post()
|
||||
refund_1.action_post()
|
||||
with Form(rma_2.refund_line_id.move_id) as refund_form:
|
||||
with refund_form.invoice_line_ids.edit(1) as refund_line:
|
||||
refund_line.quantity = 15
|
||||
refund_1.post()
|
||||
refund_2.post()
|
||||
refund_1.action_post()
|
||||
refund_2.action_post()
|
||||
|
||||
def test_replace(self):
|
||||
# Create, confirm and receive an RMA
|
||||
@@ -616,7 +610,7 @@ class TestRma(SavepointCase):
|
||||
rma = rma_form.save()
|
||||
rma.action_confirm()
|
||||
rma.reception_move_id.quantity_done = 10
|
||||
rma.reception_move_id.picking_id.action_done()
|
||||
rma.reception_move_id.picking_id._action_done()
|
||||
# Return quantity 4 of the same product to the customer
|
||||
delivery_form = Form(
|
||||
self.env["rma.delivery.wizard"].with_context(
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
<field name="model">rma.tag</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="RMA Tags">
|
||||
<field name="name" />
|
||||
<filter
|
||||
string="Archived"
|
||||
name="inactive"
|
||||
|
||||
@@ -254,10 +254,15 @@
|
||||
force_save="1"
|
||||
attrs="{'readonly': ['|', ('picking_id', '!=', False), ('state', '!=', 'draft')]}"
|
||||
/>
|
||||
<field name="uom_category_id" invisible="1" />
|
||||
<label for="product_uom_qty" />
|
||||
<div class="o_row">
|
||||
<field name="product_uom_qty" />
|
||||
<field name="product_uom" groups="uom.group_uom" />
|
||||
<field
|
||||
name="product_uom"
|
||||
groups="uom.group_uom"
|
||||
domain="[('category_id', '=', uom_category_id)]"
|
||||
/>
|
||||
</div>
|
||||
<field
|
||||
name="delivered_qty"
|
||||
|
||||
@@ -30,6 +30,7 @@ class RmaReDeliveryWizard(models.TransientModel):
|
||||
string="Warehouse",
|
||||
required=True,
|
||||
)
|
||||
uom_category_id = fields.Many2one(related="product_id.uom_id.category_id")
|
||||
|
||||
@api.constrains("product_uom_qty")
|
||||
def _check_product_uom_qty(self):
|
||||
@@ -66,14 +67,9 @@ class RmaReDeliveryWizard(models.TransientModel):
|
||||
|
||||
@api.onchange("product_id")
|
||||
def _onchange_product_id(self):
|
||||
domain_product_uom = []
|
||||
if self.product_id:
|
||||
domain_product_uom = [
|
||||
("category_id", "=", self.product_id.uom_id.category_id.id)
|
||||
]
|
||||
if not self.product_uom or self.product_id.uom_id.id != self.product_uom.id:
|
||||
self.product_uom = self.product_id.uom_id
|
||||
return {"domain": {"product_uom": domain_product_uom}}
|
||||
|
||||
def action_deliver(self):
|
||||
self.ensure_one()
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="uom_category_id" invisible="1" />
|
||||
<field
|
||||
name="product_id"
|
||||
attrs="{'invisible': ['|', ('type', '!=', 'replace'), ('rma_count', '>', 1)], 'required': [('type', '=', 'replace'), ('rma_count', '=', 1)]}"
|
||||
@@ -36,6 +37,7 @@
|
||||
name="product_uom"
|
||||
groups="uom.group_uom"
|
||||
attrs="{'required': [('rma_count', '=', 1)]}"
|
||||
domain="[('category_id', '=', uom_category_id)]"
|
||||
/>
|
||||
</div>
|
||||
</group>
|
||||
@@ -54,14 +56,14 @@
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
<act_window
|
||||
id="rma_delivery_wizard_action"
|
||||
name="Return to customer"
|
||||
binding_model="rma"
|
||||
binding_views="list"
|
||||
res_model="rma.delivery.wizard"
|
||||
view_mode="form"
|
||||
target="new"
|
||||
context="{'rma_delivery_type': 'return'}"
|
||||
/>
|
||||
|
||||
<record id="rma_delivery_wizard_action" model="ir.actions.act_window">
|
||||
<field name="name">Return to customer</field>
|
||||
<field name="res_model">rma.delivery.wizard</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="binding_model_id" ref="rma.model_rma" />
|
||||
<field name="binding_view_types">list</field>
|
||||
<field name="target">new</field>
|
||||
<field name="context">{'rma_delivery_type': 'return'}</field>
|
||||
</record>
|
||||
</odoo>
|
||||
|
||||
@@ -9,16 +9,7 @@ class ReturnPicking(models.TransientModel):
|
||||
_inherit = "stock.return.picking"
|
||||
|
||||
create_rma = fields.Boolean(string="Create RMAs")
|
||||
picking_type_code = fields.Selection(
|
||||
selection=[
|
||||
("incoming", "Vendors"),
|
||||
("outgoing", "Customers"),
|
||||
("internal", "Internal"),
|
||||
],
|
||||
related="picking_id.picking_type_id.code",
|
||||
store=True,
|
||||
readonly=True,
|
||||
)
|
||||
picking_type_code = fields.Selection(related="picking_id.picking_type_id.code")
|
||||
|
||||
@api.onchange("create_rma")
|
||||
def _onchange_create_rma(self):
|
||||
|
||||
Reference in New Issue
Block a user