From 2db34ce0f37d013bf60c9b4110e78c5254ece1d7 Mon Sep 17 00:00:00 2001 From: david Date: Fri, 30 Apr 2021 18:35:06 +0200 Subject: [PATCH] [MIG] rma_sale_mrp: Migration to 13.0 [UPD] Update rma_sale_mrp.pot [UPD] README.rst --- rma_sale_mrp/README.rst | 10 ++-- rma_sale_mrp/__manifest__.py | 2 +- rma_sale_mrp/i18n/rma_sale_mrp.pot | 49 ++++++++++++------- rma_sale_mrp/models/__init__.py | 2 +- .../{account_invoice.py => account_move.py} | 4 +- rma_sale_mrp/models/rma.py | 4 +- rma_sale_mrp/models/sale_order.py | 24 +++++++-- rma_sale_mrp/static/description/index.html | 6 +-- rma_sale_mrp/tests/test_rma_sale_mrp.py | 2 +- rma_sale_mrp/views/rma_views.xml | 9 ++-- rma_sale_mrp/wizard/sale_order_rma_wizard.py | 3 +- 11 files changed, 73 insertions(+), 42 deletions(-) rename rma_sale_mrp/models/{account_invoice.py => account_move.py} (91%) diff --git a/rma_sale_mrp/README.rst b/rma_sale_mrp/README.rst index 1be2d464..2356c86e 100644 --- a/rma_sale_mrp/README.rst +++ b/rma_sale_mrp/README.rst @@ -14,13 +14,13 @@ Return Merchandise Authorization Management - Link with MRP Kits :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/12.0/rma_sale_mrp + :target: https://github.com/OCA/rma/tree/13.0/rma_sale_mrp :alt: OCA/rma .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/rma-12-0/rma-12-0-rma_sale_mrp + :target: https://translation.odoo-community.org/projects/rma-13-0/rma-13-0-rma_sale_mrp :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/12.0 + :target: https://runbot.odoo-community.org/runbot/145/13.0 :alt: Try me on Runbot |badge1| |badge2| |badge3| |badge4| |badge5| @@ -74,7 +74,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. @@ -114,6 +114,6 @@ Current `maintainer `__: |maintainer-chienandalu| -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_sale_mrp/__manifest__.py b/rma_sale_mrp/__manifest__.py index bfd5aef0..4c94a73a 100644 --- a/rma_sale_mrp/__manifest__.py +++ b/rma_sale_mrp/__manifest__.py @@ -3,7 +3,7 @@ { "name": "Return Merchandise Authorization Management - Link with MRP Kits", "summary": "Allow doing RMAs from MRP kits", - "version": "12.0.1.0.2", + "version": "13.0.1.0.0", "development_status": "Beta", "category": "RMA", "website": "https://github.com/OCA/rma", diff --git a/rma_sale_mrp/i18n/rma_sale_mrp.pot b/rma_sale_mrp/i18n/rma_sale_mrp.pot index bff578f5..73d5c9e8 100644 --- a/rma_sale_mrp/i18n/rma_sale_mrp.pot +++ b/rma_sale_mrp/i18n/rma_sale_mrp.pot @@ -1,12 +1,12 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: -# * rma_sale_mrp +# * rma_sale_mrp # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 12.0\n" +"Project-Id-Version: Odoo Server 13.0\n" "Report-Msgid-Bugs-To: \n" -"Last-Translator: <>\n" +"Last-Translator: \n" "Language-Team: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -15,17 +15,23 @@ msgstr "" #. module: rma_sale_mrp #: model_terms:ir.ui.view,arch_db:rma_sale_mrp.portal_rma_page -msgid " Cancelled" +msgid "" +" Cancelled" msgstr "" #. module: rma_sale_mrp #: model_terms:ir.ui.view,arch_db:rma_sale_mrp.portal_rma_page -msgid " Draft" +msgid "" +" Draft" msgstr "" #. module: rma_sale_mrp #: model_terms:ir.ui.view,arch_db:rma_sale_mrp.portal_rma_page -msgid " Waiting" +msgid "" +" Waiting" msgstr "" #. module: rma_sale_mrp @@ -101,7 +107,9 @@ msgstr "" #. module: rma_sale_mrp #: model:ir.model.fields,help:rma_sale_mrp.field_sale_order_line_rma_wizard_component__uom_category_id -msgid "Conversion between Units of Measure can only occur if they belong to the same category. The conversion will be made based on the ratios." +msgid "" +"Conversion between Units of Measure can only occur if they belong to the " +"same category. The conversion will be made based on the ratios." msgstr "" #. module: rma_sale_mrp @@ -135,8 +143,8 @@ msgid "ID" msgstr "" #. module: rma_sale_mrp -#: model:ir.model,name:rma_sale_mrp.model_account_invoice -msgid "Invoice" +#: model:ir.model,name:rma_sale_mrp.model_account_move +msgid "Journal Entries" msgstr "" #. module: rma_sale_mrp @@ -233,11 +241,6 @@ msgstr "" msgid "Sale Line" msgstr "" -#. module: rma_sale_mrp -#: model:ir.model,name:rma_sale_mrp.model_sale_order -msgid "Sale Order" -msgstr "" - #. module: rma_sale_mrp #: model:ir.model,name:rma_sale_mrp.model_sale_order_line_rma_wizard msgid "Sale Order Line Rma Wizard" @@ -248,20 +251,29 @@ msgstr "" msgid "Sale Order Rma Wizard" msgstr "" +#. module: rma_sale_mrp +#: model:ir.model,name:rma_sale_mrp.model_sale_order +msgid "Sales Order" +msgstr "" + #. module: rma_sale_mrp #: model:ir.model,name:rma_sale_mrp.model_sale_order_line msgid "Sales Order Line" msgstr "" #. module: rma_sale_mrp -#: code:addons/rma_sale_mrp/wizard/sale_order_rma_wizard.py:55 +#: code:addons/rma_sale_mrp/wizard/sale_order_rma_wizard.py:0 #, python-format -msgid "The kit corresponding to the product %s can't be put in the RMA. Either all or some of the components where already put in another RMA" +msgid "" +"The kit corresponding to the product %s can't be put in the RMA. Either all " +"or some of the components where already put in another RMA" msgstr "" #. module: rma_sale_mrp #: model:ir.model.fields,help:rma_sale_mrp.field_rma__kit_qty -msgid "To how many kits this components corresponds to. Used mainly for refunding the right quantity" +msgid "" +"To how many kits this components corresponds to. Used mainly for refunding " +"the right quantity" msgstr "" #. module: rma_sale_mrp @@ -286,8 +298,7 @@ msgid "Wizard" msgstr "" #. module: rma_sale_mrp -#: code:addons/rma_sale_mrp/models/rma.py:49 +#: code:addons/rma_sale_mrp/models/rma.py:0 #, python-format msgid "You can't refund a kit in wich some RMAs aren't received" msgstr "" - diff --git a/rma_sale_mrp/models/__init__.py b/rma_sale_mrp/models/__init__.py index 7593ab7f..8d0dd9b0 100644 --- a/rma_sale_mrp/models/__init__.py +++ b/rma_sale_mrp/models/__init__.py @@ -1,3 +1,3 @@ -from . import account_invoice +from . import account_move from . import rma from . import sale_order diff --git a/rma_sale_mrp/models/account_invoice.py b/rma_sale_mrp/models/account_move.py similarity index 91% rename from rma_sale_mrp/models/account_invoice.py rename to rma_sale_mrp/models/account_move.py index 91150fc0..843e1c23 100644 --- a/rma_sale_mrp/models/account_invoice.py +++ b/rma_sale_mrp/models/account_move.py @@ -4,8 +4,8 @@ from odoo import models from odoo.tools import float_compare -class AccountInvoice(models.Model): - _inherit = "account.invoice" +class AccountMove(models.Model): + _inherit = "account.move" def _check_rma_invoice_lines_qty(self): """For those with differences, check if the kit quantity is the same""" diff --git a/rma_sale_mrp/models/rma.py b/rma_sale_mrp/models/rma.py index 45dad61c..0fbf87b2 100644 --- a/rma_sale_mrp/models/rma.py +++ b/rma_sale_mrp/models/rma.py @@ -3,8 +3,6 @@ from odoo import _, fields, models from odoo.exceptions import UserError -import odoo.addons.decimal_precision as dp - class Rma(models.Model): _inherit = "rma" @@ -14,7 +12,7 @@ class Rma(models.Model): ) kit_qty = fields.Float( string="Kit quantity", - digits=dp.get_precision("Product Unit of Measure"), + digits="Product Unit of Measure", readonly=True, help="To how many kits this components corresponds to. Used mainly " "for refunding the right quantity", diff --git a/rma_sale_mrp/models/sale_order.py b/rma_sale_mrp/models/sale_order.py index 62bc51a0..ff138568 100644 --- a/rma_sale_mrp/models/sale_order.py +++ b/rma_sale_mrp/models/sale_order.py @@ -73,7 +73,7 @@ class SaleOrderLine(models.Model): def get_delivery_move(self): self.ensure_one() - if self.product_id and not self.product_id._is_phantom_bom(): + if self.product_id and not self._rma_is_kit_product(): return super().get_delivery_move() return self.move_ids.filtered( lambda m: ( @@ -92,7 +92,7 @@ class SaleOrderLine(models.Model): can play with them when filtering or showing to the customer""" self.ensure_one() data = super().prepare_sale_rma_data() - if self.product_id and self.product_id._is_phantom_bom(): + if self.product_id and self._rma_is_kit_product(): for d in data: d.update( { @@ -107,7 +107,11 @@ class SaleOrderLine(models.Model): rely on the matching of sale order and pickings demands, but if those were manually changed, it could lead to inconsistencies""" self.ensure_one() - if self.product_id and not self.product_id._is_phantom_bom(): + if ( + self.product_id + and not self._rma_is_kit_product() + or not self.product_uom_qty + ): return 0 component_demand = sum( self.move_ids.filtered( @@ -115,3 +119,17 @@ class SaleOrderLine(models.Model): ).mapped("product_uom_qty") ) return component_demand / self.product_uom_qty + + def _rma_is_kit_product(self): + """The method _is_phantom_bom isn't available anymore. We wan't to use + the same rule Odoo does in core""" + bom = ( + self.env["mrp.bom"] + .sudo() + ._bom_find( + product=self.product_id, + company_id=self.company_id.id, + bom_type="phantom", + ) + ) + return bom and bom.type == "phantom" diff --git a/rma_sale_mrp/static/description/index.html b/rma_sale_mrp/static/description/index.html index 606e3a07..e87ce535 100644 --- a/rma_sale_mrp/static/description/index.html +++ b/rma_sale_mrp/static/description/index.html @@ -367,7 +367,7 @@ ul.auto-toc { !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

Beta License: AGPL-3 OCA/rma Translate me on Weblate Try me on Runbot

+

Beta License: AGPL-3 OCA/rma Translate me on Weblate Try me on Runbot

This module enables RMAs for kits, wich isn’t compatible with the base modules. In the backend side, we can return separate component while in the frontend side, customers can return the whole kit and the proper RMAs will be generated.

@@ -423,7 +423,7 @@ version to use the same rules so they fail for the same reasons.

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.

@@ -452,7 +452,7 @@ mission is to support the collaborative development of Odoo features and promote its widespread use.

Current maintainer:

chienandalu

-

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_sale_mrp/tests/test_rma_sale_mrp.py b/rma_sale_mrp/tests/test_rma_sale_mrp.py index 2b00d5e1..9b66d0a5 100644 --- a/rma_sale_mrp/tests/test_rma_sale_mrp.py +++ b/rma_sale_mrp/tests/test_rma_sale_mrp.py @@ -131,7 +131,7 @@ class TestRmaSaleMrp(SavepointCase): self.assertEqual(rma.refund_id, rmas_left.mapped("refund_id")) # The refund product is the kit, not the components self.assertEqual(rma.refund_id.invoice_line_ids.product_id, self.product_kit) - rma.refund_id.action_invoice_open() + rma.refund_id.post() # We can still return another kit wizard_id = order.action_create_rma()["res_id"] wizard = self.env["sale.order.rma.wizard"].browse(wizard_id) diff --git a/rma_sale_mrp/views/rma_views.xml b/rma_sale_mrp/views/rma_views.xml index d3325c27..9beaaf94 100644 --- a/rma_sale_mrp/views/rma_views.xml +++ b/rma_sale_mrp/views/rma_views.xml @@ -1,11 +1,14 @@ - + rma - + @@ -14,7 +17,7 @@ rma - + diff --git a/rma_sale_mrp/wizard/sale_order_rma_wizard.py b/rma_sale_mrp/wizard/sale_order_rma_wizard.py index 0ef72019..be80473a 100644 --- a/rma_sale_mrp/wizard/sale_order_rma_wizard.py +++ b/rma_sale_mrp/wizard/sale_order_rma_wizard.py @@ -98,7 +98,8 @@ class SaleOrderLineRmaWizard(models.TransientModel): """We need to process kit components separately so we can match them against their phantom product""" not_kit = self.filtered( - lambda x: not x.phantom_bom_product and not x.product_id._is_phantom_bom() + lambda x: not x.phantom_bom_product + and not x.sale_line_id._rma_is_kit_product() ) super(SaleOrderLineRmaWizard, not_kit)._compute_move_id() for line in self.filtered(lambda x: x.phantom_bom_product and x.picking_id):