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
[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
6 changed files with 121 additions and 2 deletions
-
14beesdoo_shift/models/cooperative_status.py
-
2beesdoo_shift_welcome_screen/__init__.py
-
23beesdoo_shift_welcome_screen/__openerp__.py
-
2beesdoo_shift_welcome_screen/models/__init__.py
-
39beesdoo_shift_welcome_screen/models/welcome.py
-
43beesdoo_shift_welcome_screen/views/welcome.xml
@ -0,0 +1,2 @@ |
|||
# -*- coding: utf-8 -*- |
|||
import models |
@ -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", |
|||
], |
|||
} |
@ -0,0 +1,2 @@ |
|||
# -*- coding: utf-8 -*- |
|||
import welcome |
@ -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 |
@ -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> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue