Skip to content

Commit

Permalink
Merge commit 'refs/pull/172/head' of https://github.com/ForgeFlow/sto…
Browse files Browse the repository at this point in the history
…ck-rma into fko/14.0.1.0.0
  • Loading branch information
max3903 committed Sep 9, 2021
2 parents fc144d0 + e55c7d0 commit 71d156f
Show file tree
Hide file tree
Showing 9 changed files with 145 additions and 0 deletions.
47 changes: 47 additions & 0 deletions rma_website_delivery/README.rst
@@ -0,0 +1,47 @@
====================
RMA Website Delivery
====================

.. image:: https://img.shields.io/badge/licence-LGPL--3-blue.svg
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3

This module allows you to provide the shipping label to your customer to return
products.

**Table of contents**

.. contents::
:local:

Usage
=====

* Go to RMA
* Create or select a record
* Create the incoming shipment for the return
* Open the receipt and click on "Get Return Label"
* The label will be attached to the RMA order and to the email sent to the customer.

Credits
=======

Authors
~~~~~~~

* Open Source Integrators <contact@opensourceintegrators.com>

Contributors
~~~~~~~~~~~~

* Ammar Officewala <aofficewala@opensourceintegrators.com>
* Melody Fetterly <mfetterly@opensourceintegrators.com>
* Raphael Lee <rlee@opensourceintegrators.com>
* Maxime Chambreuil <mchambreuil@opensourceintegrators.com>

Maintainers
~~~~~~~~~~~

This module is maintained by ForgeFlow.

This module is part of the `ForgeFlow/stock-rma <https://github.com/ForgeFlow/stock-rma>`_ project on GitHub.
3 changes: 3 additions & 0 deletions rma_website_delivery/__init__.py
@@ -0,0 +1,3 @@
# Copyright (C) 2021 Open Source Integrators
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
from . import models
17 changes: 17 additions & 0 deletions rma_website_delivery/__manifest__.py
@@ -0,0 +1,17 @@
# Copyright (C) 2021 Open Source Integrators
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
{
"name": "RMA Website Delivery",
"version": "14.0.1.0.0",
"license": "LGPL-3",
"summary": "Provide the return label to your customers",
"author": "Open Source Integrators",
"maintainer": "ForgeFlow",
"website": "https://github.com/ForgeFlow/stock-rma",
"depends": ["rma_website", "delivery"],
"data": [
"data/mail_template.xml",
"views/stock_picking_view.xml",
],
"maintainers": ["ursais"],
}
19 changes: 19 additions & 0 deletions rma_website_delivery/data/mail_template.xml
@@ -0,0 +1,19 @@
<odoo>

<record id="rma_return_label_mail" model="mail.template">
<field name="name">Return Label</field>
<field name="email_from">${(user.partner_id.email or '')|safe}</field>
<field name="subject">Return Label</field>
<field name="email_to">${(object.partner_id.email or '')|safe}</field>
<field name="model_id" ref="rma.model_rma_order" />
<field
name="body_html"
><![CDATA[
<p>Hello ${object.partner_id.name},</p>
<p>Please find attached the shipping label to return your products.</p>
<p>Thank you,</p>
]]>
</field>
</record>

</odoo>
3 changes: 3 additions & 0 deletions rma_website_delivery/models/__init__.py
@@ -0,0 +1,3 @@
# Copyright (C) 2021 Open Source Integrators
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
from . import stock_picking
30 changes: 30 additions & 0 deletions rma_website_delivery/models/stock_picking.py
@@ -0,0 +1,30 @@
# Copyright (C) 2021 Open Source Integrators
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
from odoo import _, models
from odoo.exceptions import UserError


class StockPicking(models.Model):
_inherit = "stock.picking"

def get_return_label(self):
for rec in self:
if not rec.carrier_id:
raise UserError(_("You need to assign the carrier."))
else:
rma_order_line_id = self.env["rma.order.line"].search(
[("name", "=", rec.origin)]
)
if rma_order_line_id and rma_order_line_id.rma_id:
data, labels = rec.carrier_id.get_return_label(self)
rec.carrier_tracking_ref = data["tracking_number"]
mail_template = self.env.ref(
"rma_website_delivery.rma_return_label_mail"
)
attach_id = self.env["ir.attachment"].search(
[("name", "=", labels[0][0])], limit=1
)
mail_template.write({"attachment_ids": [(6, 0, attach_id.ids)]})
mail_template.send_mail(
rma_order_line_id.rma_id.id, force_send=True
)
19 changes: 19 additions & 0 deletions rma_website_delivery/views/stock_picking_view.xml
@@ -0,0 +1,19 @@
<odoo>

<record id="view_picking_form_inherit_rma_delivery" model="ir.ui.view">
<field name="name">stock.picking.form</field>
<field name="model">stock.picking</field>
<field name="inherit_id" ref="stock.view_picking_form" />
<field name="arch" type="xml">
<xpath expr="//header/button[@name='action_cancel']" position="after">
<button
name="get_return_label"
string="Get Return Label"
type="object"
attrs="{'invisible': [('picking_type_id', '!=', %(rma.picking_type_rma_cust_in)d), ('carrier_id','=',False)]}"
/>
</xpath>
</field>
</record>

</odoo>
6 changes: 6 additions & 0 deletions setup/rma_website_delivery/setup.py
@@ -0,0 +1,6 @@
import setuptools

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

0 comments on commit 71d156f

Please sign in to comment.