[MIG] product_warranty: Migration to 16.0

Co-Authored By: Stefan Ungureanu <stefan.ungureanu@tecnativa.com>
This commit is contained in:
arulbalamurugan
2022-11-29 12:05:46 +05:30
committed by Antoni Marroig Campomar
parent a4084d8c55
commit 6bcf4cb7ff
13 changed files with 126 additions and 140 deletions

View File

@@ -13,15 +13,15 @@ Product Warranty
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Frma-lightgray.png?logo=github
:target: https://github.com/OCA/rma/tree/15.0/product_warranty
:alt: OCA/rma
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2F/opt/odoo/oca/rma/-lightgray.png?logo=github
:target: https://github.com/OCA//opt/odoo/oca/rma//tree/16.0/product_warranty
:alt: OCA//opt/odoo/oca/rma/
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/rma-15-0/rma-15-0-product_warranty
:target: https://translation.odoo-community.org/projects//opt/odoo/oca/rma/-16-0//opt/odoo/oca/rma/-16-0-product_warranty
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/145/15.0
:alt: Try me on Runbot
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/webui/builds.html?repo=OCA//opt/odoo/oca/rma/&target_branch=16.0
:alt: Try me on Runboat
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -33,6 +33,12 @@ to set product warranty details on products and product-supplier relation.
.. contents::
:local:
Configuration
=============
To manage the available return instructions, enable debug mode and go to
*Sales -> Configuration -> Product Return Instructions*.
Usage
=====
@@ -48,10 +54,10 @@ To use this module, you need to:
Bug Tracker
===========
Bugs are tracked on `GitHub Issues <https://github.com/OCA/rma/issues>`_.
Bugs are tracked on `GitHub Issues <https://github.com/OCA//opt/odoo/oca/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 <https://github.com/OCA/rma/issues/new?body=module:%20product_warranty%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA//opt/odoo/oca/rma//issues/new?body=module:%20product_warranty%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Do not contact contributors directly about support or help with technical issues.
@@ -117,6 +123,6 @@ Current `maintainers <https://odoo-community.org/page/maintainer-role>`__:
|maintainer-osi-scampbell| |maintainer-max3903|
This module is part of the `OCA/rma <https://github.com/OCA/rma/tree/15.0/product_warranty>`_ project on GitHub.
This module is part of the `OCA//opt/odoo/oca/rma/ <https://github.com/OCA//opt/odoo/oca/rma//tree/16.0/product_warranty>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@@ -11,9 +11,10 @@
"depends": ["sale_management"],
"data": [
"security/ir.model.access.csv",
"views/res_company.xml",
"views/product_warranty.xml",
"views/product_template.xml",
"views/res_company_views.xml",
"views/product_supplierinfo_views.xml",
"views/product_template_views.xml",
"views/return_instructions_views.xml",
],
"demo": ["demo/product_warranty.xml", "demo/res_company.xml"],
"images": ["images/product_warranty.png"],

View File

@@ -40,7 +40,7 @@
name="product_tmpl_id"
ref="product.product_product_3_product_template"
/>
<field name="name" ref="base.res_partner_4" />
<field name="partner_id" ref="base.res_partner_4" />
<field name="delay">5</field>
<field name="min_qty">1</field>
</record>
@@ -52,7 +52,7 @@
name="product_tmpl_id"
ref="product.product_product_3_product_template"
/>
<field name="name" ref="base.res_partner_3" />
<field name="partner_id" ref="base.res_partner_3" />
<field name="delay">5</field>
<field name="min_qty">1</field>
</record>

View File

@@ -275,33 +275,3 @@ msgstr ""
#: model:ir.model.fields.selection,name:product_warranty.selection__product_template__warranty_type__year
msgid "Year(s)"
msgstr ""
#~ msgid ""
#~ "Warranty in month for this product/supplier relation. Only for company/"
#~ "supplier relation (purchase order) ; the customer/company relation (sale "
#~ "order) always use the product main warranty field"
#~ msgstr ""
#~ "Garantía en meses para este producto/proveedor. Únicamente para "
#~ "relaciones empresa/proveedor (Orden de compra); la relación cliente/"
#~ "proveedor (Orden de venta) usa siempre el campo garantía de la ficha de "
#~ "producto"
#~ msgid "Products return instructions"
#~ msgstr "Instrucciones de devolución de los productos"
#~ msgid "Information about a product supplier"
#~ msgstr "Información sobre un proveedor de producto"
#~ msgid ""
#~ "Who is in charge of the warranty return treatment toward the end "
#~ "customer. Company will use the current compagny delivery or default "
#~ "address and so on for supplier and brand manufacturer. Doesn't necessarly "
#~ "mean that the warranty to be applied is the one of the return partner "
#~ "(ie: can be returned to the company and be under the brand warranty"
#~ msgstr ""
#~ "Quién se encarga del tratamiento de retorno de garantía hacia el cliente "
#~ "final. Compañía utilizará la entrega compagny actual o la dirección por "
#~ "defecto y así sucesivamente para el proveedor y el fabricante de la "
#~ "marca. No significa necessarly que la garantía que se aplica es el de la "
#~ "pareja de retorno (es decir: pueden ser devueltos a la empresa y estar "
#~ "bajo la garantía de la marca"

View File

@@ -258,6 +258,3 @@ msgstr ""
#: model:ir.model.fields.selection,name:product_warranty.selection__product_template__warranty_type__year
msgid "Year(s)"
msgstr ""
#~ msgid "Information about a product supplier"
#~ msgstr "Information sur le fournisseur du produit"

View File

@@ -16,30 +16,6 @@ class ProductSupplierInfo(models.Model):
[("is_default", "=", True)], limit=1
)
@api.depends("warranty_return_partner")
def _compute_warranty_return_address(self):
"""Method to return the partner delivery address or if none, the
default address
"""
for record in self:
return_partner = record.warranty_return_partner
partner_id = record.company_id.partner_id.id
if return_partner and return_partner == "supplier":
partner_id = record.name.id
elif (
return_partner
and return_partner == "company"
and record.company_id.crm_return_address_id
):
partner_id = record.company_id.crm_return_address_id.id
elif (
return_partner
and return_partner == "other"
and record.warranty_return_other_address
):
partner_id = record.warranty_return_other_address.id
record.warranty_return_address = partner_id
warranty_duration = fields.Float(
"Period",
help="Warranty in month for this product/supplier relation. Only "
@@ -82,3 +58,27 @@ class ProductSupplierInfo(models.Model):
help="Where the customer has to send back the product(s) "
"if warranty return is set to 'other'.",
)
@api.depends("warranty_return_partner")
def _compute_warranty_return_address(self):
"""Method to return the partner delivery address or if none, the
default address
"""
for record in self:
return_partner = record.warranty_return_partner
partner_id = record.company_id.partner_id.id
if return_partner and return_partner == "supplier":
partner_id = record.partner_id.id
elif (
return_partner
and return_partner == "company"
and record.company_id.crm_return_address_id
):
partner_id = record.company_id.crm_return_address_id.id
elif (
return_partner
and return_partner == "other"
and record.warranty_return_other_address
):
partner_id = record.warranty_return_other_address.id
record.warranty_return_address = partner_id

View File

@@ -0,0 +1,2 @@
To manage the available return instructions, enable debug mode and go to
*Sales -> Configuration -> Product Return Instructions*.

View File

@@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.15.1: http://docutils.sourceforge.net/" />
<meta name="generator" content="Docutils: http://docutils.sourceforge.net/" />
<title>Product Warranty</title>
<style type="text/css">
@@ -367,25 +367,31 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Production/Stable" src="https://img.shields.io/badge/maturity-Production%2FStable-green.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/rma/tree/15.0/product_warranty"><img alt="OCA/rma" src="https://img.shields.io/badge/github-OCA%2Frma-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/rma-15-0/rma-15-0-product_warranty"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/145/15.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Production/Stable" src="https://img.shields.io/badge/maturity-Production%2FStable-green.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA//opt/odoo/oca/rma//tree/16.0/product_warranty"><img alt="OCA//opt/odoo/oca/rma/" src="https://img.shields.io/badge/github-OCA%2F/opt/odoo/oca/rma/-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects//opt/odoo/oca/rma/-16-0//opt/odoo/oca/rma/-16-0-product_warranty"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runboat.odoo-community.org/webui/builds.html?repo=OCA//opt/odoo/oca/rma/&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module extends the functionality of Sales Management to allows you
to set product warranty details on products and product-supplier relation.</p>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
<ul class="simple">
<li><a class="reference internal" href="#usage" id="id1">Usage</a></li>
<li><a class="reference internal" href="#bug-tracker" id="id2">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="id3">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="id4">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="id5">Contributors</a></li>
<li><a class="reference internal" href="#other-credits" id="id6">Other credits</a></li>
<li><a class="reference internal" href="#maintainers" id="id7">Maintainers</a></li>
<li><a class="reference internal" href="#configuration" id="id1">Configuration</a></li>
<li><a class="reference internal" href="#usage" id="id2">Usage</a></li>
<li><a class="reference internal" href="#bug-tracker" id="id3">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="id4">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="id5">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="id6">Contributors</a></li>
<li><a class="reference internal" href="#other-credits" id="id7">Other credits</a></li>
<li><a class="reference internal" href="#maintainers" id="id8">Maintainers</a></li>
</ul>
</li>
</ul>
</div>
<div class="section" id="configuration">
<h1><a class="toc-backref" href="#id1">Configuration</a></h1>
<p>To manage the available return instructions, enable debug mode and go to
<em>Sales -&gt; Configuration -&gt; Product Return Instructions</em>.</p>
</div>
<div class="section" id="usage">
<h1><a class="toc-backref" href="#id1">Usage</a></h1>
<h1><a class="toc-backref" href="#id2">Usage</a></h1>
<p>To use this module, you need to:</p>
<ol class="arabic simple">
<li>Go to <em>Sales &gt; Products &gt; Products (or Product Variants)</em></li>
@@ -397,24 +403,24 @@ edit supplier information lines an set the warranty information for each one.</l
</ol>
</div>
<div class="section" id="bug-tracker">
<h1><a class="toc-backref" href="#id2">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/rma/issues">GitHub Issues</a>.
<h1><a class="toc-backref" href="#id3">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA//opt/odoo/oca/rma//issues">GitHub Issues</a>.
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
<a class="reference external" href="https://github.com/OCA/rma/issues/new?body=module:%20product_warranty%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA//opt/odoo/oca/rma//issues/new?body=module:%20product_warranty%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
<h1><a class="toc-backref" href="#id3">Credits</a></h1>
<h1><a class="toc-backref" href="#id4">Credits</a></h1>
<div class="section" id="authors">
<h2><a class="toc-backref" href="#id4">Authors</a></h2>
<h2><a class="toc-backref" href="#id5">Authors</a></h2>
<ul class="simple">
<li>Akretion</li>
<li>Vauxoo</li>
</ul>
</div>
<div class="section" id="contributors">
<h2><a class="toc-backref" href="#id5">Contributors</a></h2>
<h2><a class="toc-backref" href="#id6">Contributors</a></h2>
<ul class="simple">
<li>Emmanuel Samyn &lt;<a class="reference external" href="mailto:esamyn&#64;gmail.com">esamyn&#64;gmail.com</a>&gt;</li>
<li>Paulius Sladkevičius &lt;<a class="reference external" href="mailto:paulius&#64;inovera.lt">paulius&#64;inovera.lt</a>&gt;</li>
@@ -430,7 +436,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
</ul>
</div>
<div class="section" id="other-credits">
<h2><a class="toc-backref" href="#id6">Other credits</a></h2>
<h2><a class="toc-backref" href="#id7">Other credits</a></h2>
<p>This module has been financially supported by:</p>
<ul class="simple">
<li>Inovera &lt;<a class="reference external" href="https://www.inovera.lt">https://www.inovera.lt</a>&gt;</li>
@@ -444,7 +450,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
</ul>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#id7">Maintainers</a></h2>
<h2><a class="toc-backref" href="#id8">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
@@ -452,7 +458,7 @@ mission is to support the collaborative development of Odoo features and
promote its widespread use.</p>
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainers</a>:</p>
<p><a class="reference external" href="https://github.com/osi-scampbell"><img alt="osi-scampbell" src="https://github.com/osi-scampbell.png?size=40px" /></a> <a class="reference external" href="https://github.com/max3903"><img alt="max3903" src="https://github.com/max3903.png?size=40px" /></a></p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/rma/tree/15.0/product_warranty">OCA/rma</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA//opt/odoo/oca/rma//tree/16.0/product_warranty">OCA//opt/odoo/oca/rma/</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>

View File

@@ -6,11 +6,12 @@ from odoo.tests.common import TransactionCase
class TestProductWarranty(TransactionCase):
def setUp(self):
super(TestProductWarranty, self).setUp()
self.instruction_model = self.env["return.instruction"]
self.supplierinfo = self.env["product.supplierinfo"]
self.create_product_supplierinfo()
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.instruction_model = cls.env["return.instruction"]
cls.supplierinfo = cls.env["product.supplierinfo"]
cls.create_product_supplierinfo(cls)
def create_product_supplierinfo(self):
"""
@@ -23,7 +24,7 @@ class TestProductWarranty(TransactionCase):
other_partner = self.env.ref("base.res_partner_12")
supplierinfo_data = dict(
name=partner_id.id,
partner_id=partner_id.id,
product_name="Test SupplierInfo for display Default Instruction",
min_qty=4,
delay=5,
@@ -59,7 +60,7 @@ class TestProductWarranty(TransactionCase):
self.assertEqual(
self.supplierinfo_brw.warranty_return_address.id,
self.supplierinfo_brw.name.id,
self.supplierinfo_brw.partner_id.id,
)
self.supplierinfo_brw.write({"warranty_return_partner": "company"})

View File

@@ -1,47 +1,5 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<!-- return instructions tree view -->
<record id="product_return_instructions_tree_view" model="ir.ui.view">
<field name="name">product.return.instructions.tree</field>
<field name="model">return.instruction</field>
<field name="arch" type="xml">
<tree>
<field name="name" />
<field name="instructions" />
<field name="is_default" />
</tree>
</field>
</record>
<!-- return instructions form view -->
<record id="product_return_instructions_form_view" model="ir.ui.view">
<field name="name">product.return.instructions.form</field>
<field name="model">return.instruction</field>
<field name="arch" type="xml">
<form string="Return instructions">
<sheet>
<group name="return_instructions" col='4'>
<field name="name" />
<field name="is_default" />
</group>
<separator string="Instructions" colspan="4" />
<field name="instructions" nolabel="1" colspan="4" />
</sheet>
</form>
</field>
</record>
<record id="product_return_instructions_action" model="ir.actions.act_window">
<field name="name">Products Return Instructions</field>
<field name="res_model">return.instruction</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="product_return_instructions_tree_view" />
</record>
<menuitem
action="product_return_instructions_action"
groups="base.group_no_one"
id="menu_product_return_instructions_action"
parent="sale.prod_config_main"
sequence="3"
/>
<!-- supplier info tree view -->
<record id="product_supplierinfo_warranty_tree_view" model="ir.ui.view">
<field name="name">product.supplierinfo.warranty.tree</field>

View File

@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<!-- return instructions tree view -->
<record id="product_return_instructions_tree_view" model="ir.ui.view">
<field name="name">product.return.instructions.tree</field>
<field name="model">return.instruction</field>
<field name="arch" type="xml">
<tree>
<field name="name" />
<field name="instructions" />
<field name="is_default" />
</tree>
</field>
</record>
<!-- return instructions form view -->
<record id="product_return_instructions_form_view" model="ir.ui.view">
<field name="name">product.return.instructions.form</field>
<field name="model">return.instruction</field>
<field name="arch" type="xml">
<form string="Return instructions">
<sheet>
<group name="return_instructions" col='4'>
<field name="name" />
<field name="is_default" />
</group>
<separator string="Instructions" colspan="4" />
<field name="instructions" nolabel="1" colspan="4" />
</sheet>
</form>
</field>
</record>
<record id="product_return_instructions_action" model="ir.actions.act_window">
<field name="name">Products Return Instructions</field>
<field name="res_model">return.instruction</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="product_return_instructions_tree_view" />
</record>
<menuitem
action="product_return_instructions_action"
groups="base.group_no_one"
id="menu_product_return_instructions_action"
parent="sale.prod_config_main"
sequence="3"
/>
</odoo>