diff --git a/rma/__manifest__.py b/rma/__manifest__.py index 5e852428..2cb7bc58 100644 --- a/rma/__manifest__.py +++ b/rma/__manifest__.py @@ -3,7 +3,7 @@ { "name": "RMA (Return Merchandise Authorization)", - "version": "15.0.1.1.0", + "version": "15.0.1.1.1", "license": "LGPL-3", "category": "RMA", "summary": "Introduces the return merchandise authorization (RMA) process in odoo", diff --git a/rma/models/rma_order_line.py b/rma/models/rma_order_line.py index c0754908..34e8e574 100644 --- a/rma/models/rma_order_line.py +++ b/rma/models/rma_order_line.py @@ -303,7 +303,12 @@ class RmaOrderLine(models.Model): readonly=True, states={"draft": [("readonly", False)]}, ) - price_unit = fields.Monetary(readonly=True, states={"draft": [("readonly", False)]}) + price_unit = fields.Monetary( + string="Unit cost", + readonly=True, + states={"draft": [("readonly", False)]}, + help="Unit cost of the items under RMA", + ) in_shipment_count = fields.Integer( compute="_compute_in_shipment_count", string="# of Shipments" ) @@ -636,15 +641,24 @@ class RmaOrderLine(models.Model): ) return super(RmaOrderLine, self).create(vals) + def _get_price_unit(self): + """The price unit corresponds to the cost of that product""" + self.ensure_one() + if self.reference_move_id: + price_unit = self.reference_move_id.price_unit + else: + price_unit = self.product_id.with_company(self.company_id).standard_price + return price_unit + @api.onchange("product_id") def _onchange_product_id(self): result = {} if not self.product_id: return result self.uom_id = self.product_id.uom_id.id - self.price_unit = self.product_id.standard_price if not self.type: self.type = self._get_default_type() + self.price_unit = self._get_price_unit() if self.type == "customer": self.operation_id = ( self.product_id.rma_customer_operation_id diff --git a/rma/models/stock_rule.py b/rma/models/stock_rule.py index 678d971e..0c7119f5 100644 --- a/rma/models/stock_rule.py +++ b/rma/models/stock_rule.py @@ -36,11 +36,5 @@ class StockRule(models.Model): res["partner_id"] = line.delivery_address_id.id else: res["partner_id"] = line.rma_id.partner_id.id - # We are not checking the reference move here because if stock account - # is not installed, there is no way to know the cost of the stock move - # so better use the standard cost in this case. - company_id = res["company_id"] - company = self.env["res.company"].browse(company_id) - cost = product_id.with_company(company).standard_price - res["price_unit"] = cost + res["price_unit"] = line._get_price_unit() return res