[FIX] learning_base: remove learning value frm product detailed_type

If we have to select "learning" value in the detailed_type field, this
means that we can not select Event Ticket, then we can not sell the
product as a ticket in an event.
This commit is contained in:
Stéphan Sainléger
2023-06-16 12:47:08 +02:00
parent 9d0549db19
commit 6840765f5c
4 changed files with 88 additions and 101 deletions

View File

@@ -24,7 +24,6 @@
'security/ir.model.access.csv', 'security/ir.model.access.csv',
'ir_actions_act_window_records.xml', 'ir_actions_act_window_records.xml',
'ir_ui_menu_records.xml', 'ir_ui_menu_records.xml',
'ir_module_category_records.xml',
'views/product_template.xml', 'views/product_template.xml',
'views/event_event.xml', 'views/event_event.xml',
'views/res_company.xml', 'views/res_company.xml',

View File

@@ -1,8 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="ir_module_category_formation_r0" model="ir.module.category">
<field name="name">Formation</field>
</record>
</data>
</openerp>

View File

@@ -17,11 +17,7 @@ class learningFinancialProgram(models.Model):
class ProductTemplate(models.Model): class ProductTemplate(models.Model):
_inherit = ['product.template'] _inherit = ['product.template']
is_learning = fields.Boolean(compute='_compute_is_learning', store=True) is_learning = fields.Boolean(string='is learning')
detailed_type = fields.Selection(selection_add=[
('learning', 'Training'),
], ondelete={'learning': 'set service'})
goal = fields.Html(string='Goal', translate=True) goal = fields.Html(string='Goal', translate=True)
duration_html = fields.Html(string='Duration', translate=True) duration_html = fields.Html(string='Duration', translate=True)
@@ -56,11 +52,6 @@ class ProductTemplate(models.Model):
for record in self: for record in self:
record.count_session = len(self.env['event.event'].search([('learning_id', '=', record.id)])) record.count_session = len(self.env['event.event'].search([('learning_id', '=', record.id)]))
@api.depends('detailed_type')
def _compute_is_learning(self):
for record in self:
record.is_learning = record.detailed_type == 'learning'
def _detailed_type_mapping(self): def _detailed_type_mapping(self):
type_mapping = super()._detailed_type_mapping() type_mapping = super()._detailed_type_mapping()
type_mapping['learning'] = 'service' type_mapping['learning'] = 'service'

View File

@@ -3,98 +3,103 @@
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). --> License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
<odoo> <odoo>
<record id="learning_base_product_template_form" model="ir.ui.view"> <record id="learning_base_product_template_form" model="ir.ui.view">
<field name="name">product.template.learning.form.inherit</field> <field name="name">product.template.learning.form.inherit</field>
<field name="model">product.template</field> <field name="model">product.template</field>
<field name="inherit_id" ref="product.product_template_form_view"/> <field name="inherit_id" ref="product.product_template_form_view" />
<field name="arch" type="xml"> <field name="arch" type="xml">
<div name="button_box" position="inside">
<button name="%(ir_actions_act_window_session_r0)d"
type="action"
class="oe_stat_button"
icon="fa-pencil-square-o"
context="{'search_default_learning_id': active_id, 'default_name': name, 'default_learning_id': active_id}">
<field name="count_session" widget="statinfo" string="Sessions"/>
</button>
</div>
<page name="sales" position="after"> <div name="button_box" position="inside">
<page string="Learning" attrs="{'invisible':[('detailed_type','!=','learning')]}" name="Learning"> <button name="%(ir_actions_act_window_session_r0)d"
<group name="Informations"> type="action"
<group> class="oe_stat_button"
<field name="domain_id"/> icon="fa-pencil-square-o"
</group> context="{'search_default_learning_id': active_id, 'default_name': name, 'default_learning_id': active_id}">
</group> <field name="count_session" widget="statinfo" string="Sessions" />
<group name="Duration"> </button>
<group> </div>
<field name="duration_days"/>
<field name="hours_per_day"/>
<field name="duration_hour"/>
</group>
<group>
<field name="duration_text" placeholder="Specific duration details" nolabel="1"/>
</group>
</group>
<group name="Financial Programs">
<field name="financial_program_ids" widget="many2many_tags"/>
</group>
<div name="learning_data"> <field name="detailed_type" position="after">
<separator string="Goal"/> <field name="is_learning" />
<div class="alert alert-info" role="alert"> </field>
To edit content, please go to the website page directly.
<page name="sales" position="after">
<page string="Learning" attrs="{'invisible':[('is_learning','=', False)]}"
name="Learning">
<group name="Informations">
<group>
<field name="domain_id" />
</group>
</group>
<group name="Duration">
<group>
<field name="duration_days" />
<field name="hours_per_day" />
<field name="duration_hour" />
</group>
<group>
<field name="duration_text" placeholder="Specific duration details" nolabel="1" />
</group>
</group>
<group name="Financial Programs">
<field name="financial_program_ids" widget="many2many_tags" />
</group>
<div name="learning_data">
<separator string="Goal" />
<div class="alert alert-info" role="alert">
To edit content, please go to the website page directly.
</div> </div>
<field name="goal" readonly="1"/> <field name="goal" readonly="1" />
<separator string="Duration Details"/> <separator string="Duration Details" />
<div class="alert alert-info" role="alert"> <div class="alert alert-info" role="alert">
To edit content, please go to the website page directly. To edit content, please go to the website page directly.
</div> </div>
<field name="duration_html" readonly="1"/> <field name="duration_html" readonly="1" />
<separator string="Public"/> <separator string="Public" />
<div class="alert alert-info" role="alert"> <div class="alert alert-info" role="alert">
To edit content, please go to the website page directly. To edit content, please go to the website page directly.
</div> </div>
<field name="public" readonly="1"/> <field name="public" readonly="1" />
<separator string="Prerequisite"/> <separator string="Prerequisite" />
<div class="alert alert-info" role="alert"> <div class="alert alert-info" role="alert">
To edit content, please go to the website page directly. To edit content, please go to the website page directly.
</div> </div>
<field name="prerequisite" readonly="1"/> <field name="prerequisite" readonly="1" />
<separator string="Content"/> <separator string="Content" />
<div class="alert alert-info" role="alert"> <div class="alert alert-info" role="alert">
To edit content, please go to the website page directly. To edit content, please go to the website page directly.
</div> </div>
<field name="content" readonly="1"/> <field name="content" readonly="1" />
<separator string="Organizer"/> <separator string="Organizer" />
<div class="alert alert-info" role="alert"> <div class="alert alert-info" role="alert">
To edit content, please go to the website page directly. To edit content, please go to the website page directly.
</div> </div>
<field name="organizer" readonly="1"/> <field name="organizer" readonly="1" />
<separator string="Methodology"/> <separator string="Methodology" />
<div class="alert alert-info" role="alert"> <div class="alert alert-info" role="alert">
To edit content, please go to the website page directly. To edit content, please go to the website page directly.
</div> </div>
<field name="methodology" readonly="1"/> <field name="methodology" readonly="1" />
<separator string="Technical"/> <separator string="Technical" />
<div class="alert alert-info" role="alert"> <div class="alert alert-info" role="alert">
To edit content, please go to the website page directly. To edit content, please go to the website page directly.
</div> </div>
<field name="technic" readonly="1"/> <field name="technic" readonly="1" />
<separator string="Price details"/> <separator string="Price details" />
<div class="alert alert-info" role="alert"> <div class="alert alert-info" role="alert">
To edit content, please go to the website page directly. To edit content, please go to the website page directly.
</div> </div>
<field name="price_html" readonly="1"/> <field name="price_html" readonly="1" />
<separator string="Registration"/> <separator string="Registration" />
<div class="alert alert-info" role="alert"> <div class="alert alert-info" role="alert">
To edit content, please go to the website page directly. To edit content, please go to the website page directly.
</div> </div>
<field name="registration" readonly="1"/> <field name="registration" readonly="1" />
</div> </div>
</page> </page>
</page> </page>
</field> </field>
</record> </record>
</odoo> </odoo>