[MERGE] merge pap branch for l10n_be changes and improved the code

bzr revid: mra@mra-laptop-20100611070425-v71pz0nu5yp9yh96
This commit is contained in:
Mustufa Rangwala 2010-06-11 12:34:25 +05:30
commit eb39463ac4
4 changed files with 107 additions and 41 deletions

View File

@ -28,6 +28,11 @@ class l10n_be_vat_declaration(osv.osv_memory):
_name = "l1on_be.vat.declaration" _name = "l1on_be.vat.declaration"
_description = "Vat Declaration" _description = "Vat Declaration"
def _get_xml_data(self, cr, uid, context=None):
if context.get('file_save', False):
return base64.encodestring(context['file_save'])
return ''
_columns = { _columns = {
'name': fields.char('File Name', size=32), 'name': fields.char('File Name', size=32),
'period_id': fields.many2one('account.period','Period', required=True), 'period_id': fields.many2one('account.period','Period', required=True),
@ -39,7 +44,9 @@ class l10n_be_vat_declaration(osv.osv_memory):
} }
_defaults = { _defaults = {
'msg': 'Save the File with '".xml"' extension.', 'msg': 'Save the File with '".xml"' extension.',
} 'file_save': _get_xml_data,
'name': 'vat_declaration.xml',
}
def create_xml(self, cr, uid, ids, context=None): def create_xml(self, cr, uid, ids, context=None):
obj_fyear = self.pool.get('account.fiscalyear') obj_fyear = self.pool.get('account.fiscalyear')
@ -48,6 +55,7 @@ class l10n_be_vat_declaration(osv.osv_memory):
obj_user = self.pool.get('res.users') obj_user = self.pool.get('res.users')
obj_comp = self.pool.get('res.company') obj_comp = self.pool.get('res.company')
obj_data = self.pool.get('ir.model.data') obj_data = self.pool.get('ir.model.data')
mod_obj = self.pool.get('ir.model.data')
if context is None: if context is None:
context = {} context = {}
@ -99,9 +107,21 @@ class l10n_be_vat_declaration(osv.osv_memory):
data_of_file +='\n\t\t\t\t<D'+str(int(item['code'])) +'>' + str(abs(int(item['sum_period']*100))) + '</D'+str(int(item['code'])) +'>' data_of_file +='\n\t\t\t\t<D'+str(int(item['code'])) +'>' + str(abs(int(item['sum_period']*100))) + '</D'+str(int(item['code'])) +'>'
data_of_file +='\n\t\t\t</DATA_ELEM>\n\t\t</DATA>\n\t</VATRECORD>\n</VATSENDING>' data_of_file +='\n\t\t\t</DATA_ELEM>\n\t\t</DATA>\n\t</VATRECORD>\n</VATSENDING>'
data['file_save'] = base64.encodestring(data_of_file) model_data_ids = mod_obj.search(cr, uid,[('model','=','ir.ui.view'),('name','=','view_vat_save')], context=context)
self.write(cr, uid, ids, {'file_save': data['file_save'], 'name': 'vat_declare.xml'}, context=context) resource_id = mod_obj.read(cr, uid, model_data_ids, fields=['res_id'], context=context)[0]['res_id']
return True context['file_save'] = data_of_file
return {
'name': _('Save XML For Vat declaration'),
'context': context,
'view_type': 'form',
'view_mode': 'form',
'res_model': 'l1on_be.vat.declaration',
'views': [(resource_id,'form')],
'view_id': 'view_vat_save',
'type': 'ir.actions.act_window',
'target': 'new',
}
l10n_be_vat_declaration() l10n_be_vat_declaration()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -13,31 +13,46 @@
<field name="type">form</field> <field name="type">form</field>
<field name="arch" type="xml"> <field name="arch" type="xml">
<form string="Periodical VAT Declaration" > <form string="Periodical VAT Declaration" >
<group height="400" width="330"> <group height="220" width="330">
<group> <group>
<separator string="Declare Periodical VAT" colspan="2" /><newline/> <separator string="Declare Periodical VAT" colspan="2" /><newline/>
<field name="period_id" /><newline/> <field name="period_id" /><newline/>
<field name="ask_resitution" colspan="2" align="1"/><newline/> <field name="ask_resitution" colspan="2" align="1"/><newline/>
<field name="ask_payment" colspan="2"/><newline/> <field name="ask_payment" colspan="2"/><newline/>
<field name="client_nihil" colspan="2" string="Is Last Declaration"/><newline/><label/> <field name="client_nihil" colspan="2" string="Is Last Declaration"/><newline/><label/>
<button icon="gtk-execute" name="create_xml" string="Create XML" type="object" default_focus="1" />
</group> </group>
<newline/> <newline/>
<group attrs="{'readonly':[('name','=',False)]}"> <group>
<separator colspan="2" string="Note: "/><newline/> <button icon="gtk-execute" name="create_xml" string="Create XML" type="object" default_focus="1" />
<button special="cancel" string="Close" icon="gtk-cancel"/>
</group>
</group>
</form>
</field>
</record>
<record id="view_vat_save" model="ir.ui.view">
<field name="name">Save XML</field>
<field name="model">l1on_be.vat.declaration</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Save xml">
<group height="200" width="310">
<separator colspan="2" string="Note: "/><newline/>
<label string="Save the File with '.xml' extension." colspan="2" align="0.0"/><newline/> <label string="Save the File with '.xml' extension." colspan="2" align="0.0"/><newline/>
<field name="name"/><newline/> <field name="name"/><newline/>
<field name="file_save" readonly="True"/> <field name="file_save" readonly="True"/>
<newline/> <newline/>
<label/> <label/>
</group> <newline/>
<newline/> <label colspan="1"/>
<button special="cancel" string="Close" icon="gtk-cancel"/> <button colspan="1" special="cancel" string="Close" icon="gtk-cancel" align="0.0"/>
</group> </group>
</form> </form>
</field> </field>
</record> </record>
<record id="action_vat_declaration" model="ir.actions.act_window"> <record id="action_vat_declaration" model="ir.actions.act_window">
<field name="name">Vat Declaraion</field> <field name="name">Vat Declaraion</field>
<field name="type">ir.actions.act_window</field> <field name="type">ir.actions.act_window</field>

View File

@ -31,6 +31,11 @@ class partner_vat_intra(osv.osv_memory):
_name = "partner.vat.intra" _name = "partner.vat.intra"
_description = 'Partner VAT Intra' _description = 'Partner VAT Intra'
def _get_xml_data(self, cr, uid, context=None):
if context.get('file_save', False):
return base64.encodestring(context['file_save'])
return ''
def _get_europe_country(self, cursor, user, context=None): def _get_europe_country(self, cursor, user, context=None):
return self.pool.get('res.country').search(cursor, user, [('code', 'in', ['AT', 'BG', 'CY', 'CZ', 'DK', 'EE', 'FI', 'FR', 'DE', 'GR', 'HU', 'IE', 'IT', 'LV', 'LT', 'LU', 'MT', 'NL', 'PL', 'PT', 'RO', 'SK', 'SI', 'ES', 'SE', 'GB'])]) return self.pool.get('res.country').search(cursor, user, [('code', 'in', ['AT', 'BG', 'CY', 'CZ', 'DK', 'EE', 'FI', 'FR', 'DE', 'GR', 'HU', 'IE', 'IT', 'LV', 'LT', 'LU', 'MT', 'NL', 'PL', 'PT', 'RO', 'SK', 'SI', 'ES', 'SE', 'GB'])])
@ -56,6 +61,8 @@ class partner_vat_intra(osv.osv_memory):
_defaults = { _defaults = {
'country_ids': _get_europe_country, 'country_ids': _get_europe_country,
'file_save': _get_xml_data,
'name': 'vat_Intra.xml',
} }
def create_xml(self, cursor, user, ids, context=None): def create_xml(self, cursor, user, ids, context=None):
@ -65,6 +72,7 @@ class partner_vat_intra(osv.osv_memory):
obj_partner = self.pool.get('res.partner') obj_partner = self.pool.get('res.partner')
obj_partner_add = self.pool.get('res.partner.address') obj_partner_add = self.pool.get('res.partner.address')
obj_country = self.pool.get('res.country') obj_country = self.pool.get('res.country')
mod_obj = self.pool.get('ir.model.data')
street = zip_city = country = p_list = data_clientinfo = '' street = zip_city = country = p_list = data_clientinfo = ''
error_message = list_partner = [] error_message = list_partner = []
seq = amount_sum = 0 seq = amount_sum = 0
@ -132,14 +140,20 @@ class partner_vat_intra(osv.osv_memory):
amount_sum = int(amount_sum) amount_sum = int(amount_sum)
data_decl = '\n\t<DeclarantList SequenceNum="1" DeclarantNum="'+ dnum + '" ClientNbr="'+ str(seq) +'" AmountSum="'+ str(amount_sum) +'" >' data_decl = '\n\t<DeclarantList SequenceNum="1" DeclarantNum="'+ dnum + '" ClientNbr="'+ str(seq) +'" AmountSum="'+ str(amount_sum) +'" >'
data_file += str(data_decl) + str(data_comp) + str(data_period) + str(data_clientinfo) + '\n\t</DeclarantList>\n</VatIntra>' data_file += str(data_decl) + str(data_comp) + str(data_period) + str(data_clientinfo) + '\n\t</DeclarantList>\n</VatIntra>'
data = { model_data_ids = mod_obj.search(cursor, user,[('model','=','ir.ui.view'),('name','=','view_vat_intra_save')], context=context)
'msg': 'XML Flie has been Created. Save the File with '".xml"' extension.', resource_id = mod_obj.read(cursor, user, model_data_ids, fields=['res_id'], context=context)[0]['res_id']
'file_save': base64.encodestring(data_file), context['file_save'] = data_file
'name': 'vat_Intra.xml', return {
'country_ids': [[6, 0, obj_country.search(cursor, user, [('code', 'in', ['AT', 'BG', 'CY', 'CZ', 'DK', 'EE', 'FI', 'FR', 'DE', 'GR', 'HU', 'IE', 'IT', 'LV', 'LT', 'LU', 'MT', 'NL', 'PL', 'PT', 'RO', 'SK', 'SI', 'ES', 'SE', 'GB'])])]], 'name': _('Save'),
} 'context': context,
self.write(cursor, user, ids, {'file_save':data['file_save'], 'msg':data['msg'], 'name':data['name'], 'no_vat':p_list, 'country_ids':data['country_ids']}, context=context) 'view_type': 'form',
return True 'view_mode': 'form',
'res_model': 'partner.vat.intra',
'views': [(resource_id,'form')],
'view_id': 'view_vat_intra_save',
'type': 'ir.actions.act_window',
'target': 'new',
}
partner_vat_intra() partner_vat_intra()

View File

@ -13,32 +13,48 @@
<field name="type">form</field> <field name="type">form</field>
<field name="arch" type="xml"> <field name="arch" type="xml">
<form string="Partner VAT intra"> <form string="Partner VAT intra">
<group width="450"> <group width="450">
<separator string="Create an XML file for Vat Intra" colspan="4"/> <separator string="Create an XML file for Vat Intra" colspan="4"/>
<notebook colspan="4"> <notebook colspan="4">
<page string="General Information"> <page string="General Information">
<newline/> <newline/>
<field name="period_code" colspan="4"/> <group>
<newline/> <field name="period_code" colspan="4"/>
<field name="mand_id" colspan="4"/> <newline/>
<newline/> <field name="mand_id" colspan="4"/>
<separator string="Periods" colspan="4"/> <newline/>
<field name="period_ids" nolabel="1" colspan="4"/> </group>
<newline/><label/> <separator string="Periods" colspan="4"/>
<field name="period_ids" nolabel="1" colspan="4"/>
<newline/><label/>
</page>
<page string="European Countries">
<field name="country_ids" colspan="4" nolabel="1"/>
</page>
</notebook>
<separator colspan="4"/><label/>
<button name="create_xml" string="Create XML" type="object" icon="gtk-execute"/> <button name="create_xml" string="Create XML" type="object" icon="gtk-execute"/>
<separator colspan="4" string="Note"/> <button special="cancel" string="Close" icon="gtk-cancel"/>
<field name="msg" colspan="4" nolabel="1"/> </group>
</form>
</field>
</record>
<record id="view_vat_intra_save" model="ir.ui.view">
<field name="name">Partner VAT intra Save</field>
<field name="model">partner.vat.intra</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Save XML">
<group width="450">
<separator colspan="2" string="Note: "/><newline/>
<label string="Save the File with '.xml' extension." colspan="2" align="0.0"/><newline/>
<field name="name" colspan="4"/> <field name="name" colspan="4"/>
<newline/> <newline/>
<field name="file_save" colspan="4"/> <field name="file_save" colspan="4"/>
<newline/> <newline/>
<separator string="Partner With No VAT" colspan="4"/> <separator string="Partner With No VAT" colspan="4"/>
<field nolabel="1" name="no_vat" colspan="4"/> <field nolabel="1" name="no_vat" colspan="4"/>
</page>
<page string="European Countries">
<field name="country_ids" colspan="4" nolabel="1"/>
</page>
</notebook>
<separator colspan="4"/><label/> <separator colspan="4"/><label/>
<button special="cancel" string="Close" icon="gtk-cancel"/> <button special="cancel" string="Close" icon="gtk-cancel"/>
</group> </group>
@ -46,6 +62,7 @@
</field> </field>
</record> </record>
<record id="action_vat_intra" model="ir.actions.act_window"> <record id="action_vat_intra" model="ir.actions.act_window">
<field name="name">Partner Vat Intra</field> <field name="name">Partner Vat Intra</field>
<field name="type">ir.actions.act_window</field> <field name="type">ir.actions.act_window</field>