[ADD] rma_product_warranty v16

This commit is contained in:
AaronHForgeFlow
2023-10-31 12:59:19 +01:00
parent 139340eaf8
commit fd9b5809c4
8 changed files with 117 additions and 0 deletions

View 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

View File

@@ -0,0 +1 @@
from . import models

View 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,
}

View File

@@ -0,0 +1 @@
from . import rma_order_line

View 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()

View 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>

View File

@@ -0,0 +1 @@
../../../../rma_product_warranty

View File

@@ -0,0 +1,6 @@
import setuptools
setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)