mirror of
https://github.com/ForgeFlow/stock-rma.git
synced 2025-01-21 12:57:49 +02:00
[ADD] rma_product_warranty v16
This commit is contained in:
29
rma_product_warranty/README.rst
Normal file
29
rma_product_warranty/README.rst
Normal file
@@ -0,0 +1,29 @@
|
||||
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
|
||||
:alt: License AGPL-3
|
||||
|
||||
====================
|
||||
RMA Product Warranty
|
||||
====================
|
||||
|
||||
This module integrates RMA with product warranties
|
||||
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 smashing it by providing a detailed and welcomed feedback.
|
||||
|
||||
Credits
|
||||
=======
|
||||
|
||||
Contributors
|
||||
------------
|
||||
|
||||
* Aaron Henriquez <aaron.henriquez@forgeflow.com>
|
||||
|
||||
|
||||
Maintainer
|
||||
----------
|
||||
|
||||
This module is maintained by ForgeFlow
|
||||
1
rma_product_warranty/__init__.py
Normal file
1
rma_product_warranty/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from . import models
|
||||
15
rma_product_warranty/__manifest__.py
Normal file
15
rma_product_warranty/__manifest__.py
Normal file
@@ -0,0 +1,15 @@
|
||||
# Copyright 2023 ForgeFlow S.L.
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html)
|
||||
|
||||
{
|
||||
"name": "RMA Product Warranty",
|
||||
"version": "16.0.1.0.0",
|
||||
"license": "AGPL-3",
|
||||
"category": "RMA",
|
||||
"summary": "Integrates RMA Product Warranty",
|
||||
"author": "ForgeFlow",
|
||||
"website": "https://github.com/ForgeFlow/stock-rma",
|
||||
"depends": ["rma", "product_warranty"],
|
||||
"data": ["views/rma_order_line_view.xml"],
|
||||
"installable": True,
|
||||
}
|
||||
1
rma_product_warranty/models/__init__.py
Normal file
1
rma_product_warranty/models/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from . import rma_order_line
|
||||
49
rma_product_warranty/models/rma_order_line.py
Normal file
49
rma_product_warranty/models/rma_order_line.py
Normal file
@@ -0,0 +1,49 @@
|
||||
# Copyright 2023 ForgeFlow S.L.
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html)
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
from dateutil.relativedelta import relativedelta
|
||||
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class RmaOrderLine(models.Model):
|
||||
|
||||
_inherit = "rma.order.line"
|
||||
|
||||
warranty_end_date = fields.Date(compute="_compute_warranty_end_date")
|
||||
under_warranty = fields.Boolean(compute="_compute_under_warranty")
|
||||
|
||||
def _compute_warranty_end_date(self):
|
||||
for rec in self:
|
||||
warranty = rec.product_id.warranty
|
||||
if rec.reference_move_id and warranty:
|
||||
if rec.product_id.warranty_type == "day":
|
||||
rec.warranty_end_date = rec.reference_move_id.date + relativedelta(
|
||||
days=warranty
|
||||
)
|
||||
elif rec.product_id.warranty_type == "week":
|
||||
rec.warranty_end_date = rec.reference_move_id.date + relativedelta(
|
||||
weeks=warranty
|
||||
)
|
||||
elif rec.product_id.warranty_type == "month":
|
||||
rec.warranty_end_date = rec.reference_move_id.date + relativedelta(
|
||||
months=warranty
|
||||
)
|
||||
elif rec.product_id.warranty_type == "year":
|
||||
rec.warranty_end_date = rec.reference_move_id.date + relativedelta(
|
||||
years=warranty
|
||||
)
|
||||
else:
|
||||
rec.warranty_end_date = False
|
||||
else:
|
||||
rec.warranty_end_date = False
|
||||
|
||||
def _compute_under_warranty(self):
|
||||
today = datetime.today()
|
||||
for rec in self:
|
||||
if not rec.warranty_end_date:
|
||||
rec.under_warranty = True
|
||||
else:
|
||||
rec.under_warranty = rec.warranty_end_date >= today.date()
|
||||
15
rma_product_warranty/views/rma_order_line_view.xml
Normal file
15
rma_product_warranty/views/rma_order_line_view.xml
Normal file
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<odoo>
|
||||
|
||||
<record id="view_rma_line_warranty_form" model="ir.ui.view">
|
||||
<field name="name">rma.order.line.warranty.form</field>
|
||||
<field name="model">rma.order.line</field>
|
||||
<field name="inherit_id" ref="rma.view_rma_line_form" />
|
||||
<field name="arch" type="xml">
|
||||
<field name="under_warranty" position="after">
|
||||
<field name="warranty_end_date" />
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
1
setup/rma_product_warranty/odoo/addons/rma_product_warranty
Symbolic link
1
setup/rma_product_warranty/odoo/addons/rma_product_warranty
Symbolic link
@@ -0,0 +1 @@
|
||||
../../../../rma_product_warranty
|
||||
6
setup/rma_product_warranty/setup.py
Normal file
6
setup/rma_product_warranty/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