[ADD]GOLEM Activities first commit with form view, menu, seasons management, places, animatir etc
This commit is contained in:
parent
e537201606
commit
39350b72fa
18
golem_activity/__init__.py
Normal file
18
golem_activity/__init__.py
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
# Copyright 2016 Fabien Bourgeois <fabien@yaltik.com>
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU Affero General Public License as
|
||||||
|
# published by the Free Software Foundation, either version 3 of the
|
||||||
|
# License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU Affero General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
from . import models
|
35
golem_activity/__openerp__.py
Normal file
35
golem_activity/__openerp__.py
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
# Copyright 2016 Fabien Bourgeois <fabien@yaltik.com>
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU Affero General Public License as
|
||||||
|
# published by the Free Software Foundation, either version 3 of the
|
||||||
|
# License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU Affero General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
{
|
||||||
|
'name': 'GOLEM activities',
|
||||||
|
'summary': 'Extends Odoo products for multi-activity',
|
||||||
|
'description': 'Multi-activities management',
|
||||||
|
'version': '0.1',
|
||||||
|
'category': 'Non-profit management',
|
||||||
|
'author': 'Fabien Bourgeois',
|
||||||
|
'license': 'AGPL-3',
|
||||||
|
'application': True,
|
||||||
|
'installable': True,
|
||||||
|
'depends': ['product',
|
||||||
|
'membership',
|
||||||
|
'mail',
|
||||||
|
'l10n_fr_tax_sale_ttc',
|
||||||
|
'l10n_fr_siret',
|
||||||
|
'golem_season'],
|
||||||
|
'data': ['views/golem_activity_view.xml']
|
||||||
|
}
|
18
golem_activity/models/__init__.py
Normal file
18
golem_activity/models/__init__.py
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
# Copyright 2016 Fabien Bourgeois <fabien@yaltik.com>
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU Affero General Public License as
|
||||||
|
# published by the Free Software Foundation, either version 3 of the
|
||||||
|
# License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU Affero General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
from . import golem_activity
|
102
golem_activity/models/golem_activity.py
Normal file
102
golem_activity/models/golem_activity.py
Normal file
@ -0,0 +1,102 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
# Copyright 2016 Fabien Bourgeois <fabien@yaltik.com>
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU Affero General Public License as
|
||||||
|
# published by the Free Software Foundation, either version 3 of the
|
||||||
|
# License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU Affero General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
from openerp import models, fields, api, _
|
||||||
|
|
||||||
|
|
||||||
|
class ProductTemplate(models.Model):
|
||||||
|
_inherit = 'product.template'
|
||||||
|
|
||||||
|
# Make default service for type
|
||||||
|
type = fields.Selection([('consu', 'Consumable'), ('service', 'Service')],
|
||||||
|
'Product Type', default='service', required=True,
|
||||||
|
help="Consumable are product where you don't "
|
||||||
|
"manage stock, a service is a non-material "
|
||||||
|
"product provided by a company or an individual.")
|
||||||
|
|
||||||
|
|
||||||
|
class GolemActivity(models.Model):
|
||||||
|
_name = 'golem.activity'
|
||||||
|
_description = 'GOLEM Activity'
|
||||||
|
_inherit = 'mail.thread'
|
||||||
|
_inherits = {'product.template': 'product_id'}
|
||||||
|
|
||||||
|
season_id = fields.Many2one('golem.season', string='Seasons',
|
||||||
|
required=True)
|
||||||
|
animator = fields.Many2one('res.partner', string="Animator",
|
||||||
|
domain=[('is_company', '=', False)])
|
||||||
|
places = fields.Integer('Places', default=0)
|
||||||
|
is_surcharged = fields.Boolean('Allow surcharge?', default=False)
|
||||||
|
places_surcharged = fields.Integer('Places with surcharge', default=0)
|
||||||
|
|
||||||
|
@api.onchange('is_surcharged', 'places')
|
||||||
|
def onchange_is_surcharged(self):
|
||||||
|
for a in self:
|
||||||
|
if a.places and a.is_surcharged:
|
||||||
|
if not a.places_surcharged or (a.places_surcharged < a.places):
|
||||||
|
a.places_surcharged = a.places
|
||||||
|
|
||||||
|
@api.constrains('places', 'places_surcharged')
|
||||||
|
def _check_places(self):
|
||||||
|
""" Check integers are signed and surcharged to be superior than
|
||||||
|
normal places """
|
||||||
|
for v in self:
|
||||||
|
for f in ['places', 'places_surcharged']:
|
||||||
|
if v[f] < 0:
|
||||||
|
emsg = _('Number of places cannot be negative.')
|
||||||
|
raise models.ValidationError(emsg)
|
||||||
|
if v.places < v.places_surcharged:
|
||||||
|
emsg = _('Surcharged places cannot be inferieur than places')
|
||||||
|
raise models.ValidationError(emsg)
|
||||||
|
|
||||||
|
date_start = fields.Date('Start date')
|
||||||
|
date_end = fields.Date('End date')
|
||||||
|
|
||||||
|
@api.constrains('date_start', 'date_end')
|
||||||
|
def _check_period(self):
|
||||||
|
""" Check if end date if after start date """
|
||||||
|
for a in self:
|
||||||
|
if a.date_start > a.date_end:
|
||||||
|
raise models.ValidationError(_('Start of the period cannot be '
|
||||||
|
'after end of the period.'))
|
||||||
|
|
||||||
|
@api.onchange('type')
|
||||||
|
def onchange_type(self):
|
||||||
|
""" Force service as type """
|
||||||
|
for a in self:
|
||||||
|
self.type = 'service'
|
||||||
|
|
||||||
|
@api.onchange('season_id')
|
||||||
|
def onchange_season_dates(self):
|
||||||
|
""" Sets defaults dates according to season """
|
||||||
|
for a in self:
|
||||||
|
if a.season_id:
|
||||||
|
if not a.date_start:
|
||||||
|
a.date_start = a.season_id.date_start
|
||||||
|
if not a.date_end:
|
||||||
|
a.date_end = a.season_id.date_end
|
||||||
|
|
||||||
|
is_current = fields.Boolean('Current season?', store=True, default=False,
|
||||||
|
compute='_compute_is_current')
|
||||||
|
|
||||||
|
@api.depends('season_id')
|
||||||
|
def _compute_is_current(self):
|
||||||
|
""" Checks if activity is active for current season """
|
||||||
|
domain = [('is_default', '=', True)]
|
||||||
|
default_season = self.env['golem.season'].search(domain)
|
||||||
|
for a in self:
|
||||||
|
a.is_current = (default_season == a.season_id)
|
120
golem_activity/views/golem_activity_view.xml
Normal file
120
golem_activity/views/golem_activity_view.xml
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
Copyright 2016 Fabien Bourgeois <fabien@yaltik.com>
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
-->
|
||||||
|
<openerp>
|
||||||
|
<data>
|
||||||
|
|
||||||
|
<!-- Forms -->
|
||||||
|
<record id="view_form" model="ir.ui.view">
|
||||||
|
<field name="name">GOLEM Activity Form</field>
|
||||||
|
<field name="model">golem.activity</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<form>
|
||||||
|
<sheet>
|
||||||
|
<group>
|
||||||
|
<div class="oe_left" style="width: 500px;">
|
||||||
|
<field name="image_medium" widget="image"
|
||||||
|
class="oe_avatar oe_left"/>
|
||||||
|
<div class="oe_title" style="width: 390px;">
|
||||||
|
<label class="oe_edit_only" for="name" string="Activity Name"/>
|
||||||
|
<h1><field name="name" class="oe_inline"/></h1>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<group>
|
||||||
|
<field name="season_id" />
|
||||||
|
</group>
|
||||||
|
</group>
|
||||||
|
<group string="Details" col="4">
|
||||||
|
<group colspan="2">
|
||||||
|
<field name="default_code" />
|
||||||
|
<field name="animator" />
|
||||||
|
<field name="list_price" />
|
||||||
|
</group>
|
||||||
|
<group colspan="2">
|
||||||
|
<field name="places" />
|
||||||
|
<field name="is_surcharged" />
|
||||||
|
<field name="places_surcharged"
|
||||||
|
attrs="{'invisible': [('is_surcharged', '=', False)]}" />
|
||||||
|
<field name="date_start" />
|
||||||
|
<field name="date_end" />
|
||||||
|
</group>
|
||||||
|
</group>
|
||||||
|
<notebook>
|
||||||
|
<page name="activity_info" string="Information">
|
||||||
|
<group colspan="4">
|
||||||
|
<group>
|
||||||
|
<field name="active"/>
|
||||||
|
</group>
|
||||||
|
</group>
|
||||||
|
<group colspan="4">
|
||||||
|
<field name="description" placeholder="describe the activity characteristics..."/>
|
||||||
|
</group>
|
||||||
|
</page>
|
||||||
|
<page name="activity_details" string="Others">
|
||||||
|
<group>
|
||||||
|
<group>
|
||||||
|
<field name="type" />
|
||||||
|
<field name="active" />
|
||||||
|
</group>
|
||||||
|
</group>
|
||||||
|
</page>
|
||||||
|
</notebook>
|
||||||
|
</sheet>
|
||||||
|
<div class="oe_chatter">
|
||||||
|
<field name="message_follower_ids" widget="mail_followers" />
|
||||||
|
<field name="message_ids" widget="mail_thread" />
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<!-- Searches -->
|
||||||
|
<record id="view_filter" model="ir.ui.view">
|
||||||
|
<field name="name">GOLEM Activity Filters</field>
|
||||||
|
<field name="model">golem.activity</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<search>
|
||||||
|
<field name="name" />
|
||||||
|
<field name="season_id" widget="many2one" />
|
||||||
|
<filter name="season_default" string="Default season"
|
||||||
|
domain="[('is_current', '=', True)]" />
|
||||||
|
</search>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Actions -->
|
||||||
|
<act_window id="action"
|
||||||
|
name="GOLEM Activities"
|
||||||
|
res_model="golem.activity"
|
||||||
|
view_mode="kanban,tree,form"
|
||||||
|
context="{'search_default_season_default': True}" />
|
||||||
|
<record model="ir.actions.act_window.view" id="act_view_kanban">
|
||||||
|
<field name="view_mode">kanban</field>
|
||||||
|
<field name="view_id" ref="product.product_template_kanban_view"/>
|
||||||
|
<field name="act_window_id" ref="action"/>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<!-- Menus -->
|
||||||
|
<menuitem id="activity_menu" name="Activities"
|
||||||
|
parent="base.menu_association" sequence="5" />
|
||||||
|
<menuitem id="activity_list" name="List"
|
||||||
|
parent="activity_menu" sequence="0"
|
||||||
|
action="action" />
|
||||||
|
|
||||||
|
</data>
|
||||||
|
</openerp>
|
@ -64,4 +64,5 @@ class GolemSeason(models.Model):
|
|||||||
if old_default_season:
|
if old_default_season:
|
||||||
old_default_season.is_default = False
|
old_default_season.is_default = False
|
||||||
self.env['golem.member'].search([])._compute_is_current()
|
self.env['golem.member'].search([])._compute_is_current()
|
||||||
|
self.env['product.template'].search([])._golem_compute_is_current()
|
||||||
return res
|
return res
|
||||||
|
Loading…
Reference in New Issue
Block a user