From 9cc5bca1532edc9c8de4fd2e0d0a6cb4e0bb8161 Mon Sep 17 00:00:00 2001 From: Antoni Marroig Campomar Date: Wed, 8 May 2024 17:05:54 +0200 Subject: [PATCH] [MIG] rma: Migration to 17.0 --- rma/README.rst | 7 +- rma/__manifest__.py | 2 +- rma/data/mail_data.xml | 9 +- rma/hooks.py | 6 +- rma/models/rma.py | 155 ++++++------------- rma/models/stock_move.py | 2 +- rma/readme/CONTRIBUTORS.md | 2 + rma/readme/USAGE.md | 2 +- rma/static/description/index.html | 8 +- rma/tests/test_rma.py | 58 +++---- rma/views/res_config_settings_views.xml | 179 +++++++--------------- rma/views/res_partner_views.xml | 2 +- rma/views/rma_finalization_views.xml | 2 +- rma/views/rma_team_views.xml | 8 +- rma/views/rma_views.xml | 110 ++++++++----- rma/views/stock_picking_views.xml | 2 +- rma/wizard/rma_delivery_views.xml | 27 +--- rma/wizard/stock_picking_return_views.xml | 2 +- 18 files changed, 227 insertions(+), 356 deletions(-) diff --git a/rma/README.rst b/rma/README.rst index 2b56f5158..cfd7c32a6 100644 --- a/rma/README.rst +++ b/rma/README.rst @@ -87,8 +87,8 @@ To use this module, you need to: quantity to another RMA, preview the RMA in the website. All of these operations can be done by clicking on the buttons in the status bar. - - If you click on 'Refund' button, a refund will be created, and it - will be accessible via the smart button labeled Refund. The RMA + - If you click on 'To Refund' button, a refund will be created, and + it will be accessible via the smart button labeled Refund. The RMA will be set automatically to 'Refunded' state when the refund is validated. - If you click on 'Replace' or 'Return to customer' button instead, @@ -171,6 +171,9 @@ Contributors - Chafique Delli - Giovanni Serra - Ooops +- `APSL-Nagarro `__: + + - Antoni Marroig Maintainers ----------- diff --git a/rma/__manifest__.py b/rma/__manifest__.py index cd86ac43b..709d3ffdd 100644 --- a/rma/__manifest__.py +++ b/rma/__manifest__.py @@ -5,7 +5,7 @@ { "name": "Return Merchandise Authorization Management", "summary": "Return Merchandise Authorization (RMA)", - "version": "16.0.1.2.0", + "version": "17.0.1.0.0", "development_status": "Production/Stable", "category": "RMA", "website": "https://github.com/OCA/rma", diff --git a/rma/data/mail_data.xml b/rma/data/mail_data.xml index f1d8afa20..79d0d22f4 100644 --- a/rma/data/mail_data.xml +++ b/rma/data/mail_data.xml @@ -41,8 +41,7 @@ {{object.company_id.name}} RMA (Ref {{object.name or 'n/a' }}) - - {{(object.name or '')}} + {{object.partner_id.lang}} @@ -78,8 +77,7 @@ {{object.company_id.name}} RMA (Ref {{object.name or 'n/a' }}) products received - - {{(object.name or '')}} + {{object.partner_id.lang}} @@ -114,8 +112,7 @@ {{object.company_id.name}} Your RMA has been succesfully created (Ref {{object.name or 'n/a' }}) - - {{(object.name or '')}} + {{object.partner_id.lang}} diff --git a/rma/hooks.py b/rma/hooks.py index 83b95586d..5b46f9aa8 100644 --- a/rma/hooks.py +++ b/rma/hooks.py @@ -1,12 +1,8 @@ # Copyright 2020 Tecnativa - Ernesto Tejeda # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -from odoo import SUPERUSER_ID, api - - -def post_init_hook(cr, registry): - env = api.Environment(cr, SUPERUSER_ID, {}) +def post_init_hook(env): def _get_next_picking_type_color(): """Choose the next available color for the operation types.""" stock_picking_type = env["stock.picking.type"] diff --git a/rma/models/rma.py b/rma/models/rma.py index fb6b43dd3..570450897 100644 --- a/rma/models/rma.py +++ b/rma/models/rma.py @@ -35,60 +35,37 @@ def _domain_location_id(self): sent = fields.Boolean() name = fields.Char( index=True, - readonly=True, - states={"draft": [("readonly", False)]}, copy=False, default=lambda self: _("New"), ) origin = fields.Char( string="Source Document", - states={ - "locked": [("readonly", True)], - "cancelled": [("readonly", True)], - }, help="Reference of the document that generated this RMA.", ) date = fields.Datetime( default=fields.Datetime.now, index=True, required=True, - readonly=True, - states={"draft": [("readonly", False)]}, - ) - deadline = fields.Date( - states={ - "locked": [("readonly", True)], - "cancelled": [("readonly", True)], - }, ) + deadline = fields.Date() user_id = fields.Many2one( comodel_name="res.users", string="Responsible", index=True, tracking=True, - states={ - "locked": [("readonly", True)], - "cancelled": [("readonly", True)], - }, ) team_id = fields.Many2one( comodel_name="rma.team", string="RMA team", index=True, - states={ - "locked": [("readonly", True)], - "cancelled": [("readonly", True)], - }, compute="_compute_team_id", store=True, - readonly=False, ) tag_ids = fields.Many2many(comodel_name="rma.tag", string="Tags") finalization_id = fields.Many2one( string="Finalization Reason", comodel_name="rma.finalization", copy=False, - readonly=True, domain=( "['|', ('company_id', '=', False), ('company_id', '='," " company_id)]" ), @@ -97,16 +74,10 @@ def _domain_location_id(self): company_id = fields.Many2one( comodel_name="res.company", default=lambda self: self.env.company, - states={ - "locked": [("readonly", True)], - "cancelled": [("readonly", True)], - }, ) partner_id = fields.Many2one( string="Customer", comodel_name="res.partner", - readonly=True, - states={"draft": [("readonly", False)]}, index=True, tracking=True, ) @@ -143,8 +114,6 @@ def _domain_location_id(self): " ('partner_id', 'child_of', commercial_partner_id)," "]" ), - readonly=True, - states={"draft": [("readonly", False)]}, ) move_id = fields.Many2one( comodel_name="stock.move", @@ -187,18 +156,10 @@ def _domain_location_id(self): procurement_group_id = fields.Many2one( comodel_name="procurement.group", string="Procurement group", - readonly=True, - states={ - "draft": [("readonly", False)], - "confirmed": [("readonly", False)], - "received": [("readonly", False)], - }, ) priority = fields.Selection( selection=PROCUREMENT_PRIORITIES, default="1", - readonly=True, - states={"draft": [("readonly", False)]}, ) operation_id = fields.Many2one( comodel_name="rma.operation", @@ -222,12 +183,7 @@ def _domain_location_id(self): copy=False, tracking=True, ) - description = fields.Html( - states={ - "locked": [("readonly", True)], - "cancelled": [("readonly", True)], - }, - ) + description = fields.Html() # Reception fields location_id = fields.Many2one( comodel_name="stock.location", @@ -249,12 +205,10 @@ def _domain_location_id(self): # Refund fields refund_id = fields.Many2one( comodel_name="account.move", - readonly=True, copy=False, ) refund_line_id = fields.Many2one( comodel_name="account.move.line", - readonly=True, copy=False, ) can_be_refunded = fields.Boolean(compute="_compute_can_be_refunded") @@ -263,7 +217,6 @@ def _domain_location_id(self): comodel_name="stock.move", inverse_name="rma_id", string="Delivery reservation", - readonly=True, copy=False, ) delivery_picking_count = fields.Integer( @@ -275,11 +228,6 @@ def _domain_location_id(self): compute="_compute_delivered_qty", store=True, ) - delivered_qty_done = fields.Float( - digits="Product Unit of Measure", - compute="_compute_delivered_qty", - compute_sudo=True, - ) can_be_returned = fields.Boolean( compute="_compute_can_be_returned", ) @@ -297,11 +245,6 @@ def _domain_location_id(self): digits="Product Unit of Measure", compute="_compute_remaining_qty", ) - remaining_qty_to_done = fields.Float( - string="Remaining delivered qty to done", - digits="Product Unit of Measure", - compute="_compute_remaining_qty", - ) uom_category_id = fields.Many2one( related="product_id.uom_id.category_id", string="Category UoM" ) @@ -312,7 +255,6 @@ def _domain_location_id(self): origin_split_rma_id = fields.Many2one( comodel_name="rma", string="Extracted from", - readonly=True, copy=False, ) @@ -335,8 +277,7 @@ def _compute_delivery_picking_count(self): "delivery_move_ids.state", "delivery_move_ids.scrapped", "delivery_move_ids.product_uom_qty", - "delivery_move_ids.reserved_availability", - "delivery_move_ids.quantity_done", + "delivery_move_ids.quantity", "delivery_move_ids.product_uom", "product_uom", ) @@ -355,29 +296,21 @@ def _compute_delivered_qty(self): """ for record in self: delivered_qty = 0.0 - delivered_qty_done = 0.0 for move in record.delivery_move_ids.filtered( lambda r: r.state != "cancel" and not r.scrapped ): - if move.quantity_done: - quantity_done = move.product_uom._compute_quantity( - move.quantity_done, record.product_uom - ) - if move.state == "done": - delivered_qty_done += quantity_done - delivered_qty += quantity_done - elif move.reserved_availability: - delivered_qty += move.product_uom._compute_quantity( - move.reserved_availability, record.product_uom + if move.quantity: + quantity = move.product_uom._compute_quantity( + move.quantity, record.product_uom ) + delivered_qty += quantity elif move.product_uom_qty: delivered_qty += move.product_uom._compute_quantity( move.product_uom_qty, record.product_uom ) record.delivered_qty = delivered_qty - record.delivered_qty_done = delivered_qty_done - @api.depends("product_uom_qty", "delivered_qty", "delivered_qty_done") + @api.depends("product_uom_qty", "delivered_qty") def _compute_remaining_qty(self): """Compute 'remaining_qty' and 'remaining_qty_to_done' fields. @@ -392,7 +325,6 @@ def _compute_remaining_qty(self): """ for r in self: r.remaining_qty = r.product_uom_qty - r.delivered_qty - r.remaining_qty_to_done = r.product_uom_qty - r.delivered_qty_done @api.depends( "state", @@ -443,7 +375,7 @@ def _compute_can_be_finished(self): and rma.remaining_qty > 0 ) - @api.depends("product_uom_qty", "state", "remaining_qty", "remaining_qty_to_done") + @api.depends("product_uom_qty", "state", "remaining_qty") def _compute_can_be_split(self): """Compute 'can_be_split'. This field controls the visibility of 'Split' button in the rma form view and @@ -460,10 +392,10 @@ def _compute_can_be_split(self): else: r.can_be_split = False - @api.depends("remaining_qty_to_done", "state") + @api.depends("state") def _compute_can_be_locked(self): for r in self: - r.can_be_locked = r.remaining_qty_to_done > 0 and r.state in [ + r.can_be_locked = r.remaining_qty > 0 and r.state in [ "received", "waiting_return", "waiting_replacement", @@ -612,34 +544,41 @@ def unlink(self): def _send_draft_email(self): """Send customer notifications they place the RMA from the portal""" for rma in self.filtered("company_id.send_rma_draft_confirmation"): - rma_template_id = rma.company_id.rma_mail_draft_confirmation_template_id.id rma.with_context( force_send=True, mark_rma_as_sent=True, - default_subtype_id=self.env.ref("rma.mt_rma_notification").id, - ).message_post_with_template(rma_template_id) + ).message_post_with_source( + rma.company_id.rma_mail_draft_confirmation_template_id.get_external_id()[ + rma.company_id.rma_mail_draft_confirmation_template_id.id + ], + subtype_xmlid="rma.mt_rma_notification", + ) def _send_confirmation_email(self): """Auto send notifications""" for rma in self.filtered(lambda p: p.company_id.send_rma_confirmation): - rma_template_id = rma.company_id.rma_mail_confirmation_template_id.id rma.with_context( force_send=True, mark_rma_as_sent=True, - default_subtype_id=self.env.ref("rma.mt_rma_notification").id, - ).message_post_with_template(rma_template_id) + ).message_post_with_source( + rma.company_id.rma_mail_confirmation_template_id.get_external_id()[ + rma.company_id.rma_mail_confirmation_template_id.id + ], + subtype_xmlid="rma.mt_rma_notification", + ) def _send_receipt_confirmation_email(self): """Send customer notifications when the products are received""" for rma in self.filtered("company_id.send_rma_receipt_confirmation"): - rma_template_id = ( - rma.company_id.rma_mail_receipt_confirmation_template_id.id - ) rma.with_context( force_send=True, mark_rma_as_sent=True, - default_subtype_id=self.env.ref("rma.mt_rma_notification").id, - ).message_post_with_template(rma_template_id) + ).message_post_with_source( + rma.company_id.rma_mail_receipt_confirmation_template_id.get_external_id()[ + rma.company_id.rma_mail_receipt_confirmation_template_id.id + ], + subtype_xmlid="rma.mt_rma_notification", + ) # Action methods def action_rma_send(self): @@ -682,6 +621,7 @@ def action_confirm(self): reception_move = self._create_receptions_from_picking() else: reception_move = self._create_receptions_from_product() + reception_move.picked = True self.write({"reception_move_id": reception_move.id, "state": "confirmed"}) self._add_message_subscribe_partner() self._send_confirmation_email() @@ -703,10 +643,10 @@ def action_refund(self): (0, 0, rma._prepare_refund_line_vals()) ) refund = self.env["account.move"].sudo().create(refund_vals) - refund.with_user(self.env.uid).message_post_with_view( + refund.with_user(self.env.uid).message_post_with_source( "mail.message_origin_link", - values={"self": refund, "origin": rmas}, - subtype_id=self.env.ref("mail.mt_note").id, + render_values={"self": refund, "origin": rmas}, + subtype_id=self.env["ir.model.data"]._xmlid_to_res_id("mail.mt_note"), ) for line in refund.invoice_line_ids: line.rma_id.write( @@ -1027,10 +967,10 @@ def _create_receptions_from_product(self): picking = self.env["stock.picking"].create(self._prepare_picking_vals()) picking.action_confirm() picking.action_assign() - picking.message_post_with_view( + picking.message_post_with_source( "mail.message_origin_link", - values={"self": picking, "origin": self}, - subtype_id=self.env.ref("mail.mt_note").id, + render_values={"self": picking, "origin": self}, + subtype_id=self.env["ir.model.data"]._xmlid_to_res_id("mail.mt_note"), ) return picking.move_ids @@ -1068,7 +1008,7 @@ def extract_quantity(self, qty, uom): self._ensure_can_be_split() self._ensure_qty_to_extract(qty, uom) self.product_uom_qty -= uom._compute_quantity(qty, self.product_uom) - if self.remaining_qty_to_done <= 0: + if self.remaining_qty <= 0: if self.state == "waiting_return": self.state = "returned" elif self.state == "waiting_replacement": @@ -1083,10 +1023,10 @@ def extract_quantity(self, qty, uom): "origin_split_rma_id": self.id, } ) - extracted_rma.message_post_with_view( + extracted_rma.message_post_with_source( "mail.message_origin_link", - values={"self": extracted_rma, "origin": self}, - subtype_id=self.env.ref("mail.mt_note").id, + render_values={"self": extracted_rma, "origin": self}, + subtype_id=self.env["ir.model.data"]._xmlid_to_res_id("mail.mt_note"), ) self.message_post( body=_( @@ -1175,10 +1115,10 @@ def create_return(self, scheduled_date, qty=None, uom=None): ) picking.action_confirm() picking.action_assign() - picking.message_post_with_view( + picking.message_post_with_source( "mail.message_origin_link", - values={"self": picking, "origin": rmas}, - subtype_id=self.env.ref("mail.mt_note").id, + render_values={"self": picking, "origin": rmas}, + subtype_id=self.env["ir.model.data"]._xmlid_to_res_id("mail.mt_note"), ) rmas_to_return.write({"state": "waiting_return"}) @@ -1234,7 +1174,7 @@ def create_replace(self, scheduled_date, warehouse, product, qty, uom): % ( { "move_id": new_move.id, - "move_name": new_move.name_get()[0][1], + "move_name": new_move.display_name, "picking_id": new_move.picking_id.id, "picking_name": new_move.picking_id.name, } @@ -1427,10 +1367,7 @@ def update_replaced_state(self): [stock.move]._action_cancel """ rma = self.filtered( - lambda r: ( - r.state == "waiting_replacement" - and 0 >= r.remaining_qty_to_done == r.remaining_qty - ) + lambda r: (r.state == "waiting_replacement" and 0 >= r.remaining_qty) ) if rma: rma.write({"state": "replaced"}) @@ -1438,7 +1375,7 @@ def update_replaced_state(self): def update_returned_state(self): """Invoked by [stock.move]._action_done""" rma = self.filtered( - lambda r: (r.state == "waiting_return" and r.remaining_qty_to_done <= 0) + lambda r: (r.state == "waiting_return" and r.remaining_qty <= 0) ) if rma: rma.write({"state": "returned"}) diff --git a/rma/models/stock_move.py b/rma/models/stock_move.py index 8d9925615..df6622bd6 100644 --- a/rma/models/stock_move.py +++ b/rma/models/stock_move.py @@ -59,7 +59,7 @@ def _action_done(self, cancel_backorder=False): """ for move in self.filtered(lambda r: r.state not in ("done", "cancel")): rma_receiver = move.sudo().rma_receiver_ids - if rma_receiver and move.quantity_done != rma_receiver.product_uom_qty: + if rma_receiver and move.quantity != rma_receiver.product_uom_qty: raise ValidationError( _( "The quantity done for the product '%(id)s' must " diff --git a/rma/readme/CONTRIBUTORS.md b/rma/readme/CONTRIBUTORS.md index 85856a266..36baf52b7 100644 --- a/rma/readme/CONTRIBUTORS.md +++ b/rma/readme/CONTRIBUTORS.md @@ -5,3 +5,5 @@ - Víctor Martínez - Chafique Delli \<\> - Giovanni Serra - Ooops \<\> +- [APSL-Nagarro](https://www.apsl.tech): + - Antoni Marroig \<\> diff --git a/rma/readme/USAGE.md b/rma/readme/USAGE.md index 44e6093ee..3a5936089 100644 --- a/rma/readme/USAGE.md +++ b/rma/readme/USAGE.md @@ -14,7 +14,7 @@ To use this module, you need to: quantity to another RMA, preview the RMA in the website. All of these operations can be done by clicking on the buttons in the status bar. - - If you click on 'Refund' button, a refund will be created, and it + - If you click on 'To Refund' button, a refund will be created, and it will be accessible via the smart button labeled Refund. The RMA will be set automatically to 'Refunded' state when the refund is validated. diff --git a/rma/static/description/index.html b/rma/static/description/index.html index e5794af3c..db1ca16d2 100644 --- a/rma/static/description/index.html +++ b/rma/static/description/index.html @@ -434,8 +434,8 @@

Usage

replacement, split the RMA by extracting a part of the remaining quantity to another RMA, preview the RMA in the website. All of these operations can be done by clicking on the buttons in the status bar.
    -
  • If you click on ‘Refund’ button, a refund will be created, and it -will be accessible via the smart button labeled Refund. The RMA +
  • If you click on ‘To Refund’ button, a refund will be created, and +it will be accessible via the smart button labeled Refund. The RMA will be set automatically to ‘Refunded’ state when the refund is validated.
  • If you click on ‘Replace’ or ‘Return to customer’ button instead, @@ -523,6 +523,10 @@

    Contributors

  • Chafique Delli <chafique.delli@akretion.com>
  • Giovanni Serra - Ooops <giovanni@ooops404.com>
  • +
  • APSL-Nagarro: +
diff --git a/rma/tests/test_rma.py b/rma/tests/test_rma.py index 89c6c56d6..743226e88 100644 --- a/rma/tests/test_rma.py +++ b/rma/tests/test_rma.py @@ -85,6 +85,8 @@ def _create_rma(self, partner=None, product=None, qty=None, location=None): vals["product_uom_qty"] = qty if location: vals["location_id"] = location.id + + vals["user_id"] = self.env.user.id return self.env["rma"].create(vals) def _create_confirm_receive( @@ -92,7 +94,7 @@ def _create_confirm_receive( ): 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.quantity = rma.product_uom_qty rma.reception_move_id.picking_id._action_done() return rma @@ -107,7 +109,7 @@ def _create_delivery(self): limit=1, ) picking_form = Form( - recordp=self.env["stock.picking"].with_context( + record=self.env["stock.picking"].with_context( default_picking_type_id=picking_type.id ), view="stock.view_picking_form", @@ -124,7 +126,7 @@ def _create_delivery(self): picking = picking_form.save() picking.action_confirm() for move in picking.move_ids: - move.quantity_done = move.product_uom_qty + move.quantity = move.product_uom_qty picking.button_validate() return picking @@ -157,7 +159,7 @@ def test_computed(self): limit=1, ) picking_form = Form( - recordp=self.env["stock.picking"].with_context( + record=self.env["stock.picking"].with_context( default_picking_type_id=outgoing_picking_type.id ), view="stock.view_picking_form", @@ -203,13 +205,13 @@ def test_confirm_and_receive(self): self.assertEqual(rma.reception_move_id.product_uom_qty, 10) self.assertEqual(rma.reception_move_id.product_uom, rma.product_uom) self.assertEqual(rma.state, "confirmed") - rma.reception_move_id.quantity_done = 9 + rma.reception_move_id.quantity = 9 with self.assertRaises(ValidationError): rma.reception_move_id.picking_id._action_done() - rma.reception_move_id.quantity_done = 10 + rma.reception_move_id.quantity = 10 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.reception_move_id.quantity, 10) self.assertEqual(rma.state, "received") def test_cancel(self): @@ -386,8 +388,6 @@ def test_replace(self): self.assertTrue(rma.can_be_replaced) self.assertEqual(rma.delivered_qty, 2) self.assertEqual(rma.remaining_qty, 8) - self.assertEqual(rma.delivered_qty_done, 0) - self.assertEqual(rma.remaining_qty_to_done, 10) first_move = rma.delivery_move_ids picking = first_move.picking_id # Replace again with another product with the remaining quantity @@ -413,18 +413,13 @@ def test_replace(self): self.assertTrue(picking.state, "waiting") self.assertEqual(rma.delivered_qty, 10) self.assertEqual(rma.remaining_qty, 0) - self.assertEqual(rma.delivered_qty_done, 0) - self.assertEqual(rma.remaining_qty_to_done, 10) # remaining_qty is 0 but rma is not set to 'replaced' until - # remaining_qty_to_done is less than or equal to 0 - first_move.quantity_done = 2 - second_move.quantity_done = 8 + first_move.quantity = 2 + second_move.quantity = 8 picking.button_validate() self.assertEqual(picking.state, "done") self.assertEqual(rma.delivered_qty, 10) self.assertEqual(rma.remaining_qty, 0) - self.assertEqual(rma.delivered_qty_done, 10) - self.assertEqual(rma.remaining_qty_to_done, 0) # The RMA is now in 'replaced' state self.assertEqual(rma.state, "replaced") self.assertFalse(rma.can_be_refunded) @@ -457,18 +452,14 @@ def test_return_to_customer(self): self.assertTrue(rma.can_be_returned) self.assertEqual(rma.delivered_qty, 2) self.assertEqual(rma.remaining_qty, 8) - self.assertEqual(rma.delivered_qty_done, 0) - self.assertEqual(rma.remaining_qty_to_done, 10) first_move = rma.delivery_move_ids picking = first_move.picking_id # Validate the picking - first_move.quantity_done = 2 + first_move.quantity = 2 picking.button_validate() self.assertEqual(picking.state, "done") self.assertEqual(rma.delivered_qty, 2) self.assertEqual(rma.remaining_qty, 8) - self.assertEqual(rma.delivered_qty_done, 2) - self.assertEqual(rma.remaining_qty_to_done, 8) # Return the remaining quantity to the customer delivery_form = Form( self.env["rma.delivery.wizard"].with_context( @@ -479,21 +470,16 @@ def test_return_to_customer(self): delivery_wizard = delivery_form.save() delivery_wizard.action_deliver() second_move = rma.delivery_move_ids - first_move - second_move.quantity_done = 8 + second_move.quantity = 8 self.assertEqual(rma.delivered_qty, 10) self.assertEqual(rma.remaining_qty, 0) - self.assertEqual(rma.delivered_qty_done, 2) - self.assertEqual(rma.remaining_qty_to_done, 8) self.assertEqual(rma.state, "waiting_return") # remaining_qty is 0 but rma is not set to 'returned' until - # remaining_qty_to_done is less than or equal to 0 picking_2 = second_move.picking_id picking_2.button_validate() self.assertEqual(picking_2.state, "done") self.assertEqual(rma.delivered_qty, 10) self.assertEqual(rma.remaining_qty, 0) - self.assertEqual(rma.delivered_qty_done, 10) - self.assertEqual(rma.remaining_qty_to_done, 0) # The RMA is now in 'returned' state self.assertEqual(rma.state, "returned") self.assertFalse(rma.can_be_refunded) @@ -579,7 +565,7 @@ def test_mass_return_to_customer(self): self.assertEqual(rma.product_id, rma.delivery_move_ids.product_id) self.assertEqual(rma.product_uom_qty, rma.delivery_move_ids.product_uom_qty) self.assertEqual(rma.product_uom, rma.delivery_move_ids.product_uom) - rma.delivery_move_ids.quantity_done = rma.product_uom_qty + rma.delivery_move_ids.quantity = rma.product_uom_qty pick_1.button_validate() pick_2.button_validate() self.assertEqual(all_rmas.mapped("state"), ["returned"] * 4) @@ -643,8 +629,8 @@ def test_rma_from_picking_return(self): self.assertTrue(reception_moves[1].rma_receiver_ids) self.assertEqual(reception_moves.mapped("rma_receiver_ids"), rmas) # Validate the reception picking to set rmas to 'received' state - reception_moves[0].quantity_done = reception_moves[0].product_uom_qty - reception_moves[1].quantity_done = reception_moves[1].product_uom_qty + reception_moves[0].quantity = reception_moves[0].product_uom_qty + reception_moves[1].quantity = reception_moves[1].product_uom_qty reception.button_validate() self.assertEqual(rmas.mapped("state"), ["received"] * 2) @@ -658,7 +644,7 @@ def test_split(self): ) rma = rma_form.save() rma.action_confirm() - rma.reception_move_id.quantity_done = 10 + rma.reception_move_id.quantity = 10 rma.reception_move_id.picking_id._action_done() # Return quantity 4 of the same product to the customer delivery_form = Form( @@ -670,7 +656,7 @@ def test_split(self): delivery_form.product_uom_qty = 4 delivery_wizard = delivery_form.save() delivery_wizard.action_deliver() - rma.delivery_move_ids.quantity_done = 4 + rma.delivery_move_ids.quantity = 4 rma.delivery_move_ids.picking_id.button_validate() self.assertEqual(rma.state, "waiting_return") # Extract the remaining quantity to another RMA @@ -690,8 +676,6 @@ def test_split(self): self.assertEqual(new_rma.origin_split_rma_id, rma) self.assertEqual(new_rma.delivered_qty, 0) self.assertEqual(new_rma.remaining_qty, 6) - self.assertEqual(new_rma.delivered_qty_done, 0) - self.assertEqual(new_rma.remaining_qty_to_done, 6) self.assertEqual(new_rma.state, "received") self.assertTrue(new_rma.can_be_refunded) self.assertTrue(new_rma.can_be_returned) @@ -699,8 +683,8 @@ def test_split(self): self.assertEqual(new_rma.move_id, rma.move_id) self.assertEqual(new_rma.reception_move_id, rma.reception_move_id) self.assertEqual(new_rma.product_uom_qty + rma.product_uom_qty, 10) - self.assertEqual(new_rma.move_id.quantity_done, 10) - self.assertEqual(new_rma.reception_move_id.quantity_done, 10) + self.assertEqual(new_rma.move_id.quantity, 10) + self.assertEqual(new_rma.reception_move_id.quantity, 10) def test_rma_to_receive_on_delete_invoice(self): rma = self._create_confirm_receive(self.partner, self.product, 10, self.rma_loc) @@ -763,7 +747,7 @@ def test_autoconfirm_email(self): ) # Now we'll confirm the incoming goods picking and the automatic # reception notification should be sent - rma.reception_move_id.quantity_done = rma.product_uom_qty + rma.reception_move_id.quantity = rma.product_uom_qty rma.reception_move_id.picking_id.button_validate() mail_receipt = ( self.env["mail.message"].search([("partner_ids", "in", self.partner.ids)]) diff --git a/rma/views/res_config_settings_views.xml b/rma/views/res_config_settings_views.xml index fbaa21b7b..a887024d1 100644 --- a/rma/views/res_config_settings_views.xml +++ b/rma/views/res_config_settings_views.xml @@ -5,154 +5,85 @@ -
-
+ -
-
-
-
-
-
+ + -
-
-
-
-
+ -
-
-
-
-
+ -
-
-
+
-
-
+ -
-
-
-
-
+
diff --git a/rma/views/res_partner_views.xml b/rma/views/res_partner_views.xml index 6eb1f4616..ea77b50c3 100644 --- a/rma/views/res_partner_views.xml +++ b/rma/views/res_partner_views.xml @@ -14,7 +14,7 @@ type="object" class="oe_stat_button" icon="fa-reply" - attrs="{'invisible': [('rma_count', '=', 0)]}" + invisible="rma_count == 0" groups="rma.rma_group_user_own" > diff --git a/rma/views/rma_finalization_views.xml b/rma/views/rma_finalization_views.xml index 3772660b8..463a74e4a 100644 --- a/rma/views/rma_finalization_views.xml +++ b/rma/views/rma_finalization_views.xml @@ -28,7 +28,7 @@ name="web_ribbon" title="Archived" bg_color="bg-danger" - attrs="{'invisible': [('active', '=', True)]}" + invisible="active" /> diff --git a/rma/views/rma_team_views.xml b/rma/views/rma_team_views.xml index f3454c49c..0ae66c788 100644 --- a/rma/views/rma_team_views.xml +++ b/rma/views/rma_team_views.xml @@ -10,7 +10,7 @@ - + @@ -81,11 +81,7 @@ - + - + - - + + - + @@ -371,7 +403,7 @@ string="Finish" name="action_finish" class="btn-primary" - attrs="{'invisible': [('can_be_finished', '=', False)]}" + invisible="not can_be_finished" groups="rma.group_rma_manual_finalization" /> @@ -392,7 +424,7 @@ rma.calendar rma - + diff --git a/rma/views/stock_picking_views.xml b/rma/views/stock_picking_views.xml index 16022033f..955a94399 100644 --- a/rma/views/stock_picking_views.xml +++ b/rma/views/stock_picking_views.xml @@ -13,7 +13,7 @@ type="object" class="oe_stat_button" icon="fa-reply" - attrs="{'invisible': [('rma_count', '=', 0)]}" + invisible="rma_count == 0" groups="rma.rma_group_user_own" > diff --git a/rma/wizard/rma_delivery_views.xml b/rma/wizard/rma_delivery_views.xml index ae0cf63af..3209002f6 100644 --- a/rma/wizard/rma_delivery_views.xml +++ b/rma/wizard/rma_delivery_views.xml @@ -11,37 +11,26 @@ - + -