def create(self, cr, uid, vals, context={}):
vals['title']=vals['name']
- vals['parent_id'] = context.get('parent_id',False)
+ vals['parent_id'] = context.get('parent_id',False) or vals.get('parent_id',False)
if not vals.get('res_id', False) and context.get('default_res_id',False):
vals['res_id']=context.get('default_res_id',False)
if not vals.get('res_model', False) and context.get('default_res_model',False):
city = post_code = address = ""
for ads in addresses:
if ads.type == 'default':
- city = ads.city
- post_code = ads.zip
+ city = ads.city or ""
+ post_code = ads.zip or ""
if ads.street:
- address = ads.street
+ address = ads.street or ""
if ads.street2:
address += " " + ads.street2
return city, post_code, address
obj_fyear = pool_obj.get('account.fiscalyear')
year_id = obj_fyear.find(cr, uid)
- current_year = obj_fyear.browse(cr,uid,year_id).name
-
- period_code = pool_obj.get('account.period').browse(cr, uid, data['form']['period']).code
+
+ account_period=pool_obj.get('account.period').browse(cr, uid, data['form']['period'])
+ current_year = account_period.fiscalyear_id.name
+ period_code = account_period.code
send_ref = user_cmpny
if period_code:
data_of_file +='\n\t\t<POSTCODE>'+post_code+'</POSTCODE>\n\t\t<CITY>'+city+'</CITY>\n\t\t<SENDINGREFERENCE>'+send_ref+'</SENDINGREFERENCE>\n\t</DECLARER>'
data_of_file +='\n\t<VATRECORD>\n\t\t<RECNUM>1</RECNUM>\n\t\t<VATNUMBER>'+str(vat_no)+'</VATNUMBER>\n\t\t<DPERIODE>\n\t\t\t'
- starting_month = pool_obj.get('account.period').browse(cr, uid, data['form']['period']).date_start[5:7]
- ending_month = pool_obj.get('account.period').browse(cr, uid, data['form']['period']).date_stop[5:7]
+ starting_month = account_period.date_start[5:7]
+ ending_month = account_period.date_stop[5:7]
if starting_month != ending_month:
#starting month and ending month of selected period are not the same
#it means that the accounting isn't based on periods of 1 month but on quarters