[IMP]:split each vat wizards into two

bzr revid: pap@tinyerp.co.in-20100610130302-tpbwxp3lqe3aio1e
This commit is contained in:
pap (openerp) 2010-06-10 18:33:02 +05:30
parent 235cc31796
commit 4d746cf914
4 changed files with 99 additions and 30 deletions

View File

@ -27,7 +27,14 @@ class l10n_be_vat_declaration(osv.osv_memory):
""" Vat Declaration """
_name = "l1on_be.vat.declaration"
_description = "Vat Declaration"
def _get_xml_data(self, cr, uid, context='None'):
if context.get('file_save', False):
val=base64.encodestring(context['file_save'])
return val
else:
return base64.encodestring('')
_columns = {
'name': fields.char('File Name', size=32),
'period_id': fields.many2one('account.period','Period', required=True),
@ -39,6 +46,8 @@ class l10n_be_vat_declaration(osv.osv_memory):
}
_defaults = {
'msg': 'Save the File with '".xml"' extension.',
'file_save': _get_xml_data,
'name': lambda *a: 'vat_declaration.xml',
}
def create_xml(self, cr, uid, ids, context=None):
@ -99,9 +108,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</DATA_ELEM>\n\t\t</DATA>\n\t</VATRECORD>\n</VATSENDING>'
data['file_save'] = base64.encodestring(data_of_file)
self.write(cr, uid, ids, {'file_save': data['file_save'], 'name': 'vat_declare.xml'}, context=context)
return True
mod_obj = self.pool.get('ir.model.data')
model_data_ids = mod_obj.search(cr, uid,[('model','=','ir.ui.view'),('name','=','view_vat_save')], context=context)
resource_id = mod_obj.read(cr, uid, model_data_ids, fields=['res_id'], context=context)[0]['res_id']
context['file_save'] = data_of_file
return {
'name': _('Save'),
'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()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -13,31 +13,46 @@
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Periodical VAT Declaration" >
<group height="400" width="330">
<group height="220" width="330">
<group>
<separator string="Declare Periodical VAT" colspan="2" /><newline/>
<field name="period_id" /><newline/>
<field name="ask_resitution" colspan="2" align="1"/><newline/>
<field name="ask_payment" colspan="2"/><newline/>
<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>
<newline/>
<group attrs="{'readonly':[('name','=',False)]}">
<separator colspan="2" string="Note: "/><newline/>
<group>
<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/>
<field name="name"/><newline/>
<field name="file_save" readonly="True"/>
<newline/>
<label/>
</group>
<newline/>
<button special="cancel" string="Close" icon="gtk-cancel"/>
</group>
<newline/>
<label colspan="1"/>
<button colspan="1" special="cancel" string="Close" icon="gtk-cancel" align="0.0"/>
</group>
</form>
</field>
</field>
</record>
<record id="action_vat_declaration" model="ir.actions.act_window">
<field name="name">Vat Declaraion</field>
<field name="type">ir.actions.act_window</field>

View File

@ -30,6 +30,13 @@ class partner_vat_intra(osv.osv_memory):
"""
_name = "partner.vat.intra"
_description = 'Partner VAT Intra'
def _get_xml_data(self, cr, uid, context='None'):
if context.get('file_save', False):
val=base64.encodestring(context['file_save'])
return val
else:
return base64.encodestring('')
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'])])
@ -56,6 +63,8 @@ class partner_vat_intra(osv.osv_memory):
_defaults = {
'country_ids': _get_europe_country,
'file_save': _get_xml_data,
'name': lambda *a: 'vat_Intra.xml',
}
def create_xml(self, cursor, user, ids, context=None):
@ -132,14 +141,21 @@ class partner_vat_intra(osv.osv_memory):
amount_sum = int(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 = {
'msg': 'XML Flie has been Created. Save the File with '".xml"' extension.',
'file_save': base64.encodestring(data_file),
'name': 'vat_Intra.xml',
'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'])])]],
}
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)
return True
mod_obj = self.pool.get('ir.model.data')
model_data_ids = mod_obj.search(cursor, user,[('model','=','ir.ui.view'),('name','=','view_vat_intra_save')], context=context)
resource_id = mod_obj.read(cursor, user, model_data_ids, fields=['res_id'], context=context)[0]['res_id']
context['file_save'] = data_file
return {
'name': _('Save'),
'context': context,
'view_type': 'form',
'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()

View File

@ -18,22 +18,16 @@
<notebook colspan="4">
<page string="General Information">
<newline/>
<group>
<field name="period_code" colspan="4"/>
<newline/>
<field name="mand_id" colspan="4"/>
<newline/>
</group>
<separator string="Periods" colspan="4"/>
<field name="period_ids" nolabel="1" colspan="4"/>
<newline/><label/>
<button name="create_xml" string="Create XML" type="object" icon="gtk-execute"/>
<separator colspan="4" string="Note"/>
<field name="msg" colspan="4" nolabel="1"/>
<field name="name" colspan="4"/>
<newline/>
<field name="file_save" colspan="4"/>
<newline/>
<separator string="Partner With 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"/>
@ -45,6 +39,29 @@
</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"/>
<newline/>
<field name="file_save" colspan="4"/>
<newline/>
<separator string="Partner With No VAT" colspan="4"/>
<field nolabel="1" name="no_vat" colspan="4"/>
<separator colspan="4"/><label/>
<button special="cancel" string="Close" icon="gtk-cancel"/>
</group>
</form>
</field>
</record>
<record id="action_vat_intra" model="ir.actions.act_window">
<field name="name">Partner Vat Intra</field>