[IMP]Base:ADD Report Button and Upload Logo wiz
bzr revid: aag@tinyerp.co.in-20110406064014-mknizxp8g0s4vva3
This commit is contained in:
@@ -180,6 +180,40 @@
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!--
|
||||
======================
|
||||
Logo wiz
|
||||
======================
|
||||
-->
|
||||
|
||||
<record id="view_res_company_logo" model="ir.ui.view">
|
||||
<field name="name">res.company.logo.form</field>
|
||||
<field name="model">res.company.logo</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Upload Logo">
|
||||
<separator string="Upload your company logo in JPG or PNG with a format similar to 450*150 pixels" colspan="4"/>
|
||||
<field colspan="4" height="150" name="logo" widget="image"/>
|
||||
<separator colspan="4"/>
|
||||
<group colspan="4" col="6">
|
||||
<label string="" colspan="2"/>
|
||||
<button icon="gtk-cancel" special="cancel" string="Cancel"/>
|
||||
<button icon="gtk-ok" string="Upload" name="execute" type="object"/>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_res_company_logo" model="ir.actions.act_window">
|
||||
<field name="name">Set Logo</field>
|
||||
<field name="res_model">res.company.logo</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="view_id" ref="view_res_company_logo"/>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
<!--
|
||||
======================
|
||||
Company
|
||||
@@ -202,6 +236,9 @@
|
||||
<field name="rml_footer1" colspan="4"/>
|
||||
<field name="rml_footer2" colspan="4"/>
|
||||
<field name="currency_id"/>
|
||||
<button name="createReport" string="Print" type="object" icon="gtk-print"/>
|
||||
<button name="%(action_res_company_logo)d"
|
||||
string="Upload your logo" type="action" icon="gtk-ok"/>
|
||||
<separator colspan="4" string="Your Logo - Use a size of about 450x150 pixels."/>
|
||||
<field colspan="4" name="logo" widget="image"/>
|
||||
</page>
|
||||
|
||||
@@ -68,6 +68,27 @@ class multi_company_default(osv.osv):
|
||||
|
||||
multi_company_default()
|
||||
|
||||
class res_company_logo(osv.osv_memory):
|
||||
_name = 'res.company.logo'
|
||||
_columns = {
|
||||
'logo' : fields.binary('Logo'),
|
||||
}
|
||||
_defaults={
|
||||
}
|
||||
|
||||
def execute(self, cr, uid, ids, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
comp_obj = self.pool.get("res.company")
|
||||
get_val = self.browse(cr, uid, ids)[0]
|
||||
comp_val = comp_obj.browse(cr, uid, ids)[0]
|
||||
if comp_val.logo:
|
||||
comp_obj.write(cr, uid, context['active_id'], {'logo': False})
|
||||
if get_val.logo:
|
||||
comp_obj.write(cr, uid, context['active_id'], {'logo': get_val.logo})
|
||||
return {'type': 'ir.actions.act_window_close'}
|
||||
|
||||
res_company_logo()
|
||||
|
||||
class res_company(osv.osv):
|
||||
_name = "res.company"
|
||||
@@ -138,6 +159,26 @@ class res_company(osv.osv):
|
||||
return []
|
||||
ids = self.search(cr, uid, [('parent_id','child_of',[company])])
|
||||
return ids
|
||||
|
||||
# For Report
|
||||
|
||||
def createReport(cr, uid, report, ids, name=False):
|
||||
files = []
|
||||
for id in ids:
|
||||
try:
|
||||
service = netsvc.LocalService(report)
|
||||
(result, format) = service.create(cr, uid, [id], {}, {})
|
||||
if not name:
|
||||
report_file = '/tmp/reports'+ str(id) + '.pdf'
|
||||
else:
|
||||
report_file = name
|
||||
fp = open(report_file,'wb+')
|
||||
fp.write(result);
|
||||
fp.close();
|
||||
files += [report_file]
|
||||
except Exception,e:
|
||||
continue
|
||||
return files
|
||||
|
||||
def _get_partner_hierarchy(self, cr, uid, company_id, context={}):
|
||||
if company_id:
|
||||
|
||||
Reference in New Issue
Block a user