Browse Source

[IMP] fix some PEP8

pull/16/head
houssine 5 years ago
parent
commit
f3eb9b2fb4
  1. 20
      easy_my_coop/models/coop.py

20
easy_my_coop/models/coop.py

@ -36,7 +36,10 @@ class SubscriptionRequest(models.Model):
required_fields.append('internal_rules_approved') required_fields.append('internal_rules_approved')
return required_fields return required_fields
def get_mail_template_notif(self):
def get_mail_template_notif(self, is_company=False):
if is_company:
return 'easy_my_coop.email_template_confirmation_company'
else:
return 'easy_my_coop.email_template_confirmation' return 'easy_my_coop.email_template_confirmation'
def is_member(self, vals, cooperator): def is_member(self, vals, cooperator):
@ -48,7 +51,7 @@ class SubscriptionRequest(models.Model):
@api.model @api.model
def create(self, vals): def create(self, vals):
partner_obj = self.env['res.partner'] partner_obj = self.env['res.partner']
mail_template = self.get_mail_template_notif()
mail_template = self.get_mail_template_notif(False)
if not vals.get('partner_id'): if not vals.get('partner_id'):
cooperator = False cooperator = False
@ -81,6 +84,7 @@ class SubscriptionRequest(models.Model):
@api.model @api.model
def create_comp_sub_req(self, vals): def create_comp_sub_req(self, vals):
mail_template = self.get_mail_template_notif(True)
vals["name"] = vals['company_name'] vals["name"] = vals['company_name']
if not vals.get('partner_id'): if not vals.get('partner_id'):
cooperator = self.env['res.partner'].get_cooperator_from_crn(vals.get('company_register_number')) cooperator = self.env['res.partner'].get_cooperator_from_crn(vals.get('company_register_number'))
@ -90,7 +94,7 @@ class SubscriptionRequest(models.Model):
vals['already_cooperator'] = True vals['already_cooperator'] = True
subscr_request = super(SubscriptionRequest, self).create(vals) subscr_request = super(SubscriptionRequest, self).create(vals)
confirmation_mail_template = self.env.ref('easy_my_coop.email_template_confirmation_company', False)
confirmation_mail_template = self.env.ref(mail_template, False)
confirmation_mail_template.send_mail(subscr_request.id, True) confirmation_mail_template.send_mail(subscr_request.id, True)
return subscr_request return subscr_request
@ -383,7 +387,8 @@ class SubscriptionRequest(models.Model):
return res return res
def send_capital_release_request(self, invoice): def send_capital_release_request(self, invoice):
email_template = self.env.ref('easy_my_coop.email_template_release_capital', False)
template = 'easy_my_coop.email_template_release_capital'
email_template = self.env.ref(template, False)
# we send the email with the capital release request in attachment # we send the email with the capital release request in attachment
# TODO remove sudo() and give necessary access right # TODO remove sudo() and give necessary access right
@ -520,7 +525,8 @@ class SubscriptionRequest(models.Model):
if contact: if contact:
contact.type = 'representative' contact.type = 'representative'
if not contact: if not contact:
contact_vals = {'name': self.name,
contact_vals = {
'name': self.name,
'firstname': self.firstname, 'firstname': self.firstname,
'lastname': self.lastname, 'customer': False, 'lastname': self.lastname, 'customer': False,
'is_company': False, 'cooperator': True, 'is_company': False, 'cooperator': True,
@ -617,8 +623,8 @@ class SubscriptionRegister(models.Model):
@api.multi @api.multi
def _compute_total_line(self): def _compute_total_line(self):
for register_line in self:
register_line.total_amount_line = register_line.share_unit_price * register_line.quantity
for line in self:
line.total_amount_line = line.share_unit_price * line.quantity
name = fields.Char(string='Number Operation', name = fields.Char(string='Number Operation',
required=True, required=True,

Loading…
Cancel
Save