Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0][ADD] product_warranty & rma_product_warranty #479

Open
wants to merge 3 commits into
base: 16.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions rma_account_product_warranty/README.rst
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions rma_account_product_warranty/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
14 changes: 14 additions & 0 deletions rma_account_product_warranty/__manifest__.py
Original file line number Diff line number Diff line change
@@ -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,
}
1 change: 1 addition & 0 deletions rma_account_product_warranty/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import rma_order_line
38 changes: 38 additions & 0 deletions rma_account_product_warranty/models/rma_order_line.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# 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)
)
elif rec.sale_line_id and rec.sale_line_id.invoice_lines:
rec.warranty_end_date = rec.sale_line_id.invoice_lines[
0
].date + relativedelta(years=warranty)
return res
29 changes: 29 additions & 0 deletions rma_product_warranty/README.rst
Original file line number Diff line number Diff line change
@@ -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 change: 1 addition & 0 deletions rma_product_warranty/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
15 changes: 15 additions & 0 deletions rma_product_warranty/__manifest__.py
Original file line number Diff line number Diff line change
@@ -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 change: 1 addition & 0 deletions rma_product_warranty/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import rma_order_line
49 changes: 49 additions & 0 deletions rma_product_warranty/models/rma_order_line.py
Original file line number Diff line number Diff line change
@@ -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 changes: 15 additions & 0 deletions rma_product_warranty/views/rma_order_line_view.xml
Original file line number Diff line number Diff line change
@@ -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>
6 changes: 6 additions & 0 deletions setup/rma_account_product_warranty/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
6 changes: 6 additions & 0 deletions setup/rma_product_warranty/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
Loading