Browse Source

[PEP8] pep8 code style refactoring

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

4
easy_my_coop/__openerp__.py

@ -40,7 +40,8 @@
"website": "www.coopiteasy.be", "website": "www.coopiteasy.be",
"license": "AGPL-3", "license": "AGPL-3",
"description": """ "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': [ 'data': [
'security/easy_my_coop_security.xml', 'security/easy_my_coop_security.xml',
@ -64,7 +65,6 @@
'report/cooperator_subscription_G001.xml', 'report/cooperator_subscription_G001.xml',
'report/cooperator_register_G001.xml', 'report/cooperator_register_G001.xml',
'data/mail_template_data.xml', 'data/mail_template_data.xml',
#'wizard/cooperative_history_wizard.xml',
], ],
'installable': True, 'installable': True,
'application': True, 'application': True,

1
easy_my_coop/models/__init__.py

@ -6,4 +6,3 @@ from . import account_invoice
from . import company from . import company
from . import res_partner_bank from . import res_partner_bank
from . import account_journal from . import account_journal
#import mail_mail

61
easy_my_coop/models/account_invoice.py

@ -1,17 +1,23 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from datetime import datetime from datetime import datetime
from openerp import api, fields, models, _
from openerp import api, fields, models
class account_invoice(models.Model): class account_invoice(models.Model):
_inherit = 'account.invoice' _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 @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 values['release_capital_request'] = self.release_capital_request
return values return values
@ -23,33 +29,33 @@ class account_invoice(models.Model):
mail_template_name = 'Payment Received Confirmation - Send By Email' mail_template_name = 'Payment Received Confirmation - Send By Email'
# if not yet cooperator we generate a cooperator number # 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() 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: else:
mail_template_name = 'Share Increase - Payment Received Confirmation - Send By Email' 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() sub_reg_operation = sequence_operation.next_by_id()
for line in self.invoice_line_ids: for line in self.invoice_line_ids:
sub_reg = self.env['subscription.register'].create( 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'] email_template_obj = self.env['mail.template']
certificat_email_template = email_template_obj.search([('name', '=', mail_template_name)])[0] certificat_email_template = email_template_obj.search([('name', '=', mail_template_name)])[0]
@ -70,11 +76,12 @@ class account_invoice(models.Model):
# we check if there is an open refund for this invoice. in this case we # 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 # don't run the process_subscription function as the invoice has been
# reconciled with a refund and not a payment. # 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 \ if invoice.partner_id.cooperator and invoice.release_capital_request \
and invoice.type == 'out_invoice' and not refund: 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") effective_date = datetime.now().strftime("%d/%m/%Y")
if invoice.payment_move_line_ids: if invoice.payment_move_line_ids:

20
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): def random_date(start, end):
delta = end - start delta = end - start
return start + timedelta(seconds=randrange(delta.total_seconds())) return start + timedelta(seconds=randrange(delta.total_seconds()))
def generate_identification_id(start_date, end_date): def generate_identification_id(start_date, end_date):
birthday = random_date(start_date, end_date) birthday = random_date(start_date, end_date)
year = str(birthday.year)[2:] year = str(birthday.year)[2:]
month = str(birthday.month).zfill(2) month = str(birthday.month).zfill(2)
day = str(birthday.day).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 millenium_baby = birthday.year > 2000
main_number = year + month + day + gender main_number = year + month + day + gender
@ -20,12 +22,14 @@ def generate_identification_id(start_date, end_date):
return main_number + control_number return main_number + control_number
def identification_id_to_gender(identification_id): def identification_id_to_gender(identification_id):
if identification_id and len(identification_id) == 11: if identification_id and len(identification_id) == 11:
gender = identification_id[6:9] 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" ?> <?xml version="1.0" ?>
<openerp> <openerp>
<data> <data>
<record id="view_cooperative_history_wizard" model="ir.ui.view"> <record id="view_cooperative_history_wizard" model="ir.ui.view">
<field name="name">cooperative.history.wizard.form</field> <field name="name">cooperative.history.wizard.form</field>
<field name="model">cooperative.history.report</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"/> <label string="This report allows you to print a pdf of history and number of share for each cooperator"/>
<group> <group>
<field name="display_cooperator"/> <field name="display_cooperator"/>
<!--<field name="display_time"/>-->
</group> </group>
<footer> <footer>
@ -37,20 +35,7 @@
<field name="multi">True</field> <field name="multi">True</field>
</record> </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_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_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> </data>
</openerp> </openerp>

2
easy_my_coop_ch/__openerp__.py

@ -23,7 +23,7 @@
"version": "1.0", "version": "1.0",
"depends": ["easy_my_coop", "depends": ["easy_my_coop",
"l10n_ch", "l10n_ch",
"theme_light",],
"theme_light"],
"author": "Houssine BAKKALI <houssine@coopiteasy.be>", "author": "Houssine BAKKALI <houssine@coopiteasy.be>",
"category": "Cooperative management", "category": "Cooperative management",
'webstite': "www.coopiteasy.be", 'webstite': "www.coopiteasy.be",

2
easy_my_coop_document/__init__.py

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

2
easy_my_coop_eater/__openerp__.py

@ -21,7 +21,7 @@
{ {
"name": "Easy My Coop Eater/worker", "name": "Easy My Coop Eater/worker",
"version": "1.0", "version": "1.0",
"depends": ["easy_my_coop","partner_age"],
"depends": ["easy_my_coop", "partner_age"],
"author": "Houssine BAKKALI <houssine@coopiteasy.be>", "author": "Houssine BAKKALI <houssine@coopiteasy.be>",
"category": "Cooperative management", "category": "Cooperative management",
'website': "www.coopiteasy.be", 'website': "www.coopiteasy.be",

2
easy_my_coop_fr/__openerp__.py

@ -23,7 +23,7 @@
"version": "1.0", "version": "1.0",
"depends": ["easy_my_coop", "depends": ["easy_my_coop",
"l10n_fr", "l10n_fr",
"theme_light",],
"theme_light"],
"author": "Houssine BAKKALI <houssine@coopiteasy.be>", "author": "Houssine BAKKALI <houssine@coopiteasy.be>",
"category": "Cooperative management", "category": "Cooperative management",
'webstite': "www.coopiteasy.be", 'webstite': "www.coopiteasy.be",

16
easy_my_coop_fr/models/coop.py

@ -1,23 +1,25 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from openerp import api, fields, models, _
from openerp import fields, models
class subscription_request(models.Model): class subscription_request(models.Model):
_inherit = 'subscription.request' _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): 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: if 'iban' in required_fields:
required_fields.remove('iban') required_fields.remove('iban')
return required_fields return required_fields
# override function to disable the check
def check_belgian_identification_id(self, nat_register_num): def check_belgian_identification_id(self, nat_register_num):
#deactivate number validation for french localization
# deactivate number validation for french localization
return True return True

2
easy_my_coop_recompute_coop_number/__init__.py

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

3
easy_my_coop_recompute_coop_number/__openerp__.py

@ -26,7 +26,8 @@
"category": "Cooperative management", "category": "Cooperative management",
'website': "www.coopiteasy.be", 'website': "www.coopiteasy.be",
"description": """ "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': [ 'data': [
'wizard/cooperator_number_wizard.xml', 'wizard/cooperator_number_wizard.xml',

2
easy_my_coop_recompute_coop_number/wizard/__init__.py

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

4
easy_my_coop_recompute_coop_number/wizard/cooperator_number_wizard.py

@ -12,8 +12,8 @@ class RecomputeWizard(models.TransientModel):
obj_sequence = self.env['ir.sequence'] obj_sequence = self.env['ir.sequence']
sequence_operation = obj_sequence.search([('name','=','Register Operation')])[0] 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: for subscription_register in subscription_registers:
sub_reg_operation = sequence_operation.next_by_id() 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)})

1
easy_my_coop_recompute_coop_number/wizard/cooperator_number_wizard.xml

@ -1,6 +1,5 @@
<openerp> <openerp>
<data> <data>
<record id="view_register_number_wizard" model="ir.ui.view"> <record id="view_register_number_wizard" model="ir.ui.view">
<field name="name">Register number wizard</field> <field name="name">Register number wizard</field>
<field name="model">register.number.wizard</field> <field name="model">register.number.wizard</field>

3
easy_my_coop_taxshelter_report/__openerp__.py

@ -27,7 +27,8 @@
'website': "www.coopiteasy.be", 'website': "www.coopiteasy.be",
"license": "AGPL-3", "license": "AGPL-3",
"description": """ "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': [ 'data': [
'security/ir.model.access.csv', 'security/ir.model.access.csv',

2
easy_my_coop_website_document/__init__.py

@ -1,2 +1,2 @@
# -*- coding: utf8 -*- # -*- 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: elif status == 301:
# TODO: test this case not sure if this render the same # TODO: test this case not sure if this render the same
# return werkzeug.utils.redirect(content, code=301) # return werkzeug.utils.redirect(content, code=301)
return request.redirec(content, code=301)
return request.redirect(content, code=301)
elif status != 200: elif status != 200:
return request.not_found() return request.not_found()
content_base64 = base64.b64decode(content) content_base64 = base64.b64decode(content)

2
easy_my_coop_website_portal/__init__.py

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

2
easy_my_coop_website_taxshelter/__init__.py

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

2
partner_age/__openerp__.py

@ -28,7 +28,7 @@
"category": "Cooperative management", "category": "Cooperative management",
'website': "www.coopiteasy.be", 'website': "www.coopiteasy.be",
"description": """ "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': [ 'data': [
'view/partner_view.xml', 'view/partner_view.xml',

Loading…
Cancel
Save