Browse Source

[WIP] welcome screen: add a new field on partner can_shop, add the new screen codebar capable field

9.0-shift6-welcome_screen-tfr
Thibault Francois 7 years ago
parent
commit
da6fddbda9
  1. 14
      beesdoo_shift/models/cooperative_status.py
  2. 2
      beesdoo_shift_welcome_screen/__init__.py
  3. 23
      beesdoo_shift_welcome_screen/__openerp__.py
  4. 2
      beesdoo_shift_welcome_screen/models/__init__.py
  5. 39
      beesdoo_shift_welcome_screen/models/welcome.py
  6. 43
      beesdoo_shift_welcome_screen/views/welcome.xml

14
beesdoo_shift/models/cooperative_status.py

@ -139,7 +139,7 @@ class CooperativeStatus(models.Model):
#Check for holidays; Can be in holidays even in alert or other mode ? #Check for holidays; Can be in holidays even in alert or other mode ?
elif self.today >= self.holiday_start_time and self.today <= self.holiday_end_time: elif self.today >= self.holiday_start_time and self.today <= self.holiday_end_time:
self.status = 'holiday' self.status = 'holiday'
self.can_shop = True
self.can_shop = False
elif ok or (not self.alert_start_time and self.sr >= 0): elif ok or (not self.alert_start_time and self.sr >= 0):
self.status = 'ok' self.status = 'ok'
self.can_shop = True self.can_shop = True
@ -172,7 +172,7 @@ class CooperativeStatus(models.Model):
#Check for holidays; Can be in holidays even in alert or other mode ? #Check for holidays; Can be in holidays even in alert or other mode ?
elif self.today >= self.holiday_start_time and self.today <= self.holiday_end_time: elif self.today >= self.holiday_start_time and self.today <= self.holiday_end_time:
self.status = 'holiday' self.status = 'holiday'
self.can_shop = True
self.can_shop = False
elif ok or (not self.alert_start_time and self.sr >= 0): elif ok or (not self.alert_start_time and self.sr >= 0):
self.status = 'ok' self.status = 'ok'
self.can_shop = True self.can_shop = True
@ -305,6 +305,16 @@ class ResPartner(models.Model):
state = fields.Selection(related='cooperative_status_ids.status', readonly=True, store=True) state = fields.Selection(related='cooperative_status_ids.status', readonly=True, store=True)
extension_start_time = fields.Date(related='cooperative_status_ids.extension_start_time', string="Extension Start Day", readonly=True, store=True) extension_start_time = fields.Date(related='cooperative_status_ids.extension_start_time', string="Extension Start Day", readonly=True, store=True)
subscribed_shift_ids = fields.Many2many('beesdoo.shift.template') subscribed_shift_ids = fields.Many2many('beesdoo.shift.template')
can_shop = fields.Boolean(compute="_get_can_shop")
@api.multi
def _get_can_shop(self):
for rec in self:
can_shop = False
if rec.cooperator_type in ('share_a', 'share_b'):
if rec.cooperative_status_ids:
can_shop = rec.cooperative_status_ids[0].can_shop
rec.can_shop = can_shop
@api.multi @api.multi
def coop_subscribe(self): def coop_subscribe(self):

2
beesdoo_shift_welcome_screen/__init__.py

@ -0,0 +1,2 @@
# -*- coding: utf-8 -*-
import models

23
beesdoo_shift_welcome_screen/__openerp__.py

@ -0,0 +1,23 @@
# -*- coding: utf-8 -*-
{
'name': "Beescoop Shift Management - Welcome Screen",
'summary': """
Volonteer Timetable Management""",
'description': """
""",
'author': "Thibault Francois",
'website': "https://github.com/beescoop/Obeesdoo",
'category': 'Cooperative management',
'version': '0.1',
'depends': ['beesdoo_shift', 'barcodes'],
'data': [
"views/welcome.xml",
],
}

2
beesdoo_shift_welcome_screen/models/__init__.py

@ -0,0 +1,2 @@
# -*- coding: utf-8 -*-
import welcome

39
beesdoo_shift_welcome_screen/models/welcome.py

@ -0,0 +1,39 @@
# -*- coding: utf-8 -*-
from openerp import models, fields, api, _
from openerp.exceptions import UserError
class TaskType(models.TransientModel):
_name = 'beesdoo.shift.welcome'
_inherit = ['barcodes.barcode_events_mixin']
partner_id = fields.Many2one('res.partner', string="Cooperator")
message = fields.Html("Message")
can_shop = fields.Boolean(related='partner_id.can_shop', readonly=True)
def on_barcode_scanned(self, barcode):
self._barcode_scanned = ''
self.message = ''
if barcode.startswith('42'):
barcode = '0' + barcode
if not barcode.startswith('042'):
self.message = 'invalid barcode'
return
#0 at the begining of the code bar seems not to be scanned
partner_ids = self.env['res.partner'].search([('barcode', '=', barcode)])
if not partner_ids:
self.message = "Member does not exist"
elif len(partner_ids) > 1:
self.message = "more then one member found with this barcode"
else:
self.partner_id = partner_ids[0]
@api.onchange('partner_id')
def _onchange_partner(self):
values = {
'rec': self
}
html_res = self.env.ref("beesdoo_shift_welcome_screen.welcome_message").render(values)
self.message = html_res

43
beesdoo_shift_welcome_screen/views/welcome.xml

@ -0,0 +1,43 @@
<odoo>
<record model="ir.actions.act_window" id="action_welcome">
<field name="name">Shift Type</field>
<field name="res_model">beesdoo.shift.welcome</field>
<field name="view_mode">form</field>
<field name="target">inline</field>
</record>
<menuitem name="Shift Welcome" id="menu_root" action="action_welcome"
groups="beesdoo_shift.group_shift_attendance" />
<record model="ir.ui.view" id="shift_welcome_screen_view_form">
<field name="name">Shift Welcome Screen</field>
<field name="model">beesdoo.shift.welcome</field>
<field name="arch" type="xml">
<form>
<sheet>
<field name="_barcode_scanned" widget="barcode_handler" />
<separator string="Cooperator" />
<h1>
<field name="partner_id" />
</h1>
<group>
<field name="can_shop" />
</group>
<field name="message" readonly="1"/>
</sheet>
</form>
</field>
</record>
<template id="welcome_message" name="Welcome Message">
<img t-attf-src="data:image/*;base64,{{rec.partner_id.image}}" />
<t t-if="rec.can_shop">
<h1><font style="background-color: rgb(0, 255, 0); font-size: 24px;">Can shop</font></h1>
</t>
<t t-if="not rec.can_shop">
<h1><font style="background-color: rgb(255, 0, 0); font-size: 24px;">Cannot shop</font></h1>
</t>
</template>
</odoo>
Loading…
Cancel
Save