Browse Source

[MERGE][S0012] Gestion d'impression des BEES card de membres

pull/13/head
Thibault Francois 9 years ago
parent
commit
1ead5626c6
  1. 2
      beesdoo_base/__openerp__.py
  2. 7
      beesdoo_base/models/partner.py
  3. 7
      beesdoo_base/views/partner.xml
  4. 3
      beesdoo_base/wizard/__init__.py
  5. 52
      beesdoo_base/wizard/member_card.py
  6. 23
      beesdoo_base/wizard/new_member_card.py
  7. 82
      beesdoo_base/wizard/views/member_card.xml
  8. 24
      beesdoo_base/wizard/views/new_member_card.xml

2
beesdoo_base/__openerp__.py

@ -21,6 +21,6 @@
'security/groups.xml', 'security/groups.xml',
'security/ir.model.access.csv', 'security/ir.model.access.csv',
'views/partner.xml', 'views/partner.xml',
'wizard/views/new_member_card.xml',
'wizard/views/member_card.xml',
], ],
} }

7
beesdoo_base/models/partner.py

@ -3,8 +3,6 @@ from openerp import models, fields, api, _
from openerp.exceptions import ValidationError from openerp.exceptions import ValidationError
from openerp.addons.beesdoo_base.tools import concat_names from openerp.addons.beesdoo_base.tools import concat_names
class Partner(models.Model): class Partner(models.Model):
_inherit = 'res.partner' _inherit = 'res.partner'
@ -19,6 +17,9 @@ class Partner(models.Model):
parent_barcode = fields.Char(compute="_get_bar_code", string='Parent Bar Code', store=True) parent_barcode = fields.Char(compute="_get_bar_code", string='Parent Bar Code', store=True)
member_card_ids = fields.One2many('member.card', 'partner_id') member_card_ids = fields.One2many('member.card', 'partner_id')
member_card_to_be_printed = fields.Boolean('Print BEES card?')
last_printed = fields.Datetime('Last printed on')
@api.onchange('first_name', 'last_name') @api.onchange('first_name', 'last_name')
def _on_change_name(self): def _on_change_name(self):
self.name = concat_names(self.first_name, self.last_name) self.name = concat_names(self.first_name, self.last_name)
@ -72,3 +73,5 @@ class Partner(models.Model):
res = super(Partner, self)._auto_init(cr, context=context) res = super(Partner, self)._auto_init(cr, context=context)
cr.execute("UPDATE res_partner set last_name = name where last_name IS NULL") cr.execute("UPDATE res_partner set last_name = name where last_name IS NULL")
return res return res

7
beesdoo_base/views/partner.xml

@ -27,6 +27,11 @@
<xpath expr="//notebook" position="inside"> <xpath expr="//notebook" position="inside">
<page string="Carte de Membre" <page string="Carte de Membre"
attrs="{'invisible': ['|', ('customer', '=', False), ('eater', '!=', 'worker_eater')]}"> attrs="{'invisible': ['|', ('customer', '=', False), ('eater', '!=', 'worker_eater')]}">
<separator string="Printing" />
<group>
<field name="member_card_to_be_printed" />
<field name="last_printed" />
</group>
<separator string="Mangeurs" /> <separator string="Mangeurs" />
<field name="child_eater_ids" widget="many2many_tags" /> <field name="child_eater_ids" widget="many2many_tags" />
<separator string="Cartes" /> <separator string="Cartes" />
@ -64,4 +69,4 @@
'default_company_type' : 'company', } 'default_company_type' : 'company', }
</field> </field>
</record> </record>
</odoo>
</odoo>

3
beesdoo_base/wizard/__init__.py

@ -1 +1,2 @@
import new_member_card
import member_card

52
beesdoo_base/wizard/member_card.py

@ -0,0 +1,52 @@
# -*- coding: utf-8 -*-
from openerp import models, fields, api
class NewMemberCardWizard(models.TransientModel):
"""
A transient model for the creation of a new card.
The user can only define the raison why a new card is
needed and the eater/worker that is concerned.
"""
_name = 'membercard.new.wizard'
def _get_default_partner(self):
return self.env.context['active_id']
new_comment = fields.Text('Reason', required=True)
partner_id = fields.Many2one('res.partner', default=_get_default_partner)
force_barcode = fields.Char('Force Barcode', groups="beesdoo_base.group_force_barcode")
@api.one
def create_new_card(self):
client = self.partner_id.sudo()
client._deactivate_active_cards()
client._new_card(self.new_comment, self.env.uid, barcode=self.force_barcode)
class RequestMemberCardPrintingWizard(models.TransientModel):
_name = 'membercard.requestprinting.wizard'
def _get_selected_partners(self):
return self.env.context['active_ids']
partner_ids = fields.Many2many('res.partner', default=_get_selected_partners)
@api.one
def request_printing(self):
self.partner_ids.write({'member_card_to_be_printed' : True})
class SetAsPrintedWizard(models.TransientModel):
_name = 'membercard.set_as_printed.wizard'
def _get_selected_partners(self):
return self.env.context['active_ids']
partner_ids = fields.Many2many('res.partner', default=_get_selected_partners)
@api.one
def set_as_printed(self):
self.partner_ids.write({'member_card_to_be_printed' : False,
'last_printed' : fields.Datetime.now()})

23
beesdoo_base/wizard/new_member_card.py

@ -1,23 +0,0 @@
# -*- coding: utf-8 -*-
from openerp import models, fields, api
class NewMemberCardWizard(models.TransientModel):
"""
A transient model for the creation of a new card.
The user can only define the raison why a new card is
needed and the eater/worker that is concerned.
"""
_name = 'membercard.new.wizard'
def _get_default_partner(self):
return self.env.context['active_id']
new_comment = fields.Text('Reason', required=True)
partner_id = fields.Many2one('res.partner', default=_get_default_partner)
force_barcode = fields.Char('Force Barcode', groups="beesdoo_base.group_force_barcode")
@api.one
def create_new_card(self):
client = self.partner_id.sudo()
client._deactivate_active_cards()
client._new_card(self.new_comment, self.env.uid, barcode=self.force_barcode)

82
beesdoo_base/wizard/views/member_card.xml

@ -0,0 +1,82 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<!-- New card generation wizard -->
<record id="MemberCard Wizard" model="ir.ui.view">
<field name="name">New MemberCard Wizard</field>
<field name="model">membercard.new.wizard</field>
<field name="arch" type="xml">
<form>
<group groups="beesdoo_base.group_force_barcode">
<field name="force_barcode" />
</group>
<separator string="Reason" />
<field name="new_comment" string="Raison" editable="True" />
<field name="partner_id" invisible="1" />
<footer>
<button type="object" name="create_new_card" string="Créer"
class="oe_highlight" />
<button special="cancel" string="Annuler" />
</footer>
</form>
</field>
</record>
<record id="printing_membercard_request_wizard" model="ir.ui.view">
<field name="name">Request Membercard Printing Wizard</field>
<field name="model">membercard.requestprinting.wizard</field>
<field name="arch" type="xml">
<form>
<separator string="Request Printing for" />
<field name="partner_ids" />
<footer>
<button
type="object"
name="request_printing"
string="Request Beescard Printing"
class="oe_highlight" />
<button special="cancel" string="Cancel" />
</footer>
</form>
</field>
</record>
<act_window name="Request BEES card printing"
res_model="membercard.requestprinting.wizard"
src_model="res.partner"
view_mode="form"
target="new"
key2="client_action_multi"
id="beesdoo_base_action_request_membercard_printing"
/>
<record id="membercard_set_as_printed_wizard" model="ir.ui.view">
<field name="name">Set Membercard as Printed Wizard</field>
<field name="model">membercard.set_as_printed.wizard</field>
<field name="arch" type="xml">
<form>
<separator string="Set as Printed for" />
<field name="partner_ids" />
<footer>
<button
type="object"
name="set_as_printed"
string="Set as Printed"
class="oe_highlight" />
<button special="cancel" string="Cancel" />
</footer>
</form>
</field>
</record>
<act_window name="Set BEES card as printed"
res_model="membercard.set_as_printed.wizard"
src_model="res.partner"
view_mode="form"
target="new"
key2="client_action_multi"
id="beesdoo_base_action_set_membercard_as_printed"
/>
</odoo>

24
beesdoo_base/wizard/views/new_member_card.xml

@ -1,24 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="MemberCard Wizard" model="ir.ui.view">
<field name="name">New MemberCard Wizard</field>
<field name="model">membercard.new.wizard</field>
<field name="arch" type="xml">
<form>
<group groups="beesdoo_base.group_force_barcode">
<field name="force_barcode" />
</group>
<separator string="Reason" />
<field name="new_comment" string="Raison" editable="True" />
<field name="partner_id" invisible="1" />
<footer>
<button type="object" name="create_new_card" string="Créer"
class="oe_highlight" />
<button special="cancel" string="Annuler" />
</footer>
</form>
</field>
</record>
</odoo>
Loading…
Cancel
Save