diff --git a/easy_my_coop/__openerp__.py b/easy_my_coop/__openerp__.py index 82ecf05..f14367f 100644 --- a/easy_my_coop/__openerp__.py +++ b/easy_my_coop/__openerp__.py @@ -21,8 +21,8 @@ { "name": "Easy My Coop", "version": "1.1", - "depends": ["base", - "sale", + "depends": ["base", + "sale", "purchase", "account_accountant", "product", @@ -40,7 +40,8 @@ "website": "www.coopiteasy.be", "license": "AGPL-3", "description": """ - This module allows to manage the cooperator subscription and all the cooperative business processes. + This module allows to manage the cooperator subscription and all the + cooperative business processes. """, 'data': [ 'security/easy_my_coop_security.xml', @@ -48,7 +49,7 @@ 'wizard/create_subscription_from_partner.xml', 'wizard/update_partner_info.xml', 'view/subscription_request_view.xml', - 'view/email_template_view.xml', + 'view/email_template_view.xml', 'view/res_partner_view.xml', 'view/cooperator_register_view.xml', 'view/operation_request_view.xml', @@ -57,15 +58,14 @@ 'view/product_view.xml', 'view/res_company_view.xml', 'view/account_journal_view.xml', - 'data/easy_my_coop_data.xml', + 'data/easy_my_coop_data.xml', 'report/easy_my_coop_report.xml', 'report/cooperator_invoice_G002.xml', 'report/cooperator_certificat_G001.xml', 'report/cooperator_subscription_G001.xml', 'report/cooperator_register_G001.xml', 'data/mail_template_data.xml', - #'wizard/cooperative_history_wizard.xml', ], 'installable': True, 'application': True, -} \ No newline at end of file +} diff --git a/easy_my_coop/models/__init__.py b/easy_my_coop/models/__init__.py index 0f4294a..9f09fa5 100644 --- a/easy_my_coop/models/__init__.py +++ b/easy_my_coop/models/__init__.py @@ -6,4 +6,3 @@ from . import account_invoice from . import company from . import res_partner_bank from . import account_journal -#import mail_mail \ No newline at end of file diff --git a/easy_my_coop/models/account_invoice.py b/easy_my_coop/models/account_invoice.py index 3b15c39..cba3b20 100644 --- a/easy_my_coop/models/account_invoice.py +++ b/easy_my_coop/models/account_invoice.py @@ -1,17 +1,23 @@ # -*- coding: utf-8 -*- from datetime import datetime -from openerp import api, fields, models, _ +from openerp import api, fields, models + class account_invoice(models.Model): _inherit = 'account.invoice' - subscription_request = fields.Many2one('subscription.request', string='Subscription request') - release_capital_request = fields.Boolean(string='Release of capital request') + subscription_request = fields.Many2one('subscription.request', + string='Subscription request') + release_capital_request = fields.Boolean( + string='Release of capital request') @api.model - def _prepare_refund(self, invoice, date_invoice=None, date=None, description=None, journal_id=None): - values = super(account_invoice, self)._prepare_refund(invoice, date_invoice, date, description, journal_id) + def _prepare_refund(self, invoice, date_invoice=None, date=None, + description=None, journal_id=None): + values = super(account_invoice, self)._prepare_refund( + invoice, date_invoice, date, + description, journal_id) values['release_capital_request'] = self.release_capital_request return values @@ -23,33 +29,33 @@ class account_invoice(models.Model): mail_template_name = 'Payment Received Confirmation - Send By Email' # if not yet cooperator we generate a cooperator number - if self.partner_id.member == False and self.partner_id.old_member == False: - sequence_id = obj_sequence.search([('name','=','Subscription Register')])[0] + if self.partner_id.member is False and self.partner_id.old_member is False: + sequence_id = obj_sequence.search([('name', '=', 'Subscription Register')])[0] sub_reg_num = sequence_id.next_by_id() - self.partner_id.write({'member':True,'old_member':False, - 'cooperator_register_number':int(sub_reg_num)}) - elif self.partner_id.old_member == True: - self.partner_id.write({'member':True,'old_member':False}) + self.partner_id.write({'member': True, 'old_member': False, + 'cooperator_register_number': int(sub_reg_num)}) + elif self.partner_id.old_member: + self.partner_id.write({'member': True, 'old_member': False}) else: mail_template_name = 'Share Increase - Payment Received Confirmation - Send By Email' - sequence_operation = obj_sequence.search([('name','=','Register Operation')])[0] + sequence_operation = obj_sequence.search([('name', '=', 'Register Operation')])[0] sub_reg_operation = sequence_operation.next_by_id() for line in self.invoice_line_ids: sub_reg = self.env['subscription.register'].create( - {'name':sub_reg_operation, - 'register_number_operation':int(sub_reg_operation), - 'partner_id':self.partner_id.id, - 'quantity':line.quantity, - 'share_product_id':line.product_id.id, - 'share_unit_price':line.price_unit, - 'date':effective_date, - 'type':'subscription'}) - self.env['share.line'].create({'share_number':line.quantity, - 'share_product_id':line.product_id.id, - 'partner_id':self.partner_id.id, - 'share_unit_price':line.price_unit, - 'effective_date':effective_date}) + {'name': sub_reg_operation, + 'register_number_operation': int(sub_reg_operation), + 'partner_id': self.partner_id.id, + 'quantity': line.quantity, + 'share_product_id': line.product_id.id, + 'share_unit_price': line.price_unit, + 'date': effective_date, + 'type': 'subscription'}) + self.env['share.line'].create({'share_number': line.quantity, + 'share_product_id': line.product_id.id, + 'partner_id': self.partner_id.id, + 'share_unit_price': line.price_unit, + 'effective_date': effective_date}) email_template_obj = self.env['mail.template'] certificat_email_template = email_template_obj.search([('name', '=', mail_template_name)])[0] @@ -59,22 +65,23 @@ class account_invoice(models.Model): return True def post_process_confirm_paid(self, effective_date): - self.set_cooperator_effective(effective_date) + self.set_cooperator_effective(effective_date) return True - @api.multi + @api.multi def confirm_paid(self): for invoice in self: super(account_invoice, invoice).confirm_paid() # we check if there is an open refund for this invoice. in this case we # don't run the process_subscription function as the invoice has been # reconciled with a refund and not a payment. - refund = self.search([('type','=','out_refund'),('origin','=',invoice.number)]).filtered(lambda record: record.state == 'open') + refund = self.search([('type', '=', 'out_refund'), ('origin', '=', invoice.number)]).filtered(lambda record: record.state == 'open') if invoice.partner_id.cooperator and invoice.release_capital_request \ and invoice.type == 'out_invoice' and not refund: - #take the effective date from the payment. by default the confirmation date is the payment date + # take the effective date from the payment. + # by default the confirmation date is the payment date effective_date = datetime.now().strftime("%d/%m/%Y") if invoice.payment_move_line_ids: diff --git a/easy_my_coop/models/belgian_identification_id_generator.py b/easy_my_coop/models/belgian_identification_id_generator.py index 05d8671..774320b 100644 --- a/easy_my_coop/models/belgian_identification_id_generator.py +++ b/easy_my_coop/models/belgian_identification_id_generator.py @@ -1,16 +1,18 @@ -from random import randrange,randint -from datetime import date,timedelta +from random import randrange, randint +from datetime import date, timedelta + def random_date(start, end): delta = end - start return start + timedelta(seconds=randrange(delta.total_seconds())) - + + def generate_identification_id(start_date, end_date): birthday = random_date(start_date, end_date) year = str(birthday.year)[2:] month = str(birthday.month).zfill(2) day = str(birthday.day).zfill(2) - gender = str(randint(1,998)).zfill(3) + gender = str(randint(1, 998)).zfill(3) millenium_baby = birthday.year > 2000 main_number = year + month + day + gender @@ -19,13 +21,15 @@ def generate_identification_id(start_date, end_date): control_number = str(control_number).zfill(2) return main_number + control_number - + + def identification_id_to_gender(identification_id): if identification_id and len(identification_id) == 11: gender = identification_id[6:9] - return int(gender)%2 + return int(gender) % 2 + -identification_id = generate_identification_id(date(1920,1,1), date(1995,12,31)) -gender = identification_id_to_gender(identification_id) -print 'Rijksregisternummer: ' + identification_id -print 'Geslacht: ' + ('Man' if gender else 'Vrouw') +INDENTITY_ID = generate_identification_id(date(1920, 1, 1), date(1995, 12, 31)) +GENDER = identification_id_to_gender(INDENTITY_ID) +print 'Rijksregisternummer: ' + INDENTITY_ID +print 'Geslacht: ' + ('Man' if GENDER else 'Vrouw') diff --git a/easy_my_coop/wizard/cooperative_history_wizard.xml b/easy_my_coop/wizard/cooperative_history_wizard.xml index e800ce9..7fd2d33 100644 --- a/easy_my_coop/wizard/cooperative_history_wizard.xml +++ b/easy_my_coop/wizard/cooperative_history_wizard.xml @@ -1,7 +1,6 @@ - cooperative.history.wizard.form cooperative.history.report @@ -14,7 +13,6 @@