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

[17.0][MIG] rma: Migration to 17.0 #385

Merged
merged 98 commits into from
May 15, 2024
Merged
Changes from 1 commit
Commits
Show all changes
98 commits
Select commit Hold shift + click to select a range
7d71958
[ADD] rma: new module
May 13, 2020
9aebb3a
Added translation using Weblate (Portuguese (Brazil))
fcolus Jul 22, 2020
c120bcb
[FIX+IMP] rma: view permissions + portal views access errors + teams …
chienandalu Aug 14, 2020
873d2d2
[FIX+IMP] rma, rma_sale: fix bugs and add improvements
Aug 19, 2020
ec05c53
Translated using Weblate (Spanish)
pedrobaeza Aug 22, 2020
1945ee0
[FIX] rma: permissions for general users
chienandalu Aug 24, 2020
665ab61
[IMP] rma: Return created sequence on create_rma_index
pedrobaeza Aug 22, 2020
9794aa4
[IMP] rma_sale: portal improvents
chienandalu Aug 28, 2020
dd7b6c4
[FIX] rma: Perform refund with proper view
pedrobaeza Sep 14, 2020
8f2351e
[IMP] rma: set rma to received on invoice delete + incoming picking t…
Sep 15, 2020
5c848ba
[FIX+IMP] rma: usability + Translated using Weblate (Spanish) + 5 thi…
chienandalu Sep 30, 2020
e6b8d70
[IMP] rma: black, isort, prettier
Oct 23, 2020
fa16030
[MIG] rma: Migration to 13.0
Oct 23, 2020
1704000
[IMP] rma: Add customer as suggested recipient
Dec 1, 2020
c509c80
Added translation using Weblate (Romanian)
dhongu Dec 11, 2020
f336ff1
Added translation using Weblate (Dutch)
bosd Dec 13, 2020
8ec5697
Added translation using Weblate (Chinese (Simplified))
dong-z Mar 21, 2021
98bb76a
Translated using Weblate (Chinese (Simplified))
dong-z Mar 21, 2021
28a9698
[IMP] rma: auto send confirmation email
chienandalu Feb 9, 2021
2a3d713
[IMP] rma_sale: prepare kits integration
chienandalu Nov 16, 2020
9b4a97e
[IMP] rma: automatic notification subtypes
chienandalu Mar 1, 2021
b29da85
[IMP] rma, rma_sale: shipping address
chienandalu Nov 6, 2020
3dba347
[FIX] rma: Set default source location for RMA created from scratch
Mar 4, 2021
ed5f42a
[FIX] rma: tagged test
chienandalu May 5, 2021
d87d582
[IMP] rma: tags
chienandalu May 6, 2021
32b569e
[IMP] rma: black, isort, prettier
chafique-delli Jun 6, 2021
6f3884c
[MIG] rma: Migration to 14.0
chafique-delli Dec 4, 2020
213c7ff
[IMP] rma: notify reception to customer
chienandalu May 19, 2021
c7be8f2
[IMP] rma: public tags
chienandalu May 25, 2021
e65f843
[IMP] rma: allow to archive operation types
chienandalu Jul 14, 2021
bd78691
Remove useless archive/unarchive button on form views
florian-dacosta Jul 29, 2021
cb83ae6
[FIX] rma: Propagate cancel_backorder argument
pedrobaeza Sep 19, 2021
34f96d1
[FIX] rma: default team and responsible
chienandalu Sep 23, 2021
cb71872
[FIX] rma: Use Form to avoid UoM change invalid check
pedrobaeza Sep 6, 2021
6ffa4fb
[FIX] rma: return location
chienandalu Sep 23, 2021
6161bf1
Added translation using Weblate (Portuguese)
pedrocs-exo Oct 28, 2021
f977197
Translated using Weblate (Portuguese)
pedrocs-exo Oct 28, 2021
b47ecd5
Added translation using Weblate (Italian)
francesco-ooops Nov 23, 2021
12a2bea
[FIX] multi company error on rma location choice
florian-dacosta Dec 1, 2021
29daa19
Translated using Weblate (Italian)
SicurSam Dec 3, 2021
1bd0589
Translated using Weblate (Italian)
francesco-ooops Dec 10, 2021
3ed7941
[FIX] duplicate labels (category_id, uom_category_id) of rma())
Kev-Roche Jan 16, 2022
573bf80
Translated using Weblate (Spanish)
xavigutipujol Jan 17, 2022
5496c03
[FIX] rma: return wizard to_refund
chienandalu Jan 17, 2022
3f4fc37
[FIX] rma: Adjust hook for existing values
pedrobaeza Dec 18, 2021
48e46f1
[IMP] rma report: invoice and shipping address
chienandalu Jan 21, 2022
df24c1f
[IMP] rma: unplug test cases from declaration
chienandalu Jan 25, 2022
6748c73
[IMP] rma: finish RMA manually
chienandalu Jan 28, 2022
5d89fa4
[FIX] Do not link reception and delivery move in case of RMA replacement
florian-dacosta Feb 7, 2022
82e319a
[FIX] rma: name column width in tree view
chienandalu Mar 15, 2022
a547e6e
Translated using Weblate (Italian)
francesco-ooops Mar 23, 2022
d8411af
Translated using Weblate (Italian)
SicurSam Mar 31, 2022
6ced59a
[IMP] update dotfiles [ci skip]
OCA-git-bot Mar 31, 2022
e9a7977
[14.0][FIX] rma_sale, fix action permission issues.
GSLabIt Apr 26, 2022
c75724d
[14.0][FIX] rma, fix permission for action
GSLabIt Apr 26, 2022
dc15dfb
[FIX] rma: Allow manual finalization in wizard.
victoralmau May 4, 2022
dada912
Translated using Weblate (Italian)
francesco-ooops May 18, 2022
b7ceaf8
[FIX] rma: refund permissions
chienandalu Feb 17, 2022
095aef8
[IMP] rma: optionally group returns to customer
chienandalu Mar 7, 2022
805178f
[FIX] rma: Avoid set invoice_payment_term_id from partner default val…
victoralmau Jun 22, 2022
0f99685
Update translation files
oca-transbot Jun 29, 2022
18159b3
[FIX] rma + rma_sale: Allow to create an RMA to a user with access_to…
victoralmau May 16, 2022
9ede170
[MIG] rma: Migration to 15.0
Aug 10, 2022
b908d0c
[OU-ADD] rma: Add migration script.
victoralmau Aug 19, 2022
45327ae
[IMP] rma: Use _prepare_home_portal_values() function.
victoralmau Sep 2, 2022
9af30f4
Added translation using Weblate (German)
Sep 26, 2022
3c59c21
[FIX] rma: multiple substitution moves
chienandalu Oct 26, 2022
37909c0
Translated using Weblate (Italian)
primes2h Dec 1, 2022
6079b53
[FIX] rma: avoid reopening a cancelled RMA when the reception is deleted
chienandalu Mar 9, 2023
ffcbf65
Translated using Weblate (German)
Apr 5, 2023
2474ba4
[FIX] rma: avoid refunding in picking return wizard
chienandalu Mar 21, 2023
89870bd
Translated using Weblate (Italian)
francesco-ooops Dec 29, 2022
87bedb4
Translated using Weblate (Italian)
mymage Dec 20, 2022
e0ffe30
Translated using Weblate (Spanish)
CarlosRoca13 Aug 11, 2023
9b1ef38
[MIG] rma: Migration to 16.0
pedrobaeza Aug 24, 2023
fff0052
[UPD] Update rma.pot
Aug 28, 2023
d186edb
[UPD] README.rst
OCA-git-bot Aug 28, 2023
0e30933
[UPD] README.rst
OCA-git-bot Sep 3, 2023
41e7022
Update translation files
weblate Sep 3, 2023
6cb2058
Translated using Weblate (Italian)
mymage Sep 4, 2023
6dae585
[FIX] rma: _get_sequence_values signature
chienandalu Sep 6, 2023
6885aa0
Translated using Weblate (Spanish)
Ivorra78 Sep 7, 2023
62c8154
Added translation using Weblate (French)
Sep 12, 2023
c94ff4b
Translated using Weblate (Spanish)
Ivorra78 Sep 20, 2023
0bc590c
Update translation files
weblate Oct 10, 2023
0596493
[FIX] rma: `image_128` -> `avatar_128`
MiquelRForgeFlow Oct 10, 2023
2bbebcf
[BOT] post-merge updates
OCA-git-bot Oct 10, 2023
5feb604
Translated using Weblate (Italian)
mymage Oct 11, 2023
21f3bbd
Translated using Weblate (Italian)
francesco-ooops Oct 17, 2023
1bce43b
Translated using Weblate (Italian)
mymage Oct 31, 2023
e949a4e
Translated using Weblate (French)
kbentaleb Jan 4, 2024
edc5145
Translated using Weblate (Italian)
mymage Jan 22, 2024
8f8d62c
[FIX] rma: unresolved and late filters
chienandalu Jan 30, 2024
f2e9657
[IMP] rma: mantainers
chienandalu Jan 30, 2024
1286c1f
[BOT] post-merge updates
OCA-git-bot Jan 30, 2024
c810090
Translated using Weblate (Italian)
mymage Mar 1, 2024
c22fa4e
[IMP] rma: pre-commit auto fixes
peluko00 May 3, 2024
9cc5bca
[MIG] rma: Migration to 17.0
peluko00 May 8, 2024
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
Prev Previous commit
Next Next commit
[IMP] rma: notify reception to customer
Now we can configure if an automatic notification should be sent when we
receive the goods from an RMA in our warehouse

If we've got `rma_sale` or `website_rma` we can also configure draft
notifications so when the customer places an RMA from the portal the
receive an acknowledge email.

TT29595
chienandalu authored and peluko00 committed May 3, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 213c7ff900681f6bfbc9e9bdc3ce4321de72ce87
60 changes: 59 additions & 1 deletion rma/data/mail_data.xml
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@
<field name="description">RMA in draft state</field>
</record>
<record id="mt_rma_notification" model="mail.message.subtype">
<field name="name">RMA Notificatoin</field>
<field name="name">RMA Notification</field>
<field name="res_model">rma</field>
<field name="default" eval="False" />
<field name="description">RMA automatic customer notifications</field>
@@ -58,4 +58,62 @@
</div>
</field>
</record>
<!--RMA receipt confirmation email template -->
<record id="mail_template_rma_receipt_notification" model="mail.template">
<field name="name">RMA Receipt Notification</field>
<field name="model_id" ref="model_rma" />
<field name="email_from">${object.user_id.email_formatted |safe}</field>
<field name="partner_to">${object.partner_id.id}</field>
<field
name="subject"
>${object.company_id.name} RMA (Ref ${object.name or 'n/a' }) products received</field>
<field name="report_template" ref="report_rma_action" />
<field name="report_name">${(object.name or '')}</field>
<field name="lang">${object.partner_id.lang}</field>
<field name="auto_delete" eval="True" />
<field name="body_html" type="html">
<div style="margin: 0px; padding: 0px;">
<p style="margin: 0px; padding: 0px; font-size: 13px;">
Dear ${object.partner_id.name}
% if object.partner_id.parent_id:
(${object.partner_id.parent_id.name})
% endif
<br /><br />
The products for your RMA <strong>${object.name}</strong>
from ${object.company_id.name} have been received in our warehouse.
<br /><br />
Do not hesitate to contact us if you have any question.
</p>
</div>
</field>
</record>
<record id="mail_template_rma_draft_notification" model="mail.template">
<field name="name">RMA Draft Notification</field>
<field name="model_id" ref="model_rma" />
<field name="email_from">${object.user_id.email_formatted |safe}</field>
<field name="partner_to">${object.partner_id.id}</field>
<field
name="subject"
>${object.company_id.name} Your RMA has been succesfully created (Ref ${object.name or 'n/a' })</field>
<field name="report_template" ref="report_rma_action" />
<field name="report_name">${(object.name or '')}</field>
<field name="lang">${object.partner_id.lang}</field>
<field name="auto_delete" eval="True" />
<field name="body_html" type="html">
<div style="margin: 0px; padding: 0px;">
<p style="margin: 0px; padding: 0px; font-size: 13px;">
Dear ${object.partner_id.name}
% if object.partner_id.parent_id:
(${object.partner_id.parent_id.name})
% endif
<br /><br />
You've succesfully placed your RMA <strong>${object.name}</strong>
on ${object.company_id.name}. Our team will check it and will validate
it as soon as possible.
<br /><br />
Do not hesitate to contact us if you have any question.
</p>
</div>
</field>
</record>
</data>
35 changes: 35 additions & 0 deletions rma/models/res_company.py
Original file line number Diff line number Diff line change
@@ -13,18 +13,53 @@ def _default_rma_mail_confirmation_template(self):
except ValueError:
return False

def _default_rma_mail_receipt_template(self):
try:
return self.env.ref("rma.mail_template_rma_receipt_notification").id
except ValueError:
return False

def _default_rma_mail_draft_template(self):
try:
return self.env.ref("rma.mail_template_rma_draft_notification").id
except ValueError:
return False

send_rma_confirmation = fields.Boolean(
string="Send RMA Confirmation",
help="When the delivery is confirmed, send a confirmation email "
"to the customer.",
)
send_rma_receipt_confirmation = fields.Boolean(
string="Send RMA Receipt Confirmation",
help="When the RMA receipt is confirmed, send a confirmation email "
"to the customer.",
)
send_rma_draft_confirmation = fields.Boolean(
string="Send RMA draft Confirmation",
help="When a customer places an RMA, send a notification with it",
)
rma_mail_confirmation_template_id = fields.Many2one(
comodel_name="mail.template",
string="Email Template confirmation for RMA",
domain="[('model', '=', 'rma')]",
default=_default_rma_mail_confirmation_template,
help="Email sent to the customer once the RMA is confirmed.",
)
rma_mail_receipt_confirmation_template_id = fields.Many2one(
comodel_name="mail.template",
string="Email Template receipt confirmation for RMA",
domain="[('model', '=', 'rma')]",
default=_default_rma_mail_receipt_template,
help="Email sent to the customer once the RMA products are received.",
)
rma_mail_draft_confirmation_template_id = fields.Many2one(
comodel_name="mail.template",
string="Email Template draft notification for RMA",
domain="[('model', '=', 'rma')]",
default=_default_rma_mail_draft_template,
help="Email sent to the customer when they place " "an RMA from the portal",
)

@api.model
def create(self, vals):
16 changes: 16 additions & 0 deletions rma/models/res_config_settings.py
Original file line number Diff line number Diff line change
@@ -14,3 +14,19 @@ class ResConfigSettings(models.TransientModel):
related="company_id.rma_mail_confirmation_template_id",
readonly=False,
)
send_rma_receipt_confirmation = fields.Boolean(
related="company_id.send_rma_receipt_confirmation",
readonly=False,
)
rma_mail_receipt_confirmation_template_id = fields.Many2one(
related="company_id.rma_mail_receipt_confirmation_template_id",
readonly=False,
)
send_rma_draft_confirmation = fields.Boolean(
related="company_id.send_rma_draft_confirmation",
readonly=False,
)
rma_mail_draft_confirmation_template_id = fields.Many2one(
related="company_id.rma_mail_draft_confirmation_template_id",
readonly=False,
)
40 changes: 39 additions & 1 deletion rma/models/rma.py
Original file line number Diff line number Diff line change
@@ -511,7 +511,13 @@ def create(self, vals_list):
# Assign a default team_id which will be the first in the sequence
if "team_id" not in vals:
vals["team_id"] = self.env["rma.team"].search([], limit=1).id
return super().create(vals_list)
rmas = super().create(vals_list)
# Send acknowledge when the RMA is created from the portal and the
# company has the proper setting active. This context is set by the
# `rma_sale` module.
if self.env.context.get("from_portal"):
rmas._send_draft_email()
return rmas

def copy(self, default=None):
team = super().copy(default)
@@ -529,6 +535,16 @@ def unlink(self):
)
return super().unlink()

def _send_draft_email(self):
"""Send customer notifications they place the RMA from the portal"""
for rma in self.filtered("company_id.send_rma_draft_confirmation"):
rma_template_id = rma.company_id.rma_mail_draft_confirmation_template_id.id
rma.with_context(
force_send=True,
mark_rma_as_sent=True,
default_subtype_id=self.env.ref("rma.mt_rma_notification").id,
).message_post_with_template(rma_template_id)

def _send_confirmation_email(self):
"""Auto send notifications"""
for rma in self.filtered(lambda p: p.company_id.send_rma_confirmation):
@@ -539,6 +555,18 @@ def _send_confirmation_email(self):
default_subtype_id=self.env.ref("rma.mt_rma_notification").id,
).message_post_with_template(rma_template_id)

def _send_receipt_confirmation_email(self):
"""Send customer notifications when the products are received"""
for rma in self.filtered("company_id.send_rma_receipt_confirmation"):
rma_template_id = (
rma.company_id.rma_mail_receipt_confirmation_template_id.id
)
rma.with_context(
force_send=True,
mark_rma_as_sent=True,
default_subtype_id=self.env.ref("rma.mt_rma_notification").id,
).message_post_with_template(rma_template_id)

# Action methods
def action_rma_send(self):
self.ensure_one()
@@ -1260,6 +1288,16 @@ def _get_report_base_filename(self):
return "RMA Report - %s" % self.name

# Other business methods

def update_received_state_on_reception(self):
"""Invoked by:
[stock.move]._action_done
Here we can attach methods to trigger when the customer products
are received on the RMA location, such as automatic notifications
"""
self.write({"state": "received"})
self._send_receipt_confirmation_email()

def update_received_state(self):
"""Invoked by:
[stock.move].unlink
2 changes: 1 addition & 1 deletion rma/models/stock_move.py
Original file line number Diff line number Diff line change
@@ -75,7 +75,7 @@ def _action_done(self, cancel_backorder=False):
.mapped("rma_receiver_ids")
.filtered(lambda r: r.state == "confirmed")
)
to_be_received.write({"state": "received"})
to_be_received.update_received_state_on_reception()
# Set RMAs as delivered
move_done.mapped("rma_id").update_replaced_state()
move_done.mapped("rma_id").update_returned_state()
47 changes: 39 additions & 8 deletions rma/tests/test_rma.py
Original file line number Diff line number Diff line change
@@ -676,19 +676,50 @@ def test_quantities_on_hand(self):
self.assertEqual(rma.product_id.qty_available, 0)

def test_autoconfirm_email(self):
rma = self._create_rma(self.partner, self.product, 10, self.rma_loc)
rma.company_id.send_rma_confirmation = True
rma.company_id.rma_mail_confirmation_template_id = self.env.ref(
self.company.send_rma_confirmation = True
self.company.send_rma_receipt_confirmation = True
self.company.send_rma_draft_confirmation = True
self.company.rma_mail_confirmation_template_id = self.env.ref(
"rma.mail_template_rma_notification"
)
self.company.rma_mail_receipt_confirmation_template_id = self.env.ref(
"rma.mail_template_rma_receipt_notification"
)
self.company.rma_mail_draft_confirmation_template_id = self.env.ref(
"rma.mail_template_rma_draft_notification"
)
previous_mails = self.env["mail.mail"].search(
[("partner_ids", "in", self.partner.ids)]
)
self.assertFalse(previous_mails)
rma.action_confirm()
mail = self.env["mail.message"].search(
# Force the context to mock an RMA created from the portal, which is
# feature that we get on `rma_sale`. We drop it after the RMA creation
# to avoid uncontrolled side effects
ctx = self.env.context
self.env.context = dict(ctx, from_portal=True)
rma = self._create_rma(self.partner, self.product, 10, self.rma_loc)
self.env.context = ctx
mail_draft = self.env["mail.message"].search(
[("partner_ids", "in", self.partner.ids)]
)
self.assertTrue(rma.name in mail.subject)
self.assertTrue(rma.name in mail.body)
self.assertEqual(self.env.ref("rma.mt_rma_notification"), mail.subtype_id)
rma.action_confirm()
mail_confirm = (
self.env["mail.message"].search([("partner_ids", "in", self.partner.ids)])
- mail_draft
)
self.assertTrue(rma.name in mail_confirm.subject)
self.assertTrue(rma.name in mail_confirm.body)
self.assertEqual(
self.env.ref("rma.mt_rma_notification"), mail_confirm.subtype_id
)
# Now we'll confirm the incoming goods picking and the automatic
# reception notification should be sent
rma.reception_move_id.quantity_done = rma.product_uom_qty
rma.reception_move_id.picking_id.button_validate()
mail_receipt = (
self.env["mail.message"].search([("partner_ids", "in", self.partner.ids)])
- mail_draft
- mail_confirm
)
self.assertTrue(rma.name in mail_receipt.subject)
self.assertTrue("products received" in mail_receipt.subject)
76 changes: 76 additions & 0 deletions rma/views/res_config_settings_views.xml
Original file line number Diff line number Diff line change
@@ -46,6 +46,82 @@
</div>
</div>
</div>
<div
class="col-12 col-lg-6 o_setting_box"
title="Send automatic RMA products reception notification to customer"
>
<div class="o_setting_left_pane">
<field name="send_rma_receipt_confirmation" />
</div>
<div class="o_setting_right_pane">
<label
for="send_rma_receipt_confirmation"
string="RMA Receipt Confirmation Email"
/>
<span
class="fa fa-lg fa-building-o"
title="Values set here are company-specific."
groups="base.group_multi_company"
/>
<div class="text-muted">
When the RMA products are received, send an automatic information email.
</div>
<div
class="row mt16"
attrs="{'invisible': [('send_rma_receipt_confirmation', '=', False)]}"
>
<label
for="rma_mail_receipt_confirmation_template_id"
string="Email Template"
class="col-lg-4 o_light_label"
/>
<field
name="rma_mail_receipt_confirmation_template_id"
class="oe_inline"
attrs="{'required': [('send_rma_receipt_confirmation', '=', True)]}"
context="{'default_model': 'rma'}"
/>
</div>
</div>
</div>
<div
class="col-12 col-lg-6 o_setting_box"
title="Send automatic notification when the customer places an RMA"
>
<div class="o_setting_left_pane">
<field name="send_rma_draft_confirmation" />
</div>
<div class="o_setting_right_pane">
<label
for="send_rma_draft_confirmation"
string="RMA draft notification Email"
/>
<span
class="fa fa-lg fa-building-o"
title="Values set here are company-specific."
groups="base.group_multi_company"
/>
<div class="text-muted">
When customers themselves place an RMA from the portal, send an automatic notification acknowleging it.
</div>
<div
class="row mt16"
attrs="{'invisible': [('send_rma_draft_confirmation', '=', False)]}"
>
<label
for="rma_mail_draft_confirmation_template_id"
string="Email Template"
class="col-lg-4 o_light_label"
/>
<field
name="rma_mail_draft_confirmation_template_id"
class="oe_inline"
attrs="{'required': [('send_rma_draft_confirmation', '=', True)]}"
context="{'default_model': 'rma'}"
/>
</div>
</div>
</div>
</xpath>
</field>
</record>