forked from Yaltik/golem
[IMP]GOLEM Activity : new fields, enhancements in namings, default name...
This commit is contained in:
parent
af825ab8ba
commit
03ed5e1719
@ -22,11 +22,7 @@ class ProductTemplate(models.Model):
|
|||||||
_inherit = 'product.template'
|
_inherit = 'product.template'
|
||||||
|
|
||||||
# Make default service for type
|
# Make default service for type
|
||||||
type = fields.Selection([('consu', 'Consumable'), ('service', 'Service')],
|
type = fields.Selection(default='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):
|
class GolemActivity(models.Model):
|
||||||
@ -34,33 +30,34 @@ class GolemActivity(models.Model):
|
|||||||
_description = 'GOLEM Activity'
|
_description = 'GOLEM Activity'
|
||||||
_inherit = 'mail.thread'
|
_inherit = 'mail.thread'
|
||||||
_inherits = {'product.template': 'product_id'}
|
_inherits = {'product.template': 'product_id'}
|
||||||
|
_rec_name = 'activity_name'
|
||||||
|
|
||||||
season_id = fields.Many2one('golem.season', string='Seasons',
|
season_id = fields.Many2one('golem.season', string='Seasons',
|
||||||
required=True)
|
required=True)
|
||||||
animator = fields.Many2one('res.partner', string="Animator",
|
animator_id = fields.Many2one('res.partner', string="Animator",
|
||||||
domain=[('is_company', '=', False)])
|
domain=[('is_company', '=', False)])
|
||||||
places = fields.Integer('Places', default=0)
|
places = fields.Integer('Places', default=0)
|
||||||
is_surcharged = fields.Boolean('Allow surcharge?', default=False)
|
is_overbooked = fields.Boolean('Allow overbook?', default=False)
|
||||||
places_surcharged = fields.Integer('Places with surcharge', default=0)
|
places_overbooked = fields.Integer('Places with overbook', default=0)
|
||||||
|
|
||||||
@api.onchange('is_surcharged', 'places')
|
@api.onchange('is_overbooked', 'places')
|
||||||
def onchange_is_surcharged(self):
|
def onchange_is_overbooked(self):
|
||||||
for a in self:
|
for a in self:
|
||||||
if a.places and a.is_surcharged:
|
if a.places and a.is_overbooked:
|
||||||
if not a.places_surcharged or (a.places_surcharged < a.places):
|
if not a.places_overbooked or (a.places_overbooked < a.places):
|
||||||
a.places_surcharged = a.places
|
a.places_overbooked = a.places + 1
|
||||||
|
|
||||||
@api.constrains('places', 'places_surcharged')
|
@api.constrains('places', 'places_overbooked')
|
||||||
def _check_places(self):
|
def _check_places(self):
|
||||||
""" Check integers are signed and surcharged to be superior than
|
""" Check integers are signed and overbooked to be superior than
|
||||||
normal places """
|
normal places """
|
||||||
for v in self:
|
for v in self:
|
||||||
for f in ['places', 'places_surcharged']:
|
for f in ['places', 'places_overbooked']:
|
||||||
if v[f] < 0:
|
if v[f] < 0:
|
||||||
emsg = _('Number of places cannot be negative.')
|
emsg = _('Number of places cannot be negative.')
|
||||||
raise models.ValidationError(emsg)
|
raise models.ValidationError(emsg)
|
||||||
if v.places < v.places_surcharged:
|
if v.is_overbooked and (v.places_overbooked <= v.places):
|
||||||
emsg = _('Surcharged places cannot be inferieur than places')
|
emsg = _('Overbooked places cannot be inferior than places')
|
||||||
raise models.ValidationError(emsg)
|
raise models.ValidationError(emsg)
|
||||||
|
|
||||||
date_start = fields.Date('Start date')
|
date_start = fields.Date('Start date')
|
||||||
@ -100,3 +97,16 @@ class GolemActivity(models.Model):
|
|||||||
default_season = self.env['golem.season'].search(domain)
|
default_season = self.env['golem.season'].search(domain)
|
||||||
for a in self:
|
for a in self:
|
||||||
a.is_current = (default_season == a.season_id)
|
a.is_current = (default_season == a.season_id)
|
||||||
|
|
||||||
|
activity_name = fields.Char('Name', compute='_compute_name', store=True,
|
||||||
|
index=True)
|
||||||
|
|
||||||
|
@api.depends('name', 'default_code')
|
||||||
|
def _compute_name(self):
|
||||||
|
""" Provide a better displayed name """
|
||||||
|
for a in self:
|
||||||
|
activity_name = unicode(a.name)
|
||||||
|
if a.default_code:
|
||||||
|
activity_name = u'[{}] {}'.format(a.default_code,
|
||||||
|
activity_name)
|
||||||
|
a.activity_name = activity_name
|
||||||
|
@ -25,7 +25,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<form>
|
<form>
|
||||||
<sheet>
|
<sheet>
|
||||||
<group>
|
<div class="oe_right oe_button_box" style="width: 300px;"
|
||||||
|
name="buttons"></div>
|
||||||
<div class="oe_left" style="width: 500px;">
|
<div class="oe_left" style="width: 500px;">
|
||||||
<field name="image_medium" widget="image"
|
<field name="image_medium" widget="image"
|
||||||
class="oe_avatar oe_left"/>
|
class="oe_avatar oe_left"/>
|
||||||
@ -37,29 +38,24 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
<group>
|
<group>
|
||||||
<field name="season_id" />
|
<field name="season_id" />
|
||||||
</group>
|
</group>
|
||||||
</group>
|
|
||||||
<group string="Details" col="4">
|
<group string="Details" col="4">
|
||||||
<group colspan="2">
|
<group colspan="2">
|
||||||
<field name="default_code" />
|
<field name="default_code" />
|
||||||
<field name="animator" />
|
<field name="categ_id" />
|
||||||
|
<field name="animator_id" />
|
||||||
<field name="list_price" />
|
<field name="list_price" />
|
||||||
</group>
|
</group>
|
||||||
<group colspan="2">
|
<group colspan="2">
|
||||||
<field name="places" />
|
<field name="places" />
|
||||||
<field name="is_surcharged" />
|
<field name="is_overbooked" />
|
||||||
<field name="places_surcharged"
|
<field name="places_overbooked"
|
||||||
attrs="{'invisible': [('is_surcharged', '=', False)]}" />
|
attrs="{'invisible': [('is_overbooked', '=', False)]}" />
|
||||||
<field name="date_start" />
|
<field name="date_start" />
|
||||||
<field name="date_end" />
|
<field name="date_end" />
|
||||||
</group>
|
</group>
|
||||||
</group>
|
</group>
|
||||||
<notebook>
|
<notebook>
|
||||||
<page name="activity_info" string="Information">
|
<page name="activity_info" string="Information">
|
||||||
<group colspan="4">
|
|
||||||
<group>
|
|
||||||
<field name="active"/>
|
|
||||||
</group>
|
|
||||||
</group>
|
|
||||||
<group colspan="4">
|
<group colspan="4">
|
||||||
<field name="description" placeholder="describe the activity characteristics..."/>
|
<field name="description" placeholder="describe the activity characteristics..."/>
|
||||||
</group>
|
</group>
|
||||||
@ -88,7 +84,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
<field name="model">golem.activity</field>
|
<field name="model">golem.activity</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<search>
|
<search>
|
||||||
<field name="name" />
|
<field name="activity_name" />
|
||||||
<field name="season_id" widget="many2one" />
|
<field name="season_id" widget="many2one" />
|
||||||
<filter name="season_default" string="Default season"
|
<filter name="season_default" string="Default season"
|
||||||
domain="[('is_current', '=', True)]" />
|
domain="[('is_current', '=', True)]" />
|
||||||
@ -98,16 +94,25 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
|
|
||||||
|
|
||||||
<!-- Actions -->
|
<!-- Actions -->
|
||||||
<act_window id="action"
|
<record id="action" model="ir.actions.act_window">
|
||||||
name="GOLEM Activities"
|
<field name="name">GOLEM Activities</field>
|
||||||
res_model="golem.activity"
|
<field name="res_model">golem.activity</field>
|
||||||
view_mode="kanban,tree,form"
|
<field name="view_mode">kanban,tree,form</field>
|
||||||
context="{'search_default_season_default': True}" />
|
<field name="domain" eval="[('categ_id', 'child_of', ref('golem_activity.golem_product_category_all_activities'))]" />
|
||||||
|
<field name="context"
|
||||||
|
eval="{'search_default_season_default': True, 'default_categ_id': ref('golem_activity.golem_product_category_all_activities')}" />
|
||||||
|
</record>
|
||||||
<record model="ir.actions.act_window.view" id="act_view_kanban">
|
<record model="ir.actions.act_window.view" id="act_view_kanban">
|
||||||
<field name="view_mode">kanban</field>
|
<field name="view_mode">kanban</field>
|
||||||
<field name="view_id" ref="product.product_template_kanban_view"/>
|
<field name="view_id" ref="product.product_template_kanban_view"/>
|
||||||
<field name="act_window_id" ref="action"/>
|
<field name="act_window_id" ref="action"/>
|
||||||
</record>
|
</record>
|
||||||
|
<record id="category_action" model="ir.actions.act_window">
|
||||||
|
<field name="name">Activities Categories</field>
|
||||||
|
<field name="res_model">product.category</field>
|
||||||
|
<field name="view_type">form</field>
|
||||||
|
<field name="view_id" ref="product.product_category_list_view" />
|
||||||
|
</record>
|
||||||
|
|
||||||
<!-- Menus -->
|
<!-- Menus -->
|
||||||
<menuitem id="activity_menu" name="Activities"
|
<menuitem id="activity_menu" name="Activities"
|
||||||
@ -115,6 +120,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
<menuitem id="activity_list" name="List"
|
<menuitem id="activity_list" name="List"
|
||||||
parent="activity_menu" sequence="0"
|
parent="activity_menu" sequence="0"
|
||||||
action="action" />
|
action="action" />
|
||||||
|
<menuitem id="activity_categ" name="Activities categories"
|
||||||
|
parent="activity_menu" sequence="10"
|
||||||
|
action="category_action" />
|
||||||
|
|
||||||
</data>
|
</data>
|
||||||
</openerp>
|
</openerp>
|
||||||
|
Loading…
Reference in New Issue
Block a user