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

[15.0][MIG] sale_coupon_mass_mailing: Migration to version 15.0 #93

Merged
merged 4 commits into from
Jan 13, 2023
Merged
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
78 changes: 78 additions & 0 deletions coupon_mass_mailing/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
=======================
Sale Coupon Mas Mailing
=======================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |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%2Fsale--promotion-lightgray.png?logo=github
:target: https://github.com/OCA/sale-promotion/tree/15.0/coupon_mass_mailing
:alt: OCA/sale-promotion
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/sale-promotion-15-0/sale-promotion-15-0-coupon_mass_mailing
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/webui/builds.html?repo=OCA/sale-promotion&target_branch=15.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This addon adds a smart-button in promotions called "Mailings" that allows you to link mass-mailing.
In the case that there is no mass-mailing created yet, when clicking the smart-button, one will be created with the contact domain previously defined in the promotion, otherwise, the existing mailings will be listed.

**Table of contents**

.. contents::
:local:

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/sale-promotion/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/sale-promotion/issues/new?body=module:%20coupon_mass_mailing%0Aversion:%2015.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.

Credits
=======

Authors
~~~~~~~

* Tecnativa

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

* `Tecnativa <https://www.tecnativa.com>`_:

* Víctor Martínez
* Pedro M. Baeza
* Pilar Vargas

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

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

This module is part of the `OCA/sale-promotion <https://github.com/OCA/sale-promotion/tree/15.0/coupon_mass_mailing>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions coupon_mass_mailing/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
14 changes: 14 additions & 0 deletions coupon_mass_mailing/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright 2021 Tecnativa - Víctor Martínez
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
"name": "Coupon Mas Mailing",
"version": "15.0.1.0.0",
"author": "Tecnativa, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/sale-promotion",
"license": "AGPL-3",
"category": "Marketing",
"depends": ["sale_coupon", "mass_mailing"],
"data": ["views/mailing_mailing_view.xml", "views/sale_coupon_program_view.xml"],
"installable": True,
}
40 changes: 40 additions & 0 deletions coupon_mass_mailing/i18n/coupon_mass_mailing.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * coupon_mass_mailing
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 13.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: coupon_mass_mailing
#: model:ir.model.fields,field_description:coupon_mass_mailing.field_sale_coupon_program__mailing_count
msgid "Mailing count"
msgstr ""

#. module: coupon_mass_mailing
#: model:ir.model.fields,field_description:coupon_mass_mailing.field_sale_coupon_program__mailing_ids
#: model_terms:ir.ui.view,arch_db:coupon_mass_mailing.sale_coupon_program_view_form_common_custom
msgid "Mailings"
msgstr ""

#. module: coupon_mass_mailing
#: model:ir.model,name:coupon_mass_mailing.model_mailing_mailing
msgid "Mass Mailing"
msgstr ""

#. module: coupon_mass_mailing
#: model:ir.model.fields,field_description:coupon_mass_mailing.field_mailing_mailing__program_id
msgid "Program"
msgstr ""

#. module: coupon_mass_mailing
#: model:ir.model,name:coupon_mass_mailing.model_sale_coupon_program
msgid "Sales Coupon Program"
msgstr ""
44 changes: 44 additions & 0 deletions coupon_mass_mailing/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * coupon_mass_mailing
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 13.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-07-15 14:10+0000\n"
"PO-Revision-Date: 2021-07-15 16:13+0200\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: \n"
"X-Generator: Poedit 2.3\n"

#. module: coupon_mass_mailing
#: model:ir.model.fields,field_description:coupon_mass_mailing.field_sale_coupon_program__mailing_count
msgid "Mailing count"
msgstr "Total comunicaciones"

#. module: coupon_mass_mailing
#: model:ir.model.fields,field_description:coupon_mass_mailing.field_sale_coupon_program__mailing_ids
#: model_terms:ir.ui.view,arch_db:coupon_mass_mailing.sale_coupon_program_view_form_common_custom
msgid "Mailings"
msgstr "Comunicaciones"

#. module: coupon_mass_mailing
#: model:ir.model,name:coupon_mass_mailing.model_mailing_mailing
msgid "Mass Mailing"
msgstr "Correo masivo"

#. module: coupon_mass_mailing
#: model:ir.model.fields,field_description:coupon_mass_mailing.field_mailing_mailing__program_id
msgid "Program"
msgstr "Programa"

#. module: coupon_mass_mailing
#: model:ir.model,name:coupon_mass_mailing.model_sale_coupon_program
msgid "Sales Coupon Program"
msgstr "Programa de cupones de ventas"
2 changes: 2 additions & 0 deletions coupon_mass_mailing/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import mailing_mailing
from . import sale_coupon_program
17 changes: 17 additions & 0 deletions coupon_mass_mailing/models/mailing_mailing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright 2021 Tecnativa - Víctor Martínez
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import api, fields, models


class MailingMailing(models.Model):
_inherit = "mailing.mailing"

program_id = fields.Many2one(
comodel_name="coupon.program", string="Program", ondelete="cascade"
)

@api.onchange("program_id")
def onchange_program_id(self):
if self.program_id:
self.mailing_domain = self.program_id.rule_partners_domain
56 changes: 56 additions & 0 deletions coupon_mass_mailing/models/sale_coupon_program.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Copyright 2021 Tecnativa - Víctor Martínez
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import api, fields, models


class SaleCouponProgram(models.Model):
_inherit = "coupon.program"

mailing_ids = fields.One2many(
comodel_name="mailing.mailing",
inverse_name="program_id",
string="Mailings",
copy=False,
)
mailing_count = fields.Integer(
compute="_compute_mailing_count", string="Mailing count"
)

@api.depends("mailing_ids")
def _compute_mailing_count(self):
mailing_data = self.env["mailing.mailing"].read_group(
[("program_id", "in", self.ids)], ["program_id"], ["program_id"]
)
mapped_data = {m["program_id"][0]: m["program_id_count"] for m in mailing_data}
for program in self:
program.mailing_count = mapped_data.get(program.id, 0)

def action_mailing_count(self):
self.ensure_one()
xmlid = "mass_mailing.mailing_mailing_action_mail"
model = self.env["ir.model"].search([("model", "=", "res.partner")])
if not self.mailing_count:
mailing = self.env["mailing.mailing"].create(
{
"program_id": self.id,
"mailing_model_id": model.id,
"subject": self.name,
"mailing_domain": self.rule_partners_domain,
}
)
result = self.env["ir.actions.act_window"]._for_xml_id(xmlid)
result["res_id"] = mailing.id
res = self.env.ref("mass_mailing.view_mail_mass_mailing_form", False)
result["views"] = [(res and res.id or False, "form")]
else:
result = self.env["ir.actions.act_window"]._for_xml_id(xmlid)
result["domain"] = [("id", "in", self.mailing_ids.ids)]
# Set context and add defaults
result["context"] = dict(self.env.context)
result["context"]["default_mailing_model_id"] = model.id
result["context"]["default_program_id"] = self.id
result["context"]["default_subject"] = self.name
if self.rule_partners_domain:
result["context"]["default_mailing_domain"] = self.rule_partners_domain
return result
5 changes: 5 additions & 0 deletions coupon_mass_mailing/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
* `Tecnativa <https://www.tecnativa.com>`_:

* Víctor Martínez
* Pedro M. Baeza
* Pilar Vargas
2 changes: 2 additions & 0 deletions coupon_mass_mailing/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This addon adds a smart-button in promotions called "Mailings" that allows you to link mass-mailing.
In the case that there is no mass-mailing created yet, when clicking the smart-button, one will be created with the contact domain previously defined in the promotion, otherwise, the existing mailings will be listed.
Binary file added coupon_mass_mailing/static/description/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading