Browse Source

[REFACT] some cleaning in the code and comply with pep8

pull/1/head
houssine 6 years ago
parent
commit
a801b6982f
  1. 28
      easy_my_coop/models/account_invoice.py

28
easy_my_coop/models/account_invoice.py

@ -24,15 +24,14 @@ class account_invoice(models.Model):
def set_cooperator_effective(self, effective_date):
# flag the partner as a effective member
obj_sequence = self.env['ir.sequence']
mail_template_id = 'easy_my_coop.email_template_certificat'
# if not yet cooperator we generate a cooperator number
if self.partner_id.member is False and self.partner_id.old_member is False:
sequence_id = self.env.ref('easy_my_coop.sequence_subscription', False)
sub_reg_num = sequence_id.next_by_id()
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})
@ -42,8 +41,8 @@ class account_invoice(models.Model):
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,
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,
@ -51,15 +50,16 @@ class account_invoice(models.Model):
'share_unit_price': line.price_unit,
'date': effective_date,
'type': 'subscription'})
self.env['share.line'].create({'share_number': line.quantity,
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})
'effective_date': effective_date
})
email_template_obj = self.env['mail.template']
certificat_email_template = self.env.ref(mail_template_id, False)
#certificat_email_template = email_template_obj.search([('name', '=', mail_template_name)])[0]
# we send the email with the certificat in attachment
certificat_email_template.send_mail(self.partner_id.id, False)
@ -73,12 +73,12 @@ class account_invoice(models.Model):
@api.multi
def confirm_paid(self):
for invoice in self:
#self.env.cr.commit()
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.move_name)])
# 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.move_name)])
if invoice.partner_id.cooperator and invoice.release_capital_request \
and invoice.type == 'out_invoice' and not refund:

Loading…
Cancel
Save