Skip to content

Commit

Permalink
Merge 42787aa into 9ab83ff
Browse files Browse the repository at this point in the history
  • Loading branch information
yajo committed Dec 31, 2015
2 parents 9ab83ff + 42787aa commit 01d5fbb
Show file tree
Hide file tree
Showing 15 changed files with 775 additions and 0 deletions.
121 changes: 121 additions & 0 deletions event_product/README.rst
@@ -0,0 +1,121 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3

==============
Event Products
==============

This module extends the functionality of events and products allowing their
combination and the organization of a catalog of events.

Those events in your catalog can have variants, and any event can be linked to
any product as long as:

* The product's *Is an event* checkbox is enabled.
* The product's event type is empty, or matches the event's.

Examples:

* Wedding.
* Variants:
* Up to 50 attendees.
* Up to 100 attendees.
* In beach.
* In countryfield.
* Congress.
* Variants:
* Up to 50 attendees.
* Up to 100 attendees.
* Opening.
* Variants:
* 1 day.
* 2 days.
* 3 days.

Usage
=====

To create your *event products*, you need to:

#. Go to *Sales > Products > Products > Create*.
#. Give it a name, such as *Wedding*.
#. Enable *Is an event*.
#. Choose event type in *Event > Type of Event* (or leave blank for
events of any type).
#. Press *Save*.

To create variants for that, you need to:

#. Edit previous product.
#. Go to *Variants* tab.
#. Press *Add an Item*.
#. Add your attribute and values as usual.

To link an event to any of those variants, you need to:

#. Go to *Marketing > Events > Events > Create*.
#. Set name, start and end dates.
#. Choose the same *Type of Event* as when creating the product (unless you
left it blank, in which case you do not need this).
#. Choose one of your variants in *Product*.

.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/199/8.0

Known issues / Roadmap
======================

* Installing this module will install sale too. If you do not intend to sell
events, but just handle internal ones, this can be annoying since the sale
module requires complex configuration with accounting and external
dependencies.

However, this happens because this module needs the ``event_type_id`` field
in products, which is added by the *event_sale* module, which installs
*sale*; so unless Odoo divides that module in smaller parts with smaller
dependencies, the only workaround is to give permissions to use *sale* to
nobody.
* Support creating a sales order from the event.
* Support creating an event when confirming an event product sales order.

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

Bugs are tracked on `GitHub Issues
<https://github.com/OCA/event/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/
event/issues/new?body=module:%20
event_product%0Aversion:%20
8.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Credits
=======

Images
------

* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_.

Contributors
------------

* Jairo Llopis <yajo.sk8@gmail.com>

Maintainer
----------

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

This module is maintained by the OCA.

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.

To contribute to this module, please visit https://odoo-community.org.
5 changes: 5 additions & 0 deletions event_product/__init__.py
@@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-
# © 2015 Grupo ESOC Ingeniería de Servicios, S.L.U. - Jairo Llopis
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from . import models
22 changes: 22 additions & 0 deletions event_product/__openerp__.py
@@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
# © 2015 Grupo ESOC Ingeniería de Servicios, S.L.U. - Jairo Llopis
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
"name": "Event Products",
"summary": "Combine products and events",
"version": "8.0.1.0.0",
"category": "Event Management",
"website": "https://grupoesoc.es/",
"author": "Grupo ESOC Ingeniería de Servicios, "
"Odoo Community Association (OCA)",
"license": "AGPL-3",
"application": False,
"installable": True,
"depends": [
"event_sale",
],
"data": [
"views/event.xml",
"views/product.xml",
]
}
30 changes: 30 additions & 0 deletions event_product/exceptions.py
@@ -0,0 +1,30 @@
# -*- coding: utf-8 -*-
# © 2015 Grupo ESOC Ingeniería de Servicios, S.L.U. - Jairo Llopis
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from __future__ import unicode_literals
from openerp import _, exceptions


class EventProductValidationError(exceptions.ValidationError):
"""Base class for this module's validation errors."""
def __init__(self, *args, **kwargs):
self._args, self._kwargs = args, kwargs
value = self._message()
super(EventProductValidationError, self).__init__(value)

def _message(self):
"""Format the message."""
return self.__doc__.format(*self._args, **self._kwargs)


class EventAndTicketError(EventProductValidationError):
__doc__ = _("It cannot be an event and a ticket at the same time.")


class ProductIsNotEventError(EventProductValidationError):
__doc__ = _("An event is using product {}, but it is not for events.")


class TypeMismatchError(EventProductValidationError):
__doc__ = _("Product has type {product_type}, but event has {event_type}.")
100 changes: 100 additions & 0 deletions event_product/i18n/es.po
@@ -0,0 +1,100 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * event_product
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 8.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-12-29 13:47+0100\n"
"PO-Revision-Date: 2015-12-29 13:48+0100\n"
"Last-Translator: Jairo Llopis <j.llopis@grupoesoc.es>\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 1.8.5\n"

#. module: event_product
#: code:addons/event_product/exceptions.py:26
#, python-format
msgid "An event is using product {}, but it is not for events."
msgstr ""
"Un evento está usando el producto {}, pero no es para eventos."

#. module: event_product
#: model:ir.model,name:event_product.model_event_event
msgid "Event"
msgstr "Evento"

#. module: event_product
#: view:product.template:event_product.product_template_search
msgid "Event type"
msgstr "Tipo de evento"

#. module: event_product
#: field:product.product,event_ids:0
#: view:product.template:event_product.product_template_search
msgid "Events"
msgstr "Eventos"

#. module: event_product
#: field:event_product.product,id:0
msgid "ID"
msgstr "ID"

#. module: event_product
#: field:product.template,is_event:0
msgid "Is an event"
msgstr "Es un evento"

#. module: event_product
#: code:addons/event_product/exceptions.py:22
#, python-format
msgid "It cannot be an event and a ticket at the same time."
msgstr "No puede ser un evento y un ticket para eventos a la vez."

#. module: event_product
#: view:event.event:event_product.event_event_search
#: field:event.event,product_id:0
#: model:ir.model,name:event_product.model_product_product
msgid "Product"
msgstr "Producto"

#. module: event_product
#: model:ir.model,name:event_product.model_product_template
msgid "Product Template"
msgstr "Plantilla de producto"

#. module: event_product
#: code:addons/event_product/exceptions.py:30
#, python-format
msgid "Product has type {product_type}, but event has {event_type}."
msgstr ""
"El producto es de tipo {product_type}, pero el evento de typo "
"{event_type}."

#. module: event_product
#: help:event.event,product_id:0
msgid "Product of this event, if available."
msgstr "Producto de este evento, si está disponible."

#. module: event_product
#: help:product.template,is_event:0
msgid "This product defines an event (NOT an event ticket)."
msgstr "Este producto define un evento (NO un ticket para eventos)."

#. module: event_product
#: view:product.template:event_product.product_template_form_fields
msgid ""
"{\n"
" \"invisible\": [(\"event_ok\", \"=\", False),\n"
" (\"is_event\", \"=\", False)],\n"
" }"
msgstr ""
"{\n"
" \"invisible\": [(\"event_ok\", \"=\", False),\n"
" (\"is_event\", \"=\", False)],\n"
" }"
5 changes: 5 additions & 0 deletions event_product/models/__init__.py
@@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-
# © 2015 Grupo ESOC Ingeniería de Servicios, S.L.U. - Jairo Llopis
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from . import event, product
41 changes: 41 additions & 0 deletions event_product/models/event.py
@@ -0,0 +1,41 @@
# -*- coding: utf-8 -*-
# © 2015 Grupo ESOC Ingeniería de Servicios, S.L.U. - Jairo Llopis
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from openerp import api, fields, models
from .. import exceptions as ex


class EventEvent(models.Model):
_inherit = "event.event"

product_id = fields.Many2one(
"product.product",
"Product",
domain="""[("is_event", "=", True),
("event_type_id", "in", (False, type))]""",
states={"done": [("readonly", True)]},
help="Product of this event, if available.")

@api.multi
@api.constrains("type", "product_id")
def _check_product_type(self):
"""Ensure product and event types match."""
for s in self.filtered("product_id"):
if not s.product_id.is_event:
raise ex.ProductIsNotEventError(s.product_id.display_name)
elif (s.product_id.event_type_id and
s.product_id.event_type_id != s.type):
raise ex.TypeMismatchError(
product_type=s.product_id.event_type_id.display_name,
event_type=s.type.display_name)

@api.multi
@api.onchange("type")
def _onchange_type_clear_product(self):
"""Better have no product than have a wrong one."""
for s in self:
try:
s._check_product_type()
except ex.TypeMismatchError:
s.product_id = False

0 comments on commit 01d5fbb

Please sign in to comment.