Browse Source
[MERGE] 9.0-activate-deactivate-card-Elise : 0003 - Carte BEES - Code à barre
pull/7/head
[MERGE] 9.0-activate-deactivate-card-Elise : 0003 - Carte BEES - Code à barre
pull/7/head
Thibault Francois
9 years ago
12 changed files with 110 additions and 34 deletions
-
1beesdoo_base/__init__.py
-
1beesdoo_base/__openerp__.py
-
2beesdoo_base/models/__init__.py
-
24beesdoo_base/models/membercard.py
-
29beesdoo_base/models/partner.py
-
24beesdoo_base/views/partner.xml
-
1beesdoo_base/wizard/__init__.py
-
22beesdoo_base/wizard/new_member_card.py
-
21beesdoo_base/wizard/views/new_member_card.xml
-
1beesdoo_project/models/task.py
@ -1,3 +1,4 @@ |
|||||
# -*- coding: utf-8 -*- |
# -*- coding: utf-8 -*- |
||||
import models |
import models |
||||
|
import wizard |
||||
import tools |
import tools |
@ -1 +1 @@ |
|||||
import partner |
|
||||
|
import partner, membercard |
@ -0,0 +1,24 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
from openerp import models, fields, api |
||||
|
import uuid |
||||
|
|
||||
|
class MemberCard(models.Model): |
||||
|
|
||||
|
def _get_current_user(self): |
||||
|
return self.env.uid |
||||
|
|
||||
|
def _compute_bar_code(self): |
||||
|
rule = self.env['barcode.rule'].search([('name', '=', 'Customer Barcodes')])[0] |
||||
|
size = 13 - len(rule.pattern) |
||||
|
ean = rule.pattern + str(uuid.uuid4().fields[-1])[:size] |
||||
|
return ean[0:12] + str(self.env['barcode.nomenclature'].ean_checksum(ean)) |
||||
|
|
||||
|
_name = 'member.card' |
||||
|
_order = 'create_date desc' |
||||
|
|
||||
|
valid = fields.Boolean(default=True, string="Active") |
||||
|
barcode = fields.Char("Barcode", oldname='ean13', default=_compute_bar_code) |
||||
|
partner_id = fields.Many2one('res.partner') #, default=_get_current_client) |
||||
|
responsible_id = fields.Many2one('res.users', default=_get_current_user, string="Responsible") |
||||
|
end_date = fields.Date(readonly=True, string="Expiration Date") |
||||
|
comment = fields.Char("Reason", required=True) |
@ -0,0 +1 @@ |
|||||
|
import new_member_card |
@ -0,0 +1,22 @@ |
|||||
|
# -*- 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) |
||||
|
|
||||
|
@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) |
@ -0,0 +1,21 @@ |
|||||
|
<?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> |
||||
|
<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> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue