[ADD] rma_account_product_warranty in v16

This commit is contained in:
AaronHForgeFlow
2023-10-31 12:59:36 +01:00
parent fd9b5809c4
commit c25a64bb30
7 changed files with 87 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:alt: License AGPL-3
============================
RMA Account 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,14 @@
# 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 Account with Product Warranty",
"author": "ForgeFlow",
"website": "https://github.com/ForgeFlow/stock-rma",
"depends": ["rma_account", "rma_product_warranty"],
"installable": True,
}

View File

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

View File

@@ -0,0 +1,34 @@
# Copyright 2023 ForgeFlow S.L.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html)
from dateutil.relativedelta import relativedelta
from odoo import models
class RmaOrderLine(models.Model):
_inherit = "rma.order.line"
def _compute_warranty_end_date(self):
res = super()._compute_warranty_end_date()
for rec in self:
warranty = rec.product_id.warranty
if rec.account_move_line_id and warranty:
if rec.product_id.warranty_type == "day":
rec.warranty_end_date = (
rec.account_move_line_id.date + relativedelta(days=warranty)
)
elif rec.product_id.warranty_type == "week":
rec.warranty_end_date = (
rec.account_move_line_id.date + relativedelta(weeks=warranty)
)
elif rec.product_id.warranty_type == "month":
rec.warranty_end_date = (
rec.account_move_line_id.date + relativedelta(months=warranty)
)
elif rec.product_id.warranty_type == "year":
rec.warranty_end_date = (
rec.account_move_line_id.date + relativedelta(years=warranty)
)
return res

View File

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

View File

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