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/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..c813b72d 100644 --- a/rma_sale_mrp/static/description/index.html +++ b/rma_sale_mrp/static/description/index.html @@ -3,7 +3,7 @@ - + Return Merchandise Authorization Management - Link with MRP Kits