Browse Source

[PEP8] fix pep8

pull/1/head
houssine 5 years ago
parent
commit
37f5ed6de3
  1. 76
      easy_my_coop/wizard/create_subscription_from_partner.py

76
easy_my_coop/wizard/create_subscription_from_partner.py

@ -1,11 +1,9 @@
# -*- coding: utf-8 -*-
import time
from openerp import api, fields, models, _
import openerp.addons.decimal_precision as dp
from openerp.exceptions import UserError
class PartnerCreateSubscription(models.TransientModel):
_name = "partner.create.subscription"
_description = "Create Subscription From Partner"
@ -17,7 +15,8 @@ class PartnerCreateSubscription(models.TransientModel):
@api.model
def _default_product_id(self):
domain = [('is_share','=',True),('default_share_product','=',True)]
domain = [('is_share', '=', True),
('default_share_product', '=', True)]
active_id = self.env.context.get('active_id')
if active_id:
partner = self.env['res.partner'].browse(active_id)
@ -93,23 +92,47 @@ class PartnerCreateSubscription(models.TransientModel):
@api.depends('share_product', 'share_qty')
def _compute_subscription_amount(self):
for sub_request in self:
sub_request.subscription_amount = sub_request.share_product.list_price * sub_request.share_qty
is_company = fields.Boolean(String="Is company?", default=_get_is_company)
cooperator = fields.Many2one('res.partner', string="Cooperator", default=_get_partner)
register_number = fields.Char(string="Register Number", required=True, default=_get_register_number)
email = fields.Char(string="Email", required=True, default=_get_email)
bank_account = fields.Char(string="Bank account", required=True, default=_get_bank_account)
share_product = fields.Many2one('product.product', string='Share Type', domain=lambda self: self._get_possible_share(),\
default=_default_product_id, required=True)
share_qty = fields.Integer(string="Share Quantity", required=True)
share_unit_price = fields.Float(related='share_product.list_price', string='Share price', readonly=True)
subscription_amount = fields.Float(compute='_compute_subscription_amount', string='Subscription amount', digits=dp.get_precision('Account'), readonly=True)
representative_name = fields.Char(string='Representative name', default=_get_representative_name)
representative_number = fields.Char(string='Representative national register number', default=_get_representative_number)
sub_request.subscription_amount = (sub_request.
share_product.list_price *
sub_request.share_qty)
is_company = fields.Boolean(String="Is company?",
default=_get_is_company)
cooperator = fields.Many2one('res.partner',
string="Cooperator",
default=_get_partner)
register_number = fields.Char(string="Register Number",
required=True,
default=_get_register_number)
email = fields.Char(string="Email",
required=True,
default=_get_email)
bank_account = fields.Char(string="Bank account",
required=True,
default=_get_bank_account)
share_product = fields.Many2one('product.product',
string='Share Type',
domain=_get_possible_share,
default=_default_product_id,
required=True)
share_qty = fields.Integer(string="Share Quantity",
required=True)
share_unit_price = fields.Float(related='share_product.list_price',
string='Share price',
readonly=True)
subscription_amount = fields.Float(compute='_compute_subscription_amount',
string='Subscription amount',
digits=dp.get_precision('Account'),
readonly=True)
representative_name = fields.Char(string='Representative name',
default=_get_representative_name)
representative_number = fields.Char(string='Representative national '
'register number',
default=_get_representative_number)
def check_belgian_ident_id(self, register_number):
if self.env['subscription.request'].check_belgian_identification_id(register_number):
sub_req = self.env['subscription.request']
if sub_req.check_belgian_identification_id(register_number):
return True
else:
raise UserError(_("The national register number is not valid."))
@ -161,15 +184,21 @@ class PartnerCreateSubscription(models.TransientModel):
if representative:
if len(representative) > 1:
raise UserError(_('There is two different persons with the same national register number. Please proceed to a merge before to continue'))
raise UserError(_('There is two different persons with '
'the same national register number. '
'Please proceed to a merge before to '
'continue'))
if representative.parent_id:
raise UserError(_("A person can't be representative of two differents companies."))
raise UserError(_("A person can't be representative of "
"two different companies."))
representative.parent_id = cooperator.id
else:
if self.check_belgian_ident_id(representative_number):
represent_vals = {'name':self.representative_name,'cooperator':True,
represent_vals = {'name': self.representative_name,
'cooperator': True,
'national_register_number': representative_number,
'parent_id':cooperator.id,'representative':True}
'parent_id': cooperator.id,
'representative': True}
partner_obj.create(represent_vals)
if not self._get_bank_account():
@ -195,4 +224,3 @@ class PartnerCreateSubscription(models.TransientModel):
'res_id': new_sub_req.id,
'target': 'current',
}
Loading…
Cancel
Save