Browse Source

[WIP]

envent_question_sale
RemiFr82 3 weeks ago
parent
commit
40c8314dea
  1. 1
      event_question_sale/controllers/__init__.py
  2. 58
      event_question_sale/controllers/main.py
  3. 1
      event_question_sale_renting/__init__.py
  4. 41
      event_question_sale_renting/__manifest__.py
  5. 1
      event_question_sale_renting/controllers/__init__.py
  6. 58
      event_question_sale_renting/controllers/main.py
  7. 3
      event_question_sale_renting/models/__init__.py
  8. 25
      event_question_sale_renting/models/event_question.py
  9. 12
      event_question_sale_renting/models/event_question_answer.py
  10. 25
      event_question_sale_renting/models/event_question_answer_product.py
  11. 14
      event_question_sale_renting/models/event_registration_answer.py
  12. BIN
      event_question_sale_renting/static/description/icon.png
  13. 93
      event_question_sale_renting/static/description/icon.svg

1
event_question_sale/controllers/__init__.py

@ -0,0 +1 @@
from . import main

58
event_question_sale/controllers/main.py

@ -0,0 +1,58 @@
from collections import defaultdict
from odoo import _
from odoo.http import request, route
from odoo.addons.website_event_questions.controllers.main import WebsiteEventController
class WebsiteEventQep(WebsiteEventController):
# def _process_attendees_form(self, event, form_details):
# """Process data posted from the attendee details form.
# Extracts question answers:
# - For both questions asked 'once_per_order' and questions asked to every attendee
# - For questions of type 'simple_choice', extracting the suggested answer id
# - For questions of type 'text_box', extracting the text answer of the attendee.
# """
# registrations = super(WebsiteEvent, self)._process_attendees_form(
# event, form_details
# )
def _create_attendees_from_registration_post(self, event, registration_data):
if not any(info.get("event_ticket_id") for info in registration_data):
return super()._create_attendees_from_registration_post(
event, registration_data
)
res = super()._create_attendees_from_registration_post(event, registration_data)
order_sudo = request.website.sale_get_order(force_create=True)
reg_answers = {}
for data in registration_data:
answers = data.get("registration_answer_ids")
# tickets_data = defaultdict(int)
# for data in registration_data:
# event_ticket_id = data.get("event_ticket_id")
# if event_ticket_id:
# tickets_data[event_ticket_id] += 1
# cart_data = {}
# for ticket_id, count in tickets_data.items():
# ticket_sudo = request.env["event.event.ticket"].sudo().browse(ticket_id)
# cart_values = order_sudo._cart_update(
# product_id=ticket_sudo.product_id.id,
# add_qty=count,
# event_ticket_id=ticket_id,
# )
# cart_data[ticket_id] = cart_values["line_id"]
# for data in registration_data:
# event_ticket_id = data.get("event_ticket_id")
# if event_ticket_id:
# data["sale_order_id"] = order_sudo.id
# data["sale_order_line_id"] = cart_data[event_ticket_id]
request.session["website_sale_cart_quantity"] = order_sudo.cart_quantity
return res

1
event_question_sale_renting/__init__.py

@ -0,0 +1 @@
from . import models

41
event_question_sale_renting/__manifest__.py

@ -0,0 +1,41 @@
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
{
"name": "Event question sale renting",
"version": "1.0.0",
"summary": """
Set booking order extra products on event question answers.
""",
"description": """
This module extends the functionnalities of event questions and event tickets sale.
On the event questions you can check the box to be able to add on each answer,
zero, one or more extra products (giving price and qty) that will be added to the sale order.
For the questions asked once per registration, you can choose to add the extra products once or for each attendee.
""",
"author": "RemiFr82",
"contributors": "Hike2River",
"website": "https://remifr82.me",
"license": "LGPL-3",
"category": "Events",
# "price": 0,
# "currency": "EUR",
"application": False,
"installable": True,
"auto_install": False,
"pre_init_hook": "",
"post_init_hook": "",
"uninstall_hook": "",
"excludes": [],
"external_dependencies": [],
"depends": [
"website_event_questions",
"website_event_sale",
],
"data": [],
"assets": {},
"css": [],
"images": [],
"js": [],
"test": [],
"demo": [],
"maintainer": "RemiFr82",
}

1
event_question_sale_renting/controllers/__init__.py

@ -0,0 +1 @@
from . import main

58
event_question_sale_renting/controllers/main.py

@ -0,0 +1,58 @@
from collections import defaultdict
from odoo import _
from odoo.http import request, route
from odoo.addons.website_event_questions.controllers.main import WebsiteEventController
class WebsiteEventQep(WebsiteEventController):
# def _process_attendees_form(self, event, form_details):
# """Process data posted from the attendee details form.
# Extracts question answers:
# - For both questions asked 'once_per_order' and questions asked to every attendee
# - For questions of type 'simple_choice', extracting the suggested answer id
# - For questions of type 'text_box', extracting the text answer of the attendee.
# """
# registrations = super(WebsiteEvent, self)._process_attendees_form(
# event, form_details
# )
def _create_attendees_from_registration_post(self, event, registration_data):
if not any(info.get("event_ticket_id") for info in registration_data):
return super()._create_attendees_from_registration_post(
event, registration_data
)
res = super()._create_attendees_from_registration_post(event, registration_data)
order_sudo = request.website.sale_get_order(force_create=True)
reg_answers = {}
for data in registration_data:
answers = data.get("registration_answer_ids")
# tickets_data = defaultdict(int)
# for data in registration_data:
# event_ticket_id = data.get("event_ticket_id")
# if event_ticket_id:
# tickets_data[event_ticket_id] += 1
# cart_data = {}
# for ticket_id, count in tickets_data.items():
# ticket_sudo = request.env["event.event.ticket"].sudo().browse(ticket_id)
# cart_values = order_sudo._cart_update(
# product_id=ticket_sudo.product_id.id,
# add_qty=count,
# event_ticket_id=ticket_id,
# )
# cart_data[ticket_id] = cart_values["line_id"]
# for data in registration_data:
# event_ticket_id = data.get("event_ticket_id")
# if event_ticket_id:
# data["sale_order_id"] = order_sudo.id
# data["sale_order_line_id"] = cart_data[event_ticket_id]
request.session["website_sale_cart_quantity"] = order_sudo.cart_quantity
return res

3
event_question_sale_renting/models/__init__.py

@ -0,0 +1,3 @@
from . import event_question_answer_product
from . import event_question_answer
from . import event_question

25
event_question_sale_renting/models/event_question.py

@ -0,0 +1,25 @@
from odoo import api, fields, models, _
class EventQuestion(models.Model):
_inherit = "event.question"
add_renting = fields.Boolean(
string="Add extra renting on answers",
)
qty_by_attendees = fields.Boolean(
string="Multiply quantity by attendees count",
help="For the questions asked only once per registration.\n"
"If checked, Odoo will add the extra product for each attendee.\n"
"Otherwise, Odoo will add the extra product only once.",
)
@api.onchange("question_type")
def onchange_qtype(self):
if self.question_type != "simple_choice" and self.add_product:
self.add_product = False
@api.onchange("once_per_order")
def onchange_qtype(self):
if not self.once_per_order and self.qty_by_attendees:
self.qty_by_attendees = False

12
event_question_sale_renting/models/event_question_answer.py

@ -0,0 +1,12 @@
from odoo import api, fields, models, _
class EventQuestionAnswer(models.Model):
_inherit = "event.question.answer"
extra_renting_ids = fields.One2many(
comodel_name="event.question.answer.renting",
inverse_name="answer_id",
string="Extra Renting",
help="These products rentings will be added to the sale order of the booking with the given quantity, prices and duration.",
)

25
event_question_sale_renting/models/event_question_answer_product.py

@ -0,0 +1,25 @@
from odoo import api, fields, models, _
class EventQuestionAnswerRenting(models.Model):
_inherit = "event.question.answer.renting"
rentable = fields.Boolean(
string="Rentable",
compute="_get_rentable",
invisible=True,
)
renting = fields.Boolean(
string="Renting",
)
@api.depends("product_id")
def _get_rentable(self):
for eqap in self:
eqap.rentable = eqap.product_id.rent_ok
@api.onchange("rentable")
def onchange_rentable(self):
for eqap in self:
if not eqap.rentable:
eqap.renting = False

14
event_question_sale_renting/models/event_registration_answer.py

@ -0,0 +1,14 @@
from odoo import api, fields, models, _
class EventRegistrationAnswer(models.Model):
_inherit = "event.registration.answer"
extra_product_ids = fields.One2many(related="value_answer_id.extra_product_ids")
sale_order_line_ids = fields.Many2many(
comodel_name="sale.order.line",
column1="event_answer_id",
column2="sale_order_line_id",
relation="event_answer_sale_order_line_rel",
string="Related sale order lines",
)

BIN
event_question_sale_renting/static/description/icon.png

After

Width: 1539  |  Height: 1771  |  Size: 182 KiB

93
event_question_sale_renting/static/description/icon.svg

@ -0,0 +1,93 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 28.2.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Calque_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 2000 2000" style="enable-background:new 0 0 2000 2000;" xml:space="preserve">
<style type="text/css">
.st0{fill:url(#SVGID_1_);}
.st1{opacity:0.288;fill:#5BB4B9;enable-background:new ;}
.st2{fill:#714B67;stroke:#FFFFFF;stroke-width:2.5312;stroke-linejoin:round;stroke-miterlimit:84.375;}
.st3{fill:#00A09D;stroke:#FFFFFF;stroke-width:2.5312;stroke-linejoin:round;stroke-miterlimit:84.375;}
</style>
<g id="Calque_1_00000161600930838337179250000013767234669113973950_">
<g>
<g>
<g transform="translate(13 10)">
<linearGradient id="SVGID_1_" gradientUnits="userSpaceOnUse" x1="-856.1276" y1="-992.6924" x2="-877.9248" y2="-975.3946" gradientTransform="matrix(43.9892 0 0 50.6251 39146.6719 50789.9492)">
<stop offset="0" style="stop-color:#81D9DD"/>
<stop offset="1" style="stop-color:#419CA1"/>
</linearGradient>
<path class="st0" d="M1747.1,540.7l-749.9-433c-6-3.4-13.3-3.4-19.3,0L228,540.7c-6,3.4-9.6,9.8-9.6,16.7v865.9
c0,6.9,3.7,13.3,9.6,16.7l749.9,433c3,1.7,6.3,2.6,9.6,2.6s6.6-0.8,9.6-2.6l749.9-433c6-3.4,9.6-9.8,9.6-16.7v-866
C1756.7,550.5,1753,544.1,1747.1,540.7z M256.8,1409V590.7l708.6,409.1l2.8,4.9V1823l-708.7-409.2L256.8,1409z M990.3,148.2
L1699,557.3L990.3,966.5h-5.6L276,557.3l708.7-409.1L990.3,148.2L990.3,148.2z M1006.8,1004.7l2.8-4.8l708.6-409.1V1409
l-2.8,4.8l-708.6,409.1L1006.8,1004.7L1006.8,1004.7z"/>
<rect x="970" y="870.2" class="st1" width="35" height="48.1"/>
<rect x="970" y="485.1" class="st1" width="35" height="48.1"/>
<rect x="970" y="774" class="st1" width="35" height="48.1"/>
<rect x="970" y="581.4" class="st1" width="35" height="48.1"/>
<rect x="970" y="196.3" class="st1" width="35" height="48.1"/>
<rect x="970" y="292.6" class="st1" width="35" height="48.1"/>
<rect x="970" y="388.9" class="st1" width="35" height="48.1"/>
<rect x="970" y="677.7" class="st1" width="35" height="48.1"/>
<rect x="703.4" y="1109.5" transform="matrix(0.8661 -0.4999 0.4999 0.8661 -465.9773 514.5881)" class="st1" width="48.1" height="35"/>
<rect x="620.2" y="1157.7" transform="matrix(0.8661 -0.4999 0.4999 0.8661 -501.1965 479.4498)" class="st1" width="48.1" height="35"/>
<rect x="536.7" y="1205.8" transform="matrix(0.8659 -0.5002 0.5002 0.8659 -536.6949 444.5481)" class="st1" width="48.2" height="35"/>
<rect x="870.1" y="1013.3" transform="matrix(0.8662 -0.4996 0.4996 0.8662 -395.3831 584.6333)" class="st1" width="48.1" height="35"/>
<rect x="786.8" y="1061.3" transform="matrix(0.8659 -0.5002 0.5002 0.8659 -430.897 550.2667)" class="st1" width="48.2" height="35"/>
<rect x="286.6" y="1350.2" transform="matrix(0.8659 -0.5002 0.5002 0.8659 -642.4768 338.7787)" class="st1" width="48.1" height="35"/>
<rect x="453.3" y="1253.8" transform="matrix(0.866 -0.5 0.5 0.866 -571.7071 408.9949)" class="st1" width="48.1" height="35"/>
<rect x="370.1" y="1302.1" transform="matrix(0.8661 -0.4999 0.4999 0.8661 -606.8809 373.7628)" class="st1" width="48.1" height="35"/>
<rect x="1307.6" y="1145.5" transform="matrix(0.5 -0.866 0.866 0.5 -350.2617 1732.3198)" class="st1" width="35" height="48.1"/>
<rect x="1141" y="1049.1" transform="matrix(0.5001 -0.866 0.866 0.5001 -350.2007 1539.6794)" class="st1" width="35" height="48.1"/>
<rect x="1224.4" y="1097.2" transform="matrix(0.4996 -0.8663 0.8663 0.4996 -349.8225 1636.8931)" class="st1" width="35" height="48.1"/>
<rect x="1638.3" y="1342.1" transform="matrix(0.5004 -0.8658 0.8658 0.5004 -349.8787 2112.7935)" class="st1" width="35" height="35"/>
<rect x="1057.5" y="1001" transform="matrix(0.5003 -0.8658 0.8658 0.5003 -350.4254 1443.0403)" class="st1" width="35" height="48.2"/>
<rect x="1474.3" y="1241.7" transform="matrix(0.5003 -0.8658 0.8658 0.5003 -350.5846 1924.1418)" class="st1" width="35" height="48.2"/>
<rect x="1557.8" y="1289.8" transform="matrix(0.5 -0.866 0.866 0.5 -350.1897 2021.1473)" class="st1" width="35" height="48.1"/>
<rect x="1391.1" y="1193.6" transform="matrix(0.4997 -0.8662 0.8662 0.4997 -349.9747 1829.327)" class="st1" width="35" height="48.1"/>
</g>
</g>
</g>
</g>
<g id="odoo">
<path class="st2" d="M993.2,439.3c-303.8,0-550,246.2-550,550s246.2,550,550,550s550-246.2,550-550S1297,439.3,993.2,439.3z
M993.2,659.3c182.3,0,330,147.7,330,330s-147.7,330-330,330s-330-147.7-330-330S811,659.3,993.2,659.3z"/>
</g>
<g id="kayak">
<path class="st3" d="M609.8,957.9c-0.4,14.4,11.8,59.8,23.4,86.8c33.6,75.8,69.2,108.4,220.1,201.6
c98.9,60.7,128.1,86.2,151.7,130.9c9.2,17,18.8,40,22,51.1l6,20.3v-44.8c0.8-103.6-28.8-138.3-193.3-229.7
c-39.6-21.8-88-51-107.3-64.7c-55.2-39.6-95.4-88.1-115.8-141c0,0-6.7-16.2-6.7-16.2L609.8,957.9z"/>
<path class="st3" d="M1179.5,540c-5.6,5.6-17.4,11.1-35.1,16.4c-15.4,4.6-35.2,9-59.3,13.2c-151.7,26.3-191.7,46.6-191.7,97.3
c0,13.3,6,27.7,29.6,71.8c16.4,30.3,32.4,65.1,36,77.3c10.4,37.7,12,87.3,4.8,149.8c-3.6,31.4-6.8,63.6-7.6,72.1l-0.8,14.8
l-56.8-27.7c-81.6-40.3-115.7-61.4-148.1-91.4c-54.8-50.7-76-114.7-64.8-197.5c8.8-68.1,35.2-132.8,70.8-173.1l18.4-21.1l-16,11.8
c-68,49.9-109.7,147.2-109.7,257.4c0,84.7,28.4,150.9,88,206c32.4,30,61.6,47.3,140.9,83.6c38,17.8,79.6,38.8,92.8,47
c44.8,29.2,84.4,82.5,98.1,132.4l7.2,26.3l4.8-58.4c2.8-32.5,6.8-67.3,8.8-77.3c2-10.4,7.2-40.3,11.2-66.6
c10.4-65.1,30.8-112.1,58.4-134.3c25.6-21.1,38.4-14.8,63.6,31.4c22,40.7,38,54.7,74.8,65.1c4.4,1.5,8,13.3,13.2,46.6
c6.4,39.9,6.8,50.7,2.4,96.5c-6,61.8-3.6,120.6,6,146.1c10.4,28.1,27.6,51,56.8,74.3l26,21.5l-2.4-38.8
c-6.4-85.1-18-150.2-38.4-208.2c-6.8-18.5-16.4-61-22.4-94.7c-15.6-92.1-51.6-255.2-67.6-306.3c-22.4-71.8-53.6-138.2-90.4-192.6
c-4.9-7.1-17.3-25.2-17.3-25.2s5.9-7.4,9.3-12.6c3.9-4.8,9.7-15.2,12.5-23.7c2.7-8.3,1.7-18,1.7-18S1183.5,535.9,1179.5,540z
M1177.1,619.2c36.4,59.2,61.2,128.3,86,240.8c19.2,88,31.2,150.2,29.2,152.4c-4.4,3.7-19.2-25.9-29.2-58.1
c-12.8-41.8-21.2-58.1-37.2-72.9c-18-17-37.6-23.7-88-30.7c-58.8-8.1-74-15.2-113.7-52.5c-42.4-39.9-59.6-64.7-62-88.4
c-3.6-33.7,9.6-43.6,81.2-62.5c48.4-12.9,71.6-23.3,96.1-42.5c8.8-7,17.8-13.8,17.8-13.8S1167.5,604,1177.1,619.2z"/>
<path class="st3" d="M1130.6,658.7c0,6.7-4.7,23.2-9.1,33.5c-6.4,14.8-8,27.4-8,61.4c0,34-1.6,45.1-6.8,53.6
c-4,5.9-13.2,14.4-13.2,14.4s22.4,3.7,44.4-6.7c52-24.4,55.6-74.3,9.6-139.8c-11-15.6-16.9-20.8-16.9-20.8
S1130.6,654.5,1130.6,658.7z"/>
</g>
</svg>
Loading…
Cancel
Save