Browse Source

[PEP8] pep8 code style refactoring

pull/1/head
houssine 6 years ago
parent
commit
abc577ff3f
  1. 14
      easy_my_coop/__openerp__.py
  2. 1
      easy_my_coop/models/__init__.py
  3. 65
      easy_my_coop/models/account_invoice.py
  4. 24
      easy_my_coop/models/belgian_identification_id_generator.py
  5. 15
      easy_my_coop/wizard/cooperative_history_wizard.xml
  6. 6
      easy_my_coop_be/__openerp__.py
  7. 6
      easy_my_coop_ch/__openerp__.py
  8. 2
      easy_my_coop_document/__init__.py
  9. 6
      easy_my_coop_eater/__openerp__.py
  10. 2
      easy_my_coop_fr/__init__.py
  11. 6
      easy_my_coop_fr/__openerp__.py
  12. 2
      easy_my_coop_fr/models/__init__.py
  13. 26
      easy_my_coop_fr/models/coop.py
  14. 8
      easy_my_coop_online_payment/__openerp__.py
  15. 2
      easy_my_coop_recompute_coop_number/__init__.py
  16. 5
      easy_my_coop_recompute_coop_number/__openerp__.py
  17. 2
      easy_my_coop_recompute_coop_number/wizard/__init__.py
  18. 10
      easy_my_coop_recompute_coop_number/wizard/cooperator_number_wizard.py
  19. 17
      easy_my_coop_recompute_coop_number/wizard/cooperator_number_wizard.xml
  20. 5
      easy_my_coop_taxshelter_report/__openerp__.py
  21. 2
      easy_my_coop_website_document/__init__.py
  22. 2
      easy_my_coop_website_document/controllers/main.py
  23. 2
      easy_my_coop_website_portal/__init__.py
  24. 2
      easy_my_coop_website_taxshelter/__init__.py
  25. 4
      partner_age/__openerp__.py

14
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,
}
}

1
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

65
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:

24
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')

15
easy_my_coop/wizard/cooperative_history_wizard.xml

@ -1,7 +1,6 @@
<?xml version="1.0" ?>
<openerp>
<data>
<record id="view_cooperative_history_wizard" model="ir.ui.view">
<field name="name">cooperative.history.wizard.form</field>
<field name="model">cooperative.history.report</field>
@ -14,7 +13,6 @@
<label string="This report allows you to print a pdf of history and number of share for each cooperator"/>
<group>
<field name="display_cooperator"/>
<!--<field name="display_time"/>-->
</group>
<footer>
@ -37,20 +35,7 @@
<field name="multi">True</field>
</record>
<!--
<record model="ir.values" id="action_mission_history_wizard_values">
<field name="model_id" ref="fiducis.model_mission_mission"/>
<field name="object" eval="1"/>
<field name="name">Mission history</field>
<field name="key2">client_print_multi</field>
<field name="value"
eval="'ir.actions.act_window,' +str(ref('action_mission_history_wizard'))"/>
<field name="key">action</field>
<field name="model">mission.mission</field>
</record>
-->
<menuitem id="menu_energiris_reporting" name="Reporting" parent="menu_main_energiris" sequence="20"/>
<menuitem id="menu_coop_history_wizard_report" name="Cooperative history report" parent="menu_energiris_reporting" action="action_cooperative_history_wizard" sequence="10"/>
<!--<menuitem id="menu_optify_rep_history" name="Mission hours history" action="action_mission_history_wizard" parent="menu_optify_reporting" sequence="2"/>-->
</data>
</openerp>

6
easy_my_coop_be/__openerp__.py

@ -22,16 +22,16 @@
"name": "Easy My Coop Be",
"version": "1.0",
"depends": ["easy_my_coop",
"l10n_be",
"l10n_be",
"l10n_be_invoice_bba",
],
"author": "Houssine BAKKALI <houssine@coopiteasy.be>",
"category": "Cooperative management",
"website": "www.coopiteasy.be",
"description": """
This is the belgian localization for the easy my coop module.
This is the belgian localization for the easy my coop module.
""",
'data': [],
'installable': True,
'application': False,
}
}

6
easy_my_coop_ch/__openerp__.py

@ -23,16 +23,16 @@
"version": "1.0",
"depends": ["easy_my_coop",
"l10n_ch",
"theme_light",],
"theme_light"],
"author": "Houssine BAKKALI <houssine@coopiteasy.be>",
"category": "Cooperative management",
'webstite': "www.coopiteasy.be",
"description": """
This is the swiss localization for the easy my coop module
This is the swiss localization for the easy my coop module
""",
'data': [
'views/subscription_template.xml',
'views/subscription_request_view.xml'
],
'installable': True,
}
}

2
easy_my_coop_document/__init__.py

@ -1,2 +1,2 @@
# -*- coding: utf8 -*-
import models
from . import models

6
easy_my_coop_eater/__openerp__.py

@ -21,15 +21,15 @@
{
"name": "Easy My Coop Eater/worker",
"version": "1.0",
"depends": ["easy_my_coop","partner_age"],
"depends": ["easy_my_coop", "partner_age"],
"author": "Houssine BAKKALI <houssine@coopiteasy.be>",
"category": "Cooperative management",
'website': "www.coopiteasy.be",
"description": """
This module allows to manage the activity of the cooperator.
This module allows to manage the activity of the cooperator.
""",
'data': [
'view/product_view.xml',
],
'installable': True,
}
}

2
easy_my_coop_fr/__init__.py

@ -1 +1 @@
from . import models
from . import models

6
easy_my_coop_fr/__openerp__.py

@ -23,12 +23,12 @@
"version": "1.0",
"depends": ["easy_my_coop",
"l10n_fr",
"theme_light",],
"theme_light"],
"author": "Houssine BAKKALI <houssine@coopiteasy.be>",
"category": "Cooperative management",
'webstite': "www.coopiteasy.be",
"description": """
This is the french localization for the easy my coop module
This is the french localization for the easy my coop module
""",
'data': [
'views/subscription_template.xml',
@ -36,4 +36,4 @@
'views/certificate_template.xml'
],
'installable': True,
}
}

2
easy_my_coop_fr/models/__init__.py

@ -1 +1 @@
from . import coop
from . import coop

26
easy_my_coop_fr/models/coop.py

@ -1,23 +1,25 @@
# -*- coding: utf-8 -*-
from openerp import api, fields, models, _
from openerp import fields, models
class subscription_request(models.Model):
_inherit = 'subscription.request'
company_type = fields.Selection([('asso','Association'),
('eurl','EURL / Entreprise individuelle'),
('sarl','SARL'),
('sa','SA / SAS')])
company_type = fields.Selection([
('asso', 'Association'),
('eurl', 'EURL / Entreprise individuelle'),
('sarl', 'SARL'),
('sa', 'SA / SAS')])
def get_required_field(self):
required_fields = super(subscription_request,self).get_required_field()
required_fields = super(subscription_request, self).get_required_field()
if 'iban' in required_fields:
required_fields.remove('iban')
return required_fields
# override function to disable the check
def check_belgian_identification_id(self, nat_register_num):
#deactivate number validation for french localization
return True
# deactivate number validation for french localization
return True

8
easy_my_coop_online_payment/__openerp__.py

@ -22,14 +22,14 @@
"name": "Easy My Coop Online Payment",
"version": "1.0",
"depends": ["easy_my_coop",
"website_payment",
"website_payment",
"payment_paypal"],
"author": "Houssine BAKKALI <houssine@coopiteasy.be>",
"category": "Cooperative management",
'website': "www.coopiteasy.be",
"description": """
This module allows the cooperator to pay the subscribed shares online
during the subscription process
This module allows the cooperator to pay the subscribed shares online
during the subscription process
""",
'data': [
"views/online_payment_template.xml",
@ -37,4 +37,4 @@
],
'installable': True,
'application': False,
}
}

2
easy_my_coop_recompute_coop_number/__init__.py

@ -1 +1 @@
import wizard
from . import wizard

5
easy_my_coop_recompute_coop_number/__openerp__.py

@ -26,11 +26,12 @@
"category": "Cooperative management",
'website': "www.coopiteasy.be",
"description": """
This module allows to recompute the cooperator number subscription it has to be used carefully.
This module allows to recompute the cooperator number subscription
it has to be used carefully.
""",
'data': [
'wizard/cooperator_number_wizard.xml',
],
'installable': True,
'active': False,
}
}

2
easy_my_coop_recompute_coop_number/wizard/__init__.py

@ -1,2 +1,2 @@
# -*- coding: utf-8 -*-
import cooperator_number_wizard
from . import cooperator_number_wizard

10
easy_my_coop_recompute_coop_number/wizard/cooperator_number_wizard.py

@ -3,17 +3,17 @@ from openerp import models, fields, api
class RecomputeWizard(models.TransientModel):
_name = 'register.number.wizard'
from_number = fields.Integer(string="From number")
to_number = fields.Integer(string="To number")
@api.one
def compute_register_number(self):
obj_sequence = self.env['ir.sequence']
sequence_operation = obj_sequence.search([('name','=','Register Operation')])[0]
subscription_registers = self.env['subscription.register'].search([('register_number_operation','>=',self.from_number)])
subscription_registers = self.env['subscription.register'].search([('register_number_operation', '>=', self.from_number)])
for subscription_register in subscription_registers:
sub_reg_operation = sequence_operation.next_by_id()
subscription_register.write({'name':sub_reg_operation,'register_number_operation':int(sub_reg_operation)})
subscription_register.write({'name':sub_reg_operation, 'register_number_operation': int(sub_reg_operation)})

17
easy_my_coop_recompute_coop_number/wizard/cooperator_number_wizard.xml

@ -1,25 +1,24 @@
<openerp>
<data>
<record id="view_register_number_wizard" model="ir.ui.view">
<field name="name">Register number wizard</field>
<field name="model">register.number.wizard</field>
<field name="arch" type="xml">
<form>
<form>
<group>
<field name="from_number" default_focus="1" />
<field name="to_number"/>
</group>
<footer>
<button name="compute_register_number" string="Compute" type="object" class="oe_highlight"/>
or
<button string="Cancel" class="oe_link" special="cancel" />
</footer>
</form>
<footer>
<button name="compute_register_number" string="Compute" type="object" class="oe_highlight"/>
or
<button string="Cancel" class="oe_link" special="cancel" />
</footer>
</form>
</field>
</record>
<record id="action_register_number_wizard" model="ir.actions.act_window">
<record id="action_register_number_wizard" model="ir.actions.act_window">
<field name="name">Recompute register number</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">register.number.wizard</field>

5
easy_my_coop_taxshelter_report/__openerp__.py

@ -27,7 +27,8 @@
'website': "www.coopiteasy.be",
"license": "AGPL-3",
"description": """
This module allows to create a fiscal declaration year and to print tax shelter declaration each cooperator
This module allows to create a fiscal declaration year and to print
tax shelter declaration each cooperator
""",
'data': [
'security/ir.model.access.csv',
@ -39,4 +40,4 @@
'data/scheduler_data.xml',
],
'installable': True,
}
}

2
easy_my_coop_website_document/__init__.py

@ -1,2 +1,2 @@
# -*- coding: utf8 -*-
import controllers
from . import controllers

2
easy_my_coop_website_document/controllers/main.py

@ -33,7 +33,7 @@ class DocumentWebsite(http.Controller):
elif status == 301:
# TODO: test this case not sure if this render the same
# return werkzeug.utils.redirect(content, code=301)
return request.redirec(content, code=301)
return request.redirect(content, code=301)
elif status != 200:
return request.not_found()
content_base64 = base64.b64decode(content)

2
easy_my_coop_website_portal/__init__.py

@ -1,2 +1,2 @@
# -*- coding: utf8 -*-
import controllers
from . import controllers

2
easy_my_coop_website_taxshelter/__init__.py

@ -1,2 +1,2 @@
# -*- coding: utf8 -*-
import controllers
from . import controllers

4
partner_age/__openerp__.py

@ -28,10 +28,10 @@
"category": "Cooperative management",
'website': "www.coopiteasy.be",
"description": """
This module allows to recompute the cooperator number subscription it has to be used carefully.
This module computes the age of the partner.
""",
'data': [
'view/partner_view.xml',
],
'installable': True,
}
}
Loading…
Cancel
Save