robin.keunen
5 years ago
11 changed files with 237 additions and 145 deletions
-
46beesdoo_base/__openerp__.py
-
58beesdoo_base/controllers/report.py
-
26beesdoo_base/models/membercard.py
-
124beesdoo_base/models/partner.py
-
30beesdoo_base/models/procurement.py
-
1beesdoo_base/wizard/__init__.py
-
47beesdoo_base/wizard/member_card.py
-
14beesdoo_base/wizard/partner.py
-
28beesdoo_base/wizard/portal_wizard.py
@ -1,30 +1,30 @@ |
|||
# -*- coding: utf-8 -*- |
|||
{ |
|||
'name': "Beescoop Base Module", |
|||
|
|||
'summary': """ |
|||
"name": "Beescoop Base Module", |
|||
"summary": """ |
|||
Module that customize the base module and contains some python tools |
|||
""", |
|||
|
|||
'description': """ |
|||
"description": """ |
|||
""", |
|||
|
|||
'author': "Beescoop - Cellule IT", |
|||
'website': "https://github.com/beescoop/Obeesdoo", |
|||
|
|||
'category': 'Project Management', |
|||
'version': '9.0.1.0.1', |
|||
|
|||
'depends': ['point_of_sale', 'purchase', 'report', 'portal', 'partner_firstname'], |
|||
|
|||
'data': [ |
|||
'security/groups.xml', |
|||
'security/ir.model.access.csv', |
|||
'data/cron.xml', |
|||
'views/partner.xml', |
|||
'wizard/views/member_card.xml', |
|||
'wizard/views/partner.xml', |
|||
'data/default_contact.xml', |
|||
'report/beescard.xml', |
|||
"author": "Beescoop - Cellule IT", |
|||
"website": "https://github.com/beescoop/Obeesdoo", |
|||
"category": "Project Management", |
|||
"version": "9.0.1.0.1", |
|||
"depends": [ |
|||
"point_of_sale", |
|||
"purchase", |
|||
"report", |
|||
"portal", |
|||
"partner_firstname", |
|||
], |
|||
"data": [ |
|||
"security/groups.xml", |
|||
"security/ir.model.access.csv", |
|||
"data/cron.xml", |
|||
"views/partner.xml", |
|||
"wizard/views/member_card.xml", |
|||
"wizard/views/partner.xml", |
|||
"data/default_contact.xml", |
|||
"report/beescard.xml", |
|||
], |
|||
} |
@ -1,2 +1 @@ |
|||
import member_card, partner, portal_wizard |
|||
|
@ -1,52 +1,67 @@ |
|||
# -*- 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' |
|||
|
|||
_name = "membercard.new.wizard" |
|||
|
|||
def _get_default_partner(self): |
|||
return self.env.context['active_id'] |
|||
return self.env.context["active_id"] |
|||
|
|||
new_comment = fields.Char('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") |
|||
new_comment = fields.Char("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) |
|||
client._new_card( |
|||
self.new_comment, self.env.uid, barcode=self.force_barcode |
|||
) |
|||
client.member_card_to_be_printed = True |
|||
|
|||
|
|||
class RequestMemberCardPrintingWizard(models.TransientModel): |
|||
|
|||
_name = 'membercard.requestprinting.wizard' |
|||
_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) |
|||
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}) |
|||
self.partner_ids.write({"member_card_to_be_printed": True}) |
|||
|
|||
|
|||
class SetAsPrintedWizard(models.TransientModel): |
|||
|
|||
_name = 'membercard.set_as_printed.wizard' |
|||
_name = "membercard.set_as_printed.wizard" |
|||
|
|||
def _get_selected_partners(self): |
|||
return self.env.context['active_ids'] |
|||
return self.env.context["active_ids"] |
|||
|
|||
partner_ids = fields.Many2many('res.partner', default=_get_selected_partners) |
|||
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()}) |
|||
self.partner_ids.write( |
|||
{ |
|||
"member_card_to_be_printed": False, |
|||
"last_printed": fields.Datetime.now(), |
|||
} |
|||
) |
@ -1,20 +1,22 @@ |
|||
# -*- coding: utf-8 -*- |
|||
from openerp import models, fields, api |
|||
|
|||
|
|||
class NewEaterWizard(models.TransientModel): |
|||
""" |
|||
A transient model for the creation of a eater related to a worker. |
|||
""" |
|||
_name = 'eater.new.wizard' |
|||
|
|||
_name = "eater.new.wizard" |
|||
|
|||
def _get_default_partner(self): |
|||
return self.env.context['active_id'] |
|||
return self.env.context["active_id"] |
|||
|
|||
first_name = fields.Char('First Name', required=True) |
|||
last_name = fields.Char('Last Name', required=True) |
|||
email = fields.Char('Email') |
|||
first_name = fields.Char("First Name", required=True) |
|||
last_name = fields.Char("Last Name", required=True) |
|||
email = fields.Char("Email") |
|||
|
|||
partner_id = fields.Many2one('res.partner', default=_get_default_partner) |
|||
partner_id = fields.Many2one("res.partner", default=_get_default_partner) |
|||
|
|||
@api.one |
|||
def create_new_eater(self): |
|||
|
@ -1,26 +1,30 @@ |
|||
from openerp import models, fields, api |
|||
from openerp import SUPERUSER_ID |
|||
|
|||
|
|||
class BeesdooWizard(models.TransientModel): |
|||
|
|||
_inherit = 'portal.wizard' |
|||
_inherit = "portal.wizard" |
|||
|
|||
@api.onchange('portal_id') |
|||
@api.onchange("portal_id") |
|||
def onchange_portal(self): |
|||
# for each partner, determine corresponding portal.wizard.user records |
|||
res_partner = self.env['res.partner'] |
|||
partner_ids = self._context.get('active_ids', []) |
|||
res_partner = self.env["res.partner"] |
|||
partner_ids = self._context.get("active_ids", []) |
|||
|
|||
contact_ids = set() |
|||
for partner in res_partner.browse(partner_ids): |
|||
for contact in (partner.child_ids | partner): |
|||
for contact in partner.child_ids | partner: |
|||
# make sure that each contact appears at most once in the list |
|||
if contact.id not in contact_ids: |
|||
contact_ids.add(contact.id) |
|||
in_portal = self.portal_id in contact.user_ids.mapped('groups_id') |
|||
self.user_ids |= self.env['portal.wizard.user'].new({ |
|||
'partner_id': contact.id, |
|||
'email': contact.email, |
|||
'in_portal': in_portal, |
|||
}) |
|||
|
|||
in_portal = self.portal_id in contact.user_ids.mapped( |
|||
"groups_id" |
|||
) |
|||
self.user_ids |= self.env["portal.wizard.user"].new( |
|||
{ |
|||
"partner_id": contact.id, |
|||
"email": contact.email, |
|||
"in_portal": in_portal, |
|||
} |
|||
) |
Write
Preview
Loading…
Cancel
Save
Reference in new issue