Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0][MIG] rma_sale_mrp: Migration to 16.0 #451

Merged
merged 3 commits into from
Sep 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions rma_sale_mrp/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
=============================
RMA Manufacturing Integration
=============================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:0a029de8ab7176f3af957dcf8796bec39ee8fba332aea42ef559cf108dd14d50
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-ForgeFlow%2Fstock--rma-lightgray.png?logo=github
:target: https://github.com/ForgeFlow/stock-rma/tree/14.0/rma_mrp
:alt: ForgeFlow/stock-rma

|badge1| |badge2| |badge3|


**Table of contents**

.. contents::
:local:

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/ForgeFlow/stock-rma/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/ForgeFlow/stock-rma/issues/new?body=module:%20rma_mrp%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
~~~~~~~

* ForgeFlow

Contributors
~~~~~~~~~~~~

* Christopher Ormaza <[email protected]>

Maintainers
~~~~~~~~~~~

This module is part of the `ForgeFlow/stock-rma <https://github.com/ForgeFlow/stock-rma/tree/14.0/rma_mrp>`_ project on GitHub.

You are welcome to contribute.
3 changes: 3 additions & 0 deletions rma_sale_mrp/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Copyright 2023 ForgeFlow S.L.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
from . import models
15 changes: 15 additions & 0 deletions rma_sale_mrp/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2023 ForgeFlow S.L.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)

{
"name": "RMA Manufacturing Integration",
"version": "16.0.1.0.0",
"license": "LGPL-3",
"category": "RMA",
"summary": "Integrates RMA with Kit Manufacturing/Sale Process",
"author": "ForgeFlow",
"website": "https://github.com/ForgeFlow/stock-rma",
"depends": ["rma_sale", "sale_mrp"],
"data": [],
"installable": True,
}
3 changes: 3 additions & 0 deletions rma_sale_mrp/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Copyright 2023 ForgeFlow S.L.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
from . import rma_order_line
41 changes: 41 additions & 0 deletions rma_sale_mrp/models/rma_order_line.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Copyright 2023 ForgeFlow S.L.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)

from odoo import models
from odoo.tools import float_is_zero


class RmaOrderLine(models.Model):

_inherit = "rma.order.line"

def _get_price_unit(self):
self.ensure_one()
price_unit = 0
if (
self.env.context.get("product_required")
and self.env.context.get("product_required") != self.product_id
and self.sale_line_id
and self.sale_line_id.move_ids.filtered(
lambda x: x.state == "done"
and x.product_id == self.env.context.get("product_required")
)
):
done_moves = self.sale_line_id.move_ids.filtered(
lambda x: x.state == "done"
and x.location_dest_id.usage != "internal"
and x.location_id.usage == "internal"
and x.product_id == self.env.context.get("product_required")
)
layers_value = sum(done_moves.mapped("stock_valuation_layer_ids.value"))
layers_quantity = sum(
done_moves.mapped("stock_valuation_layer_ids.quantity")
)
pd = self.env["decimal.precision"].precision_get("Product Price")
if not float_is_zero(layers_quantity, precision_digits=pd):
price_unit = layers_value / layers_quantity
else:
price_unit = super(RmaOrderLine, self)._get_price_unit()
else:
price_unit = super(RmaOrderLine, self)._get_price_unit()
return price_unit
1 change: 1 addition & 0 deletions rma_sale_mrp/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Christopher Ormaza <[email protected]>
Empty file.
Loading
Loading