Skip to content

Commit

Permalink
Merge pull request #516 from ForgeFlow/17.0-mig-rma_sale-good
Browse files Browse the repository at this point in the history
[17.0][MIG] rma_sale
  • Loading branch information
LoisRForgeFlow authored Jan 9, 2025
2 parents 15e12e5 + 6d383af commit f57de50
Show file tree
Hide file tree
Showing 27 changed files with 1,790 additions and 0 deletions.
57 changes: 57 additions & 0 deletions rma_sale/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
.. image:: https://img.shields.io/badge/licence-LGPL--3-blue.svg
:alt: License LGPL-3

========
RMA Sale
========

This module allows you to:

#. Import sales order lines into RMA lines
#. Create a sales order and/or sales order line from one or more RMA lines

Usage
=====

**Import existing sales order lines into an RMA:**

This feature is useful when you create an RMA associated to a product that
was shipped and you have as a reference the customer PO number.

#. Access to a customer RMA.
#. Fill the customer.
#. Press the button *Add from Sales Order*.
#. In the wizard add a sales order and click on *add item* to select the
lines you want to add to the RMA.

**Create a sales order and/or sales order line from RMA lines:**

#. Go to a approved RMA line.
#. Click on *Create a Sales Quotation*.
#. In the wizard, select an *Existing Quotation to update* or leave it empty
if you want to create a new one.
#. Fill the quantity to sell in the lines.
#. Hit *Create a Sales Quotation*.

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

Bugs are tracked on `GitHub Issues
<https://github.com/Eficent/stock-rma/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.

Credits
=======

Contributors
------------

* Jordi Ballester Alomar <[email protected]>
* Aaron Henriquez <[email protected]>
* Lois Rilo <[email protected]>

Maintainer
----------

This module is maintained by Eficent
4 changes: 4 additions & 0 deletions rma_sale/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright 2020 ForgeFlow S.L.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
from . import models
from . import wizards
24 changes: 24 additions & 0 deletions rma_sale/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright 2020 ForgeFlow S.L.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)

{
"name": "RMA Sale",
"version": "17.0.1.0.0",
"license": "LGPL-3",
"category": "RMA",
"summary": "Links RMA with Sales Orders",
"author": "ForgeFlow",
"website": "https://github.com/ForgeFlow",
"depends": ["rma_account", "sale_stock"],
"data": [
"security/ir.model.access.csv",
"data/rma_operation.xml",
"views/rma_order_view.xml",
"views/rma_operation_view.xml",
"views/sale_order_view.xml",
"wizards/rma_order_line_make_sale_order_view.xml",
"wizards/rma_add_sale.xml",
"views/rma_order_line_view.xml",
],
"installable": True,
}
28 changes: 28 additions & 0 deletions rma_sale/data/rma_operation.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo noupdate="1">

<record id="rma_operation_customer_sale" model="rma.operation">
<field name="name">Sale after receive</field>
<field name="code">SL-C</field>
<field name="sale_policy">received</field>
<field name="receipt_policy">ordered</field>
<field name="delivery_policy">no</field>
<field name="refund_policy">no</field>
<field name="type">customer</field>
<field name="in_route_id" ref="rma.route_rma_customer" />
<field name="out_route_id" ref="rma.route_rma_customer" />
</record>

<record id="rma_operation_customer_sale_advanced" model="rma.operation">
<field name="name">Advanced Refund</field>
<field name="code">AR-C</field>
<field name="sale_policy">received</field>
<field name="receipt_policy">ordered</field>
<field name="delivery_policy">no</field>
<field name="refund_policy">received</field>
<field name="type">customer</field>
<field name="in_route_id" ref="rma.route_rma_customer" />
<field name="out_route_id" ref="rma.route_rma_customer" />
</record>

</odoo>
8 changes: 8 additions & 0 deletions rma_sale/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Copyright 2020-2022 ForgeFlow S.L.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
from . import sale_order_line
from . import sale_order
from . import rma_order_line
from . import rma_order
from . import rma_operation
from . import procurement
37 changes: 37 additions & 0 deletions rma_sale/models/procurement.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Copyright 2022 ForgeFlow S.L.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)

from odoo import models


class StockRule(models.Model):
_inherit = "stock.rule"

def _get_stock_move_values(
self,
product_id,
product_qty,
product_uom,
location_id,
name,
origin,
company_id,
values,
):
res = super()._get_stock_move_values(
product_id,
product_qty,
product_uom,
location_id,
name,
origin,
company_id,
values,
)
if "rma_line_id" in values:
line = values.get("rma_line_id")
line = self.env["rma.order.line"].browse([line])
if line.reference_move_id:
return res
res["price_unit"] = line._get_price_unit()
return res
26 changes: 26 additions & 0 deletions rma_sale/models/rma_operation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Copyright 2020 ForgeFlow S.L.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
from odoo import fields, models


class RmaOperation(models.Model):
_inherit = "rma.operation"

sale_policy = fields.Selection(
[
("no", "Not required"),
("ordered", "Based on Ordered Quantities"),
("received", "Based on Received Quantities"),
],
default="no",
)
auto_confirm_rma_sale = fields.Boolean(
string="Auto confirm Sales Order upon creation from RMA",
help="When a sales is created from an RMA, automatically confirm it",
readonly=False,
)
free_of_charge_rma_sale = fields.Boolean(
string="Free of charge RMA Sales Order",
help="Sales orders created from RMA are free of charge by default",
readonly=False,
)
38 changes: 38 additions & 0 deletions rma_sale/models/rma_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Copyright 2020 ForgeFlow S.L.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
from odoo import api, fields, models


class RmaOrder(models.Model):
_inherit = "rma.order"

@api.depends(
"rma_line_ids",
"rma_line_ids.sale_line_id",
"rma_line_ids.sale_line_id.order_id",
)
def _compute_sales_count(self):
for rma in self:
sales = rma.mapped("rma_line_ids.sale_line_id.order_id")
rma.sale_count = len(sales)

sale_count = fields.Integer(compute="_compute_sales_count", string="# of Sales")

@api.model
def _get_line_domain(self, rma_id, line):
if line.sale_line_id and line.sale_line_id.id:
domain = [
("rma_id", "=", rma_id.id),
("type", "=", "supplier"),
("sale_line_id", "=", line.sale_line_id.id),
]
else:
domain = super()._get_line_domain(rma_id, line)
return domain

def action_view_sale_order(self):
action = self.env.ref("sale.action_quotations")
result = action.sudo().read()[0]
so_ids = self.mapped("rma_line_ids.sale_line_id.order_id").ids
result["domain"] = [("id", "in", so_ids)]
return result
Loading

0 comments on commit f57de50

Please sign in to comment.