@ -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,12 +29,12 @@ 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 :
if self . partner_id . member is False and self . partner_id . old_member is False :
sequence_id = obj_sequence . search ( [ ( ' name ' , ' = ' , ' Subscription Register ' ) ] ) [ 0 ]
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 ,
self . partner_id . write ( { ' member ' : True , ' old_member ' : False ,
' cooperator_register_number ' : int ( sub_reg_num ) } )
' cooperator_register_number ' : int ( sub_reg_num ) } )
elif self . partner_id . old_member == True :
elif self . partner_id . old_member :
self . partner_id . write ( { ' member ' : True , ' old_member ' : False } )
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 '
@ -74,7 +80,8 @@ class account_invoice(models.Model):
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 :