mirror of
https://github.com/ForgeFlow/stock-rma.git
synced 2025-01-21 12:57:49 +02:00
[ADD] rma_repair_refurbish: split refurbish dependency from rma_repair
This commit is contained in:
@@ -2,13 +2,13 @@
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
||||
{
|
||||
"name": "RMA Repair",
|
||||
"version": "14.0.1.0.0",
|
||||
"version": "14.0.2.0.0",
|
||||
"license": "AGPL-3",
|
||||
"category": "RMA",
|
||||
"summary": "Links RMA with Repairs.",
|
||||
"author": "ForgeFlow S.L., Odoo Community Association (OCA)",
|
||||
"website": "https://github.com/ForgeFlow/stock-rma",
|
||||
"depends": ["rma_account", "repair_refurbish"],
|
||||
"depends": ["rma_account", "repair"],
|
||||
"data": [
|
||||
"security/ir.model.access.csv",
|
||||
"views/rma_order_view.xml",
|
||||
|
||||
@@ -24,11 +24,6 @@ class RmaOperation(models.Model):
|
||||
comodel_name="stock.location",
|
||||
help="Indicate here the source location of the product to be repaired",
|
||||
)
|
||||
repair_location_dest_id = fields.Many2one(
|
||||
string="Repair Destination Location",
|
||||
comodel_name="stock.location",
|
||||
help="Indicate here the destination location of the repair",
|
||||
)
|
||||
repair_invoice_method = fields.Selection(
|
||||
string="Repair Invoice Method",
|
||||
selection=[
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
<group name="outbound" position="after">
|
||||
<group name="repair" string="Repair">
|
||||
<field name="repair_location_id" />
|
||||
<field name="repair_location_dest_id" />
|
||||
<field name="repair_invoice_method" />
|
||||
</group>
|
||||
</group>
|
||||
|
||||
@@ -17,11 +17,6 @@ class RmaLineMakeRepair(models.TransientModel):
|
||||
|
||||
@api.model
|
||||
def _prepare_item(self, line):
|
||||
if line.product_id.refurbish_product_id:
|
||||
to_refurbish = True
|
||||
refurbish_product_id = line.product_id.refurbish_product_id.id
|
||||
else:
|
||||
to_refurbish = refurbish_product_id = False
|
||||
return {
|
||||
"line_id": line.id,
|
||||
"product_id": line.product_id.id,
|
||||
@@ -30,12 +25,8 @@ class RmaLineMakeRepair(models.TransientModel):
|
||||
"out_route_id": line.out_route_id.id,
|
||||
"product_uom_id": line.uom_id.id,
|
||||
"partner_id": line.partner_id.id,
|
||||
"to_refurbish": to_refurbish,
|
||||
"refurbish_product_id": refurbish_product_id,
|
||||
"location_id": line.operation_id.repair_location_id.id
|
||||
or line.location_id.id,
|
||||
"location_dest_id": line.operation_id.repair_location_dest_id.id
|
||||
or line.location_id.id,
|
||||
"invoice_method": line.operation_id.repair_invoice_method or "after_repair",
|
||||
}
|
||||
|
||||
@@ -86,13 +77,6 @@ class RmaLineMakeRepairItem(models.TransientModel):
|
||||
if rec.product_qty <= 0.0:
|
||||
raise ValidationError(_("Quantity must be positive."))
|
||||
|
||||
@api.onchange("to_refurbish")
|
||||
def _onchange_to_refurbish(self):
|
||||
if self.to_refurbish:
|
||||
self.refurbish_product_id = self.product_id.refurbish_product_id
|
||||
else:
|
||||
self.refurbish_product_id = False
|
||||
|
||||
wiz_id = fields.Many2one(
|
||||
comodel_name="rma.order.line.make.repair", string="Wizard", ondelete="cascade"
|
||||
)
|
||||
@@ -124,13 +108,6 @@ class RmaLineMakeRepairItem(models.TransientModel):
|
||||
location_id = fields.Many2one(
|
||||
comodel_name="stock.location", string="Location", required=True
|
||||
)
|
||||
location_dest_id = fields.Many2one(
|
||||
comodel_name="stock.location", string="Destination location", required=True
|
||||
)
|
||||
to_refurbish = fields.Boolean(string="To Refurbish?")
|
||||
refurbish_product_id = fields.Many2one(
|
||||
comodel_name="product.product", string="Refurbished Product"
|
||||
)
|
||||
invoice_method = fields.Selection(
|
||||
string="Invoice Method",
|
||||
selection=[
|
||||
@@ -147,14 +124,6 @@ class RmaLineMakeRepairItem(models.TransientModel):
|
||||
|
||||
def _prepare_repair_order(self, rma_line):
|
||||
self.ensure_one()
|
||||
location_dest = (
|
||||
self.location_dest_id
|
||||
if not self.to_refurbish
|
||||
else rma_line.product_id.property_stock_refurbish
|
||||
)
|
||||
refurbish_location_dest_id = (
|
||||
self.location_dest_id.id if self.to_refurbish else False
|
||||
)
|
||||
addr = rma_line.partner_id.address_get(["delivery", "invoice"])
|
||||
return {
|
||||
"product_id": rma_line.product_id.id,
|
||||
@@ -165,10 +134,6 @@ class RmaLineMakeRepairItem(models.TransientModel):
|
||||
"product_uom": rma_line.product_id.uom_po_id.id,
|
||||
"company_id": rma_line.company_id.id,
|
||||
"location_id": self.location_id.id,
|
||||
"location_dest_id": location_dest.id,
|
||||
"refurbish_location_dest_id": refurbish_location_dest_id,
|
||||
"refurbish_product_id": self.refurbish_product_id.id,
|
||||
"to_refurbish": self.to_refurbish,
|
||||
"invoice_method": self.invoice_method,
|
||||
"address_id": addr["delivery"],
|
||||
"partner_invoice_id": addr["invoice"],
|
||||
|
||||
@@ -17,18 +17,9 @@
|
||||
<field name="product_qty" />
|
||||
<field name="product_uom_id" groups="uom.group_uom" />
|
||||
<field name="partner_id" />
|
||||
<field name="to_refurbish" />
|
||||
<field
|
||||
name="refurbish_product_id"
|
||||
attrs="{'required': [('to_refurbish', '=', True)]}"
|
||||
/>
|
||||
<field
|
||||
name="location_id"
|
||||
groups="stock.group_stock_multi_locations"
|
||||
/>
|
||||
<field
|
||||
name="location_dest_id"
|
||||
groups="stock.group_stock_multi_locations"
|
||||
/>
|
||||
<field name="invoice_method" />
|
||||
</tree>
|
||||
|
||||
49
rma_repair_refurbish/README.rst
Normal file
49
rma_repair_refurbish/README.rst
Normal file
@@ -0,0 +1,49 @@
|
||||
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
|
||||
:alt: License AGPL-3
|
||||
|
||||
==========
|
||||
RMA Repair
|
||||
==========
|
||||
|
||||
This module allows you to create repairs from one or more RMA lines.
|
||||
|
||||
Installation
|
||||
============
|
||||
|
||||
This module depends on ``repair_refurbish`` which is available at
|
||||
`OCA/manufacture <https://github.com/OCA/manufacture>`_.
|
||||
|
||||
Usage
|
||||
=====
|
||||
|
||||
To create repairs from RMA lines:
|
||||
|
||||
#. Go to an approved RMA.
|
||||
#. Click on *Create Repair Order*.
|
||||
#. Fill the required information in the lines.
|
||||
#. Hit *Create Repair Orders*.
|
||||
|
||||
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 <jordi.ballester@eficent.com>
|
||||
* Aaron Henriquez <ahenriquez@eficent.com>
|
||||
* Lois Rilo <lois.rilo@eficent.com>
|
||||
* Akim Juillerat <akim.juillerat@camptocamp.com>
|
||||
* Bhavesh Odedra <bodedra@opensourceintegrators.com>
|
||||
|
||||
Maintainer
|
||||
----------
|
||||
|
||||
This module is maintained by Eficent
|
||||
2
rma_repair_refurbish/__init__.py
Normal file
2
rma_repair_refurbish/__init__.py
Normal file
@@ -0,0 +1,2 @@
|
||||
from . import models
|
||||
from . import wizards
|
||||
17
rma_repair_refurbish/__manifest__.py
Normal file
17
rma_repair_refurbish/__manifest__.py
Normal file
@@ -0,0 +1,17 @@
|
||||
# Copyright 2020-22 ForgeFlow S.L.
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
||||
{
|
||||
"name": "RMA Repair Refurbish",
|
||||
"version": "14.0.1.0.0",
|
||||
"license": "AGPL-3",
|
||||
"category": "RMA",
|
||||
"summary": "Links RMA with Repairs and Refurbish.",
|
||||
"author": "ForgeFlow, Odoo Community Association (OCA)",
|
||||
"website": "https://github.com/ForgeFlow/stock-rma",
|
||||
"depends": ["rma_repair", "repair_refurbish"],
|
||||
"data": [
|
||||
"wizards/rma_order_line_make_repair_view.xml",
|
||||
],
|
||||
"installable": True,
|
||||
"auto_install": True,
|
||||
}
|
||||
1
rma_repair_refurbish/models/__init__.py
Normal file
1
rma_repair_refurbish/models/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from . import rma_operation
|
||||
14
rma_repair_refurbish/models/rma_operation.py
Normal file
14
rma_repair_refurbish/models/rma_operation.py
Normal file
@@ -0,0 +1,14 @@
|
||||
# Copyright 2020-22 ForgeFlow S.L.
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class RmaOperation(models.Model):
|
||||
_inherit = "rma.operation"
|
||||
|
||||
repair_location_dest_id = fields.Many2one(
|
||||
string="Repair Destination Location",
|
||||
comodel_name="stock.location",
|
||||
help="Indicate here the destination location of the repair",
|
||||
)
|
||||
4
rma_repair_refurbish/wizards/__init__.py
Normal file
4
rma_repair_refurbish/wizards/__init__.py
Normal file
@@ -0,0 +1,4 @@
|
||||
# Copyright 2020 ForgeFlow S.L.
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from . import rma_order_line_make_repair
|
||||
58
rma_repair_refurbish/wizards/rma_order_line_make_repair.py
Normal file
58
rma_repair_refurbish/wizards/rma_order_line_make_repair.py
Normal file
@@ -0,0 +1,58 @@
|
||||
# Copyright 2020-22 ForgeFlow S.L.
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from odoo import api, fields, models
|
||||
|
||||
|
||||
class RmaLineMakeRepair(models.TransientModel):
|
||||
_inherit = "rma.order.line.make.repair"
|
||||
|
||||
@api.model
|
||||
def _prepare_item(self, line):
|
||||
res = super(RmaLineMakeRepair, self)._prepare_item(line)
|
||||
if line.product_id.refurbish_product_id:
|
||||
to_refurbish = True
|
||||
refurbish_product_id = line.product_id.refurbish_product_id.id
|
||||
else:
|
||||
to_refurbish = refurbish_product_id = False
|
||||
res["to_refurbish"] = to_refurbish
|
||||
if refurbish_product_id:
|
||||
res["refurbish_product_id"] = refurbish_product_id
|
||||
res["location_dest_id"] = (
|
||||
line.operation_id.repair_location_dest_id.id or line.location_id.id
|
||||
)
|
||||
return res
|
||||
|
||||
|
||||
class RmaLineMakeRepairItem(models.TransientModel):
|
||||
_inherit = "rma.order.line.make.repair.item"
|
||||
|
||||
@api.onchange("to_refurbish")
|
||||
def _onchange_to_refurbish(self):
|
||||
if self.to_refurbish:
|
||||
self.refurbish_product_id = self.product_id.refurbish_product_id
|
||||
else:
|
||||
self.refurbish_product_id = False
|
||||
|
||||
location_dest_id = fields.Many2one(
|
||||
comodel_name="stock.location", string="Destination location", required=True
|
||||
)
|
||||
to_refurbish = fields.Boolean(string="To Refurbish?")
|
||||
refurbish_product_id = fields.Many2one(
|
||||
comodel_name="product.product", string="Refurbished Product"
|
||||
)
|
||||
|
||||
def _prepare_repair_order(self, rma_line):
|
||||
res = super(RmaLineMakeRepairItem, self)._prepare_repair_order(rma_line)
|
||||
location_dest = (
|
||||
self.location_dest_id
|
||||
if not self.to_refurbish
|
||||
else rma_line.product_id.property_stock_refurbish
|
||||
)
|
||||
refurbish_location_dest_id = (
|
||||
self.location_dest_id.id if self.to_refurbish else False
|
||||
)
|
||||
res["location_dest_id"] = location_dest.id
|
||||
res["refurbish_location_dest_id"] = refurbish_location_dest_id
|
||||
res["to_refurbish"] = self.to_refurbish
|
||||
return res
|
||||
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<odoo>
|
||||
|
||||
<record id="view_rma_order_line_make_repair" model="ir.ui.view">
|
||||
<field name="name">RMA Line Make Repair - Refurbish</field>
|
||||
<field name="model">rma.order.line.make.repair</field>
|
||||
<field name="inherit_id" ref="rma_repair.view_rma_order_line_make_repair" />
|
||||
<field name="arch" type="xml">
|
||||
<field name="partner_id" position="after">
|
||||
<field name="to_refurbish" />
|
||||
<field
|
||||
name="refurbish_product_id"
|
||||
attrs="{'required': [('to_refurbish', '=', True)]}"
|
||||
/>
|
||||
<field name="location_id" groups="stock.group_stock_multi_locations" />
|
||||
<field
|
||||
name="location_dest_id"
|
||||
groups="stock.group_stock_multi_locations"
|
||||
/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
1
setup/rma_repair_refurbish/odoo/addons/rma_repair_refurbish
Symbolic link
1
setup/rma_repair_refurbish/odoo/addons/rma_repair_refurbish
Symbolic link
@@ -0,0 +1 @@
|
||||
../../../../rma_repair_refurbish
|
||||
6
setup/rma_repair_refurbish/setup.py
Normal file
6
setup/rma_repair_refurbish/setup.py
Normal file
@@ -0,0 +1,6 @@
|
||||
import setuptools
|
||||
|
||||
setuptools.setup(
|
||||
setup_requires=['setuptools-odoo'],
|
||||
odoo_addon=True,
|
||||
)
|
||||
Reference in New Issue
Block a user