Browse Source

add actions for request_membercard_printing and set_membercard_as_printed with a wizard, a view and an action in model for each

pull/11/head
gregoire 9 years ago
parent
commit
3d62e9700b
  1. 2
      beesdoo_base/__openerp__.py
  2. 12
      beesdoo_base/models/partner.py
  3. 9
      beesdoo_base/views/partner.xml
  4. 4
      beesdoo_base/wizard/__init__.py
  5. 2
      beesdoo_base/wizard/new_member_card.py
  6. 17
      beesdoo_base/wizard/request_membercard_printing.py
  7. 17
      beesdoo_base/wizard/set_membercard_as_printed.py
  8. 2
      beesdoo_base/wizard/views/new_member_card.xml
  9. 29
      beesdoo_base/wizard/views/request_membercard_printing.xml
  10. 28
      beesdoo_base/wizard/views/set_membercard_as_printed.xml

2
beesdoo_base/__openerp__.py

@ -21,5 +21,7 @@
'security/ir.model.access.csv',
'views/partner.xml',
'wizard/views/new_member_card.xml',
'wizard/views/request_membercard_printing.xml',
'wizard/views/set_membercard_as_printed.xml',
],
}

12
beesdoo_base/models/partner.py

@ -2,6 +2,7 @@
from openerp import models, fields, api, _
from openerp.exceptions import ValidationError
from openerp.addons.beesdoo_base.tools import concat_names
import datetime
@ -18,6 +19,7 @@ class Partner(models.Model):
barcode = fields.Char(compute="_get_bar_code", string='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_to_be_printed = fields.Boolean('Print BEES card?')
last_printed = fields.Datetime('Last printed on')
@ -67,3 +69,13 @@ class Partner(models.Model):
res = super(Partner, self)._auto_init(cr, context=context)
cr.execute("UPDATE res_partner set last_name = name where last_name IS NULL")
return res
@api.one
def _request_membercard_printing(self):
self.member_card_to_be_printed = True
@api.one
def _set_membercard_as_printed(self):
self.member_card_to_be_printed = False
print("datetime.now", datetime.datetime.now())
self.last_printed = datetime.datetime.now()

9
beesdoo_base/views/partner.xml

@ -23,12 +23,15 @@
<field name="eater"
attrs="{'invisible': [('company_type', '=', 'company')]}" />
<field name="parent_eater_id" attrs="{'invisible' : [('eater', '!=', 'eater')]}" />
<field name="member_card_to_be_printed"/>
<field name="last_printed"/>
</field>
<xpath expr="//notebook" position="inside">
<page string="Carte de Membre"
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" />
<field name="child_eater_ids" widget="many2many_tags" />
<separator string="Cartes" />
@ -66,4 +69,4 @@
'default_company_type' : 'company', }
</field>
</record>
</odoo>
</odoo>

4
beesdoo_base/wizard/__init__.py

@ -1 +1,3 @@
import new_member_card
import new_member_card
import request_membercard_printing
import set_membercard_as_printed

2
beesdoo_base/wizard/new_member_card.py

@ -19,4 +19,4 @@ class NewMemberCardWizard(models.TransientModel):
def create_new_card(self):
client = self.partner_id.sudo()
client._deactivate_active_cards()
client._new_card(self.new_comment, self.env.uid)
client._new_card(self.new_comment, self.env.uid)

17
beesdoo_base/wizard/request_membercard_printing.py

@ -0,0 +1,17 @@
# -*- coding: utf-8 -*-
from openerp import models, fields, api
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):
for client in self.partner_ids:
client._request_membercard_printing()

17
beesdoo_base/wizard/set_membercard_as_printed.py

@ -0,0 +1,17 @@
# -*- coding: utf-8 -*-
from openerp import models, fields, api
class RequestMemberCardPrintingWizard(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):
for client in self.partner_ids:
client._set_membercard_as_printed()

2
beesdoo_base/wizard/views/new_member_card.xml

@ -17,5 +17,5 @@
</form>
</field>
</record>
</odoo>

29
beesdoo_base/wizard/views/request_membercard_printing.xml

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<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>
<field name="partner_ids" />
</form>
<footer>
<button
type="object"
name="request_printing"
string="Demander l'impression d'une carte de membre"
class="oe_highlight" />
<button special="cancel" string="Annuler" />
</footer>
</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"
/>
</odoo>

28
beesdoo_base/wizard/views/set_membercard_as_printed.xml

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="printing_membercard_request_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>
<field name="partner_ids" />
</form>
<footer>
<button
type="object"
name="set_as_printed"
string="Marquer les cartes de membre comme imprimées"
class="oe_highlight" />
<button special="cancel" string="Annuler" />
</footer>
</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>
Loading…
Cancel
Save