diff --git a/rma/README.rst b/rma/README.rst index abdfda0a..855d4bf9 100644 --- a/rma/README.rst +++ b/rma/README.rst @@ -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 `_. 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 `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -141,6 +141,8 @@ Contributors * Pedro M. Baeza * David Vidal +* Chafique Delli + Maintainers ~~~~~~~~~~~ @@ -162,6 +164,6 @@ Current `maintainer `__: |maintainer-ernestotejeda| -This module is part of the `OCA/rma `_ project on GitHub. +This module is part of the `OCA/rma `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/rma/controllers/main.py b/rma/controllers/main.py index a262f83a..07f98862 100644 --- a/rma/controllers/main.py +++ b/rma/controllers/main.py @@ -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)), diff --git a/rma/data/mail_data.xml b/rma/data/mail_data.xml index 175d4436..b30d4b3a 100644 --- a/rma/data/mail_data.xml +++ b/rma/data/mail_data.xml @@ -42,7 +42,6 @@ ${(object.name or '')} ${object.partner_id.lang} -
diff --git a/rma/models/account_move.py b/rma/models/account_move.py index d71aeca4..251f2ff1 100644 --- a/rma/models/account_move.py +++ b/rma/models/account_move.py @@ -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") diff --git a/rma/models/rma.py b/rma/models/rma.py index e4017eca..e59bf9f8 100644 --- a/rma/models/rma.py +++ b/rma/models/rma.py @@ -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): diff --git a/rma/models/rma_team.py b/rma/models/rma_team.py index f46b3d4b..fd624f60 100644 --- a/rma/models/rma_team.py +++ b/rma/models/rma_team.py @@ -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 diff --git a/rma/readme/CONTRIBUTORS.rst b/rma/readme/CONTRIBUTORS.rst index d4052271..49a9884e 100644 --- a/rma/readme/CONTRIBUTORS.rst +++ b/rma/readme/CONTRIBUTORS.rst @@ -3,3 +3,5 @@ * Ernesto Tejeda * Pedro M. Baeza * David Vidal + +* Chafique Delli diff --git a/rma/report/report.xml b/rma/report/report.xml index 5816ab29..3840534d 100644 --- a/rma/report/report.xml +++ b/rma/report/report.xml @@ -1,14 +1,11 @@ - - - + + RMA Report + rma + qweb-pdf + rma.report_rma + rma.report_rma + (object._get_report_base_filename()) + diff --git a/rma/security/ir.model.access.csv b/rma/security/ir.model.access.csv index ad209dc7..911c8d53 100644 --- a/rma/security/ir.model.access.csv +++ b/rma/security/ir.model.access.csv @@ -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 diff --git a/rma/tests/test_rma.py b/rma/tests/test_rma.py index 7857eaae..d0680ce2 100644 --- a/rma/tests/test_rma.py +++ b/rma/tests/test_rma.py @@ -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( diff --git a/rma/views/rma_tag_views.xml b/rma/views/rma_tag_views.xml index 78033211..1d0e119c 100644 --- a/rma/views/rma_tag_views.xml +++ b/rma/views/rma_tag_views.xml @@ -4,6 +4,7 @@ rma.tag + +
@@ -54,14 +56,14 @@
- + + + Return to customer + rma.delivery.wizard + form + + list + new + {'rma_delivery_type': 'return'} + diff --git a/rma/wizard/stock_picking_return.py b/rma/wizard/stock_picking_return.py index a331c288..78679562 100644 --- a/rma/wizard/stock_picking_return.py +++ b/rma/wizard/stock_picking_return.py @@ -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):