[IMP] {website_,}event_sale: remove event_ok from product
This is now a type of product. task-2605931 Part-of: odoo/odoo#75862
This commit is contained in:
@@ -23,7 +23,6 @@ this event.
|
||||
'views/event_ticket_views.xml',
|
||||
'views/event_registration_views.xml',
|
||||
'views/event_views.xml',
|
||||
'views/product_views.xml',
|
||||
'views/sale_order_views.xml',
|
||||
'data/event_sale_data.xml',
|
||||
'data/mail_data.xml',
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
|
||||
<record id="product_product_event" model="product.product">
|
||||
<field name="list_price">30.0</field>
|
||||
<field name="event_ok" eval="True"/>
|
||||
<field name="standard_price">10.0</field>
|
||||
<field name="uom_id" ref="uom.product_uom_unit"/>
|
||||
<field name="uom_po_id" ref="uom.product_uom_unit"/>
|
||||
@@ -16,10 +15,7 @@
|
||||
<field name="description_sale" eval="False"/>
|
||||
<field name="invoice_policy">order</field>
|
||||
<field name="categ_id" ref="event_sale.product_category_events"/>
|
||||
<field name="type">service</field>
|
||||
<field name="detailed_type">event</field>
|
||||
</record>
|
||||
</data>
|
||||
</odoo>
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ class EventTemplateTicket(models.Model):
|
||||
# product
|
||||
product_id = fields.Many2one(
|
||||
'product.product', string='Product', required=True,
|
||||
domain=[("event_ok", "=", True)], default=_default_product_id)
|
||||
domain=[("detailed_type", "=", "event")], default=_default_product_id)
|
||||
price = fields.Float(
|
||||
string='Price', compute='_compute_price',
|
||||
digits='Product Price', readonly=False, store=True)
|
||||
|
||||
@@ -6,29 +6,22 @@ from odoo import api, fields, models
|
||||
class ProductTemplate(models.Model):
|
||||
_inherit = 'product.template'
|
||||
|
||||
event_ok = fields.Boolean(string='Is an Event Ticket', help="If checked this product automatically "
|
||||
"creates an event registration at the sales order confirmation.")
|
||||
detailed_type = fields.Selection(selection_add=[
|
||||
('event', 'Event Ticket'),
|
||||
], ondelete={'event': 'set default'})
|
||||
|
||||
@api.onchange('event_ok')
|
||||
def _onchange_event_ok(self):
|
||||
if self.event_ok:
|
||||
self.type = 'service'
|
||||
@api.onchange('detailed_type')
|
||||
def _onchange_type_event(self):
|
||||
if self.detailed_type == 'event':
|
||||
self.invoice_policy = 'order'
|
||||
|
||||
def _compute_show_service_fields(self):
|
||||
super()._compute_show_service_fields()
|
||||
for record in self:
|
||||
record.show_service_fields |= record.type == 'event'
|
||||
def _detailed_type_mapping(self):
|
||||
type_mapping = super()._detailed_type_mapping()
|
||||
type_mapping['event'] = 'service'
|
||||
return type_mapping
|
||||
|
||||
|
||||
class Product(models.Model):
|
||||
_inherit = 'product.product'
|
||||
|
||||
event_ticket_ids = fields.One2many('event.event.ticket', 'product_id', string='Event Tickets')
|
||||
|
||||
@api.onchange('event_ok')
|
||||
def _onchange_event_ok(self):
|
||||
""" Redirection, inheritance mechanism hides the method on the model """
|
||||
if self.event_ok:
|
||||
self.type = 'service'
|
||||
self.invoice_policy = 'order'
|
||||
|
||||
@@ -66,7 +66,12 @@ class SaleOrderLine(models.Model):
|
||||
event_ticket_id = fields.Many2one(
|
||||
'event.event.ticket', string='Event Ticket',
|
||||
help="Choose an event ticket and it will automatically create a registration for this event ticket.")
|
||||
event_ok = fields.Boolean(related='product_id.event_ok', readonly=True)
|
||||
event_ok = fields.Boolean(compute='_compute_event_ok')
|
||||
|
||||
@api.depends('product_id.detailed_type')
|
||||
def _compute_event_ok(self):
|
||||
for record in self:
|
||||
record.event_ok = record.product_id.detailed_type == 'event'
|
||||
|
||||
@api.depends('state', 'event_id')
|
||||
def _compute_product_uom_readonly(self):
|
||||
|
||||
@@ -5,7 +5,7 @@ var FormController = require('web.FormController');
|
||||
|
||||
/**
|
||||
* This controller is overridden to allow configuring sale_order_lines through a popup
|
||||
* window when a product with 'event_ok' is selected.
|
||||
* window when a product with 'detailed_type' == 'event' is selected.
|
||||
*
|
||||
* This allows keeping an editable list view for sales order and remove the noise of
|
||||
* those 2 fields ('event_id' + 'event_ticket_id')
|
||||
|
||||
@@ -54,9 +54,9 @@ ProductConfiguratorWidget.include({
|
||||
return this._rpc({
|
||||
model: 'product.product',
|
||||
method: 'read',
|
||||
args: [productId, ['event_ok']],
|
||||
args: [productId, ['detailed_type']],
|
||||
}).then(function (result) {
|
||||
if (Array.isArray(result) && result.length && result[0].event_ok) {
|
||||
if (Array.isArray(result) && result.length && result[0].detailed_type === 'event') {
|
||||
self._openEventConfigurator({
|
||||
default_product_id: productId
|
||||
},
|
||||
|
||||
@@ -27,18 +27,18 @@ odoo.define('event.configurator.tests', function (require) {
|
||||
'product.product': {
|
||||
fields: {
|
||||
id: {type: 'integer'},
|
||||
event_ok: {type: 'boolean'},
|
||||
detailed_type: {type: 'selection'},
|
||||
rent_ok: {type: 'boolean'}//sale_rental purposes
|
||||
},
|
||||
records: [{
|
||||
id: 1,
|
||||
display_name: "Customizable Event",
|
||||
event_ok: true,
|
||||
detailed_type: 'event',
|
||||
rent_ok: false//sale_rental purposes
|
||||
}, {
|
||||
id: 2,
|
||||
display_name: "Desk",
|
||||
event_ok: false,
|
||||
detailed_type: 'service',
|
||||
rent_ok: false//sale_rental purposes
|
||||
}]
|
||||
},
|
||||
@@ -85,9 +85,9 @@ odoo.define('event.configurator.tests', function (require) {
|
||||
data: this.data,
|
||||
arch: getArch(),
|
||||
mockRPC: function (route, params) {
|
||||
if (params.method === 'read' && params.args[1][0] === 'event_ok') {
|
||||
if (params.method === 'read' && params.args[1][0] === 'detailed_type') {
|
||||
assert.ok(true);
|
||||
return Promise.resolve([{event_ok: false}]);
|
||||
return Promise.resolve([{detailed_type: 'service'}]);
|
||||
}
|
||||
return this._super.apply(this, arguments);
|
||||
},
|
||||
@@ -114,9 +114,9 @@ odoo.define('event.configurator.tests', function (require) {
|
||||
data: this.data,
|
||||
arch: getArch(),
|
||||
mockRPC: function (route, params) {
|
||||
if (params.method === 'read' && params.args[1][0] === 'event_ok') {
|
||||
if (params.method === 'read' && params.args[1][0] === 'detailed_type') {
|
||||
assert.ok(true);
|
||||
return Promise.resolve([{event_ok: true}]);
|
||||
return Promise.resolve([{detailed_type: 'event'}]);
|
||||
}
|
||||
return this._super.apply(this, arguments);
|
||||
},
|
||||
|
||||
@@ -15,7 +15,6 @@ class TestEventSaleCommon(TestEventCommon, TestSalesCommon):
|
||||
'name': 'Test Registration Product',
|
||||
'description_sale': 'Mighty Description',
|
||||
'list_price': 10,
|
||||
'event_ok': True,
|
||||
'standard_price': 30.0,
|
||||
'type': 'service',
|
||||
'detailed_type': 'event',
|
||||
})
|
||||
|
||||
@@ -17,8 +17,7 @@ class TestEventSale(TestEventSaleCommon):
|
||||
|
||||
product = cls.env['product.product'].create({
|
||||
'name': 'Event',
|
||||
'type': 'service',
|
||||
'event_ok': True,
|
||||
'detailed_type': 'event',
|
||||
})
|
||||
|
||||
cls.user_salesperson = mail_new_test_user(cls.env, login='user_salesman', groups='sales_team.group_sale_salesman')
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
<attribute name="string">Sales End</attribute>
|
||||
</field>
|
||||
<field name="name" position="after">
|
||||
<field name="product_id" context="{'default_event_ok': 1}"/>
|
||||
<field name="product_id" context="{'default_detailed_type': 'event'}"/>
|
||||
</field>
|
||||
<field name="description" position="after">
|
||||
<field name="price"/>
|
||||
@@ -57,7 +57,7 @@
|
||||
<field name="inherit_id" ref="event.event_event_ticket_view_form_from_event"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="name" position="after">
|
||||
<field name="product_id" context="{'default_event_ok':1}"/>
|
||||
<field name="product_id" context="{'default_detailed_type': 'event'}"/>
|
||||
</field>
|
||||
<field name="description" position="after">
|
||||
<field name="price"/>
|
||||
@@ -98,4 +98,3 @@
|
||||
</field>
|
||||
</record>
|
||||
</data></odoo>
|
||||
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<record id="event_sale_product_template_form" model="ir.ui.view">
|
||||
<field name="name">product.template.event.form.inherit</field>
|
||||
<field name="model">product.template</field>
|
||||
<field name="inherit_id" ref="product.product_template_form_view" />
|
||||
<field name="arch" type="xml">
|
||||
<group name="sale" position="inside">
|
||||
<group string="Events">
|
||||
<field name="event_ok" />
|
||||
</group>
|
||||
</group>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
@@ -24,9 +24,8 @@ class TestEventFullCommon(TestEventCrmCommon, TestSalesCommon, EventDtPatcher, M
|
||||
'name': 'Test Registration Product',
|
||||
'description_sale': 'Mighty Description',
|
||||
'list_price': 10,
|
||||
'event_ok': True,
|
||||
'standard_price': 30.0,
|
||||
'type': 'service',
|
||||
'detailed_type': 'event',
|
||||
})
|
||||
|
||||
cls.website = cls.env['website'].search([
|
||||
@@ -138,9 +137,8 @@ class TestWEventCommon(HttpCaseWithUserDemo, HttpCaseWithUserPortal, EventDtPatc
|
||||
'default_code': 'EVENT_REG',
|
||||
'description_sale': 'Mighty Description',
|
||||
'list_price': 10,
|
||||
'event_ok': True,
|
||||
'standard_price': 30.0,
|
||||
'type': 'service',
|
||||
'detailed_type': 'event',
|
||||
})
|
||||
|
||||
self.event_tag_category_1 = self.env['event.tag.category'].create({
|
||||
|
||||
@@ -11,8 +11,8 @@ class PricelistItem(models.Model):
|
||||
msg = ''
|
||||
if self.applied_on == '3_global' or self.applied_on == '2_product_category':
|
||||
msg = _("A pricelist item with a positive min. quantity will not be applied to the event tickets products.")
|
||||
elif ((self.applied_on == '1_product' and self.product_tmpl_id.event_ok) or
|
||||
(self.applied_on == '0_product_variant' and self.product_id.event_ok)):
|
||||
elif ((self.applied_on == '1_product' and self.product_tmpl_id.type == 'event') or
|
||||
(self.applied_on == '0_product_variant' and self.product_id.type == 'event')):
|
||||
msg = _("A pricelist item with a positive min. quantity cannot be applied to this event tickets product.")
|
||||
if msg:
|
||||
return {'warning':
|
||||
|
||||
@@ -8,4 +8,4 @@ class Website(models.Model):
|
||||
|
||||
def sale_product_domain(self):
|
||||
# remove product event from the website content grid and list view (not removed in detail view)
|
||||
return ['&'] + super(Website, self).sale_product_domain() + [('event_ok', '=', False)]
|
||||
return ['&'] + super(Website, self).sale_product_domain() + [('type', '!=', 'event')]
|
||||
|
||||
Reference in New Issue
Block a user