[NEW] training-tools addons
This commit is contained in:
6
learning_base/models/__init__.py
Normal file
6
learning_base/models/__init__.py
Normal file
@@ -0,0 +1,6 @@
|
||||
from . import product_template
|
||||
from . import event_event
|
||||
from . import res_partner
|
||||
from . import learning_domain
|
||||
from . import res_company
|
||||
from . import website
|
39
learning_base/models/event_event.py
Normal file
39
learning_base/models/event_event.py
Normal file
@@ -0,0 +1,39 @@
|
||||
# Copyright 2018 Nicolas JEUDY
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
import logging
|
||||
import datetime
|
||||
from odoo import api, fields, models, _
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class EventEvent(models.Model):
|
||||
_inherit = ['event.event']
|
||||
|
||||
duration_hour = fields.Float('Duration in hour(s)')
|
||||
learning_id = fields.Many2one('product.template', string='Learning', domain=[('is_learning', '=', True)])
|
||||
date_text= fields.Char("Date in text mode")
|
||||
hour_text= fields.Char("Training time")
|
||||
duration_days = fields.Float(related='learning_id.duration_days', store=True )
|
||||
methodology_partner_id = fields.Many2one('res.partner', "Methodology partner")
|
||||
|
||||
class EventRegistration(models.Model):
|
||||
_inherit = 'event.registration'
|
||||
|
||||
is_learning = fields.Boolean(related='event_id.learning_id.is_learning', readonly="1", store=True)
|
||||
|
||||
class EventTicket(models.Model):
|
||||
_inherit = 'event.event.ticket'
|
||||
|
||||
@api.model
|
||||
def default_get(self, fields):
|
||||
res = super(EventTicket, self).default_get(fields)
|
||||
product_tmpl_id = self.env.context.get('learning_id', False)
|
||||
if product_tmpl_id:
|
||||
product_id = self.env['product.product'].search(
|
||||
[('product_tmpl_id', '=', product_tmpl_id)],
|
||||
limit=1
|
||||
)
|
||||
if product_id:
|
||||
res['product_id'] = product_id.id
|
||||
return res
|
20
learning_base/models/learning_domain.py
Normal file
20
learning_base/models/learning_domain.py
Normal file
@@ -0,0 +1,20 @@
|
||||
from odoo import models, fields, api, _
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
|
||||
class LearningDomain(models.Model):
|
||||
_name = 'learning.domain'
|
||||
_parent_name = "parent_id"
|
||||
_parent_store = True
|
||||
|
||||
name = fields.Char('Name')
|
||||
code = fields.Char('Code', translate=False)
|
||||
parent_id = fields.Many2one('learning.domain', 'Parent Domain', index=True, ondelete='cascade')
|
||||
parent_path = fields.Char(index=True)
|
||||
child_id = fields.One2many('learning.domain', 'parent_id', 'Child Domain')
|
||||
|
||||
@api.constrains('parent_id')
|
||||
def _check_domain_recursion(self):
|
||||
if not self._check_recursion():
|
||||
raise ValidationError(_('You cannot create recursive domain.'))
|
||||
return True
|
64
learning_base/models/product_template.py
Normal file
64
learning_base/models/product_template.py
Normal file
@@ -0,0 +1,64 @@
|
||||
# Copyright 2018 Nicolas JEUDY
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import api, fields, models, _
|
||||
|
||||
|
||||
class learningFinancialProgram(models.Model):
|
||||
_name = 'learning.financial.program'
|
||||
_description = "Learning Financial Program"
|
||||
|
||||
product_tmpl_ids = fields.Many2many('product.template', 'financial_program_product_category_rel', 'financial_program_id', 'product_category_id', 'Products')
|
||||
name = fields.Char("Name")
|
||||
description = fields.Text('Description')
|
||||
description_html = fields.Html("Web Description")
|
||||
|
||||
|
||||
class ProductTemplate(models.Model):
|
||||
_inherit = ['product.template']
|
||||
|
||||
is_learning = fields.Boolean(compute='_compute_is_learning')
|
||||
detailed_type = fields.Selection(selection_add=[
|
||||
('learning', 'Training'),
|
||||
], ondelete={'learning': 'set service'})
|
||||
|
||||
|
||||
goal = fields.Html(string='Goal', translate=True)
|
||||
duration_html = fields.Html(string='Duration', translate=True)
|
||||
public = fields.Html(string='Public', translate=True)
|
||||
prerequisite = fields.Html(string='Prerequisite', translate=True)
|
||||
content = fields.Html(string='Content', translate=True)
|
||||
organizer = fields.Html(string='Organizer', translate=True)
|
||||
methodology = fields.Html(string='Methodology', translate=True)
|
||||
technic = fields.Html(string='Technical', translate=True)
|
||||
price_html = fields.Html(string='Price', translate=True)
|
||||
registration = fields.Html(string='Registration', translate=True)
|
||||
|
||||
our_value = fields.Html(string='Value', translate=True)
|
||||
|
||||
description = fields.Html(string='Description', translate=True)
|
||||
validate = fields.Html(string='Validate', translate=True)
|
||||
certificate = fields.Html(string='Certificate', translate=True)
|
||||
|
||||
financial_program_ids = fields.Many2many('learning.financial.program', 'financial_program_product_category_rel', 'product_category_id', 'financial_program_id', 'Financial Program')
|
||||
parent_domain_id = fields.Many2one('learning.domain', related='domain_id.parent_id', store=True, string="Domain parent")
|
||||
domain_id = fields.Many2one('learning.domain', string="Domain")
|
||||
duration_hour = fields.Float('Duration in hour(s)')
|
||||
hours_per_day = fields.Float('Nb hour(s) per day(s) ?')
|
||||
duration_days = fields.Float('Duration in day(s)')
|
||||
duration_text = fields.Text('Duration details')
|
||||
count_session = fields.Integer('Nb session', compute="_compute_session", readonly=True)
|
||||
sessions_ids = fields.One2many('event.event', 'learning_id', 'Slots')
|
||||
|
||||
# ajouter la nature de l'action de formation avec la liste
|
||||
|
||||
def _compute_session(self):
|
||||
for record in self:
|
||||
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'
|
||||
|
||||
|
10
learning_base/models/res_company.py
Normal file
10
learning_base/models/res_company.py
Normal file
@@ -0,0 +1,10 @@
|
||||
# Copyright 2018 Nicolas JEUDY
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
from odoo import api, fields, models, _
|
||||
|
||||
|
||||
class ResCompany(models.Model):
|
||||
_inherit = 'res.company'
|
||||
|
||||
learning_code = fields.Char('Learning Code')
|
||||
learning_support_email = fields.Char("Support Email")
|
36
learning_base/models/res_partner.py
Normal file
36
learning_base/models/res_partner.py
Normal file
@@ -0,0 +1,36 @@
|
||||
# Copyright 2018 Nicolas JEUDY
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
#import barcode
|
||||
#from barcode.writer import ImageWriter
|
||||
import base64
|
||||
import logging
|
||||
from io import BytesIO
|
||||
import re
|
||||
import unicodedata
|
||||
|
||||
from odoo import api, fields, models, _
|
||||
|
||||
|
||||
class ResPartner(models.Model):
|
||||
_inherit = 'res.partner'
|
||||
|
||||
# student_barcode = fields.Binary('Barcode', attachment=True, compute="_compute_barcode", store=True)
|
||||
|
||||
is_student = fields.Boolean("Student")
|
||||
is_trainer = fields.Boolean("Trainer")
|
||||
is_learning_contact = fields.Boolean("Learning contact")
|
||||
trainer_cv = fields.Char("CV")
|
||||
# ajouter un lien vers linkedin ou site internet
|
||||
|
||||
#@api.depends('ref')
|
||||
#def _compute_barcode(self):
|
||||
# for record in self:
|
||||
# if record.ref:
|
||||
# CODE39 = barcode.get_barcode_class('code39')
|
||||
# code39 = CODE39(record.ref, writer=ImageWriter(), add_checksum=False)
|
||||
# fp = BytesIO()
|
||||
# code39.write(fp)
|
||||
# #barcode.generate('code39', self.ref, writer=ImageWriter(), output=fp)
|
||||
# record.student_barcode = base64.b64encode(fp.getvalue())
|
||||
# else:
|
||||
# record.student_barcode = False
|
14
learning_base/models/website.py
Normal file
14
learning_base/models/website.py
Normal file
@@ -0,0 +1,14 @@
|
||||
import logging
|
||||
from odoo import models
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class Website(models.Model):
|
||||
_inherit = 'website'
|
||||
|
||||
def sale_product_domain(self):
|
||||
# ['&', ('sale_ok', '=', True), ('website_id', 'in', (False, 1)), ('event_ok', '=', False)]
|
||||
_logger.debug(super(Website, self).sale_product_domain())
|
||||
#return ['&'] + super(Website, self).sale_product_domain() + [('event_ok', '=', False)]
|
||||
return [('sale_ok', '=', True), ('website_id', 'in', (False, 1))]
|
Reference in New Issue
Block a user