Browse Source

[ADD] event_sale_balance

16.0
RemiFr82 1 year ago
parent
commit
f6f12e0e5d
  1. 1
      event_sale_balance/__init__.py
  2. 38
      event_sale_balance/__manifest__.py
  3. 2
      event_sale_balance/models/__init__.py
  4. 26
      event_sale_balance/models/event_registration.py
  5. 8
      event_sale_balance/models/product_product.py
  6. 8
      event_sale_balance/security/event_sale_balance.xml
  7. 32
      event_sale_balance/views/product_product.xml

1
event_sale_balance/__init__.py

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

38
event_sale_balance/__manifest__.py

@ -0,0 +1,38 @@
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
{
"name": "Event sale balance",
"version": "1.0.0",
"summary": """
"Event ticket" product variants can be marked as "Event deposit", linked to a "Balance" variant, and added to sales order on presence confirmation.
""",
"description": """
TO WRITE
""",
"author": "RemiFr82",
"contributors": "",
"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_sale",
],
"data": [
"views/product_product.xml",
],
"css": [],
"images": [],
"js": [],
"test": [],
"demo": [],
"maintainer": "RemiFr82",
}

2
event_sale_balance/models/__init__.py

@ -0,0 +1,2 @@
from . import event_registration
from . import product_product

26
event_sale_balance/models/event_registration.py

@ -0,0 +1,26 @@
from odoo import models, api
class EventRegistration(models.Model):
_inherit = "event.registration"
def action_set_done(self):
super().action_set_done()
for regis in self:
tic_prod = regis.event_ticket_id.product_id
bal_prod = tic_prod.balance_variant_id
if tic_prod.is_event_deposit and bal_prod:
order = regis.sale_order_id
lines = order.order_line
line = lines.filtered(lambda sol: sol.product_id == bal_prod, limit=1)
if line:
# Update existing line
update_values = order._prepare_order_line_update_values(
line, line.product_uom_qty + 1
)
if update_values:
order._update_cart_line_values(line, update_values)
else:
# Create new line
line_values = order._prepare_order_line_values(bal_prod, 1)
line.sudo().create(line_values)

8
event_sale_balance/models/product_product.py

@ -0,0 +1,8 @@
from odoo import models, fields
class ProductProduct(models.Model):
_inherit = "product.product"
is_event_deposit = fields.Boolean("Event deposit")
balance_variant_id = fields.Many2one("product.product", string="Balance variant")

8
event_sale_balance/security/event_sale_balance.xml

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="group_event_balance" model="res.groups">
<field name="name">Use event balance</field>
</record>
</odoo>

32
event_sale_balance/views/product_product.xml

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="product_variant_easy_edit_view_inherit" model="ir.ui.view">
<field name="name">product.product.view.form.inherit</field>
<field name="model">product.product</field>
<field name="inherit_id" ref="product.product_variant_easy_edit_view" />
<field name="arch" type="xml">
<group name="product_variant_images" position="after">
<group name="event" string="Event sale" attrs="{'invisible': [('detailed_type','!=','event')]}">
<field name="is_deposit" />
<field name="balance_variant_id" options="{'no_create': 1}" />
</group>
</group>
</field>
</record>
<record id="product_normal_form_view_inherit" model="ir.ui.view">
<field name="name">product.product.view.form.inherit</field>
<field name="model">product.product</field>
<field name="inherit_id" ref="product.product_normal_form_view" />
<field name="arch" type="xml">
<group name="description" position="after">
<group name="event" string="Event sale" attrs="{'invisible': [('detailed_type','!=','event')]}">
<field name="is_deposit" />
<field name="balance_variant_id" options="{'no_create': 1}" />
</group>
</group>
</field>
</record>
</odoo>
Loading…
Cancel
Save