[IMP] font: handle better the difference of fonts
bzr revid: mat@openerp.com-20131014150507-4ueuyyneo6h2f6ju
This commit is contained in:
parent
53e8625cea
commit
b9c3d93416
|
@ -396,7 +396,7 @@ class res_company(osv.osv):
|
|||
return {'value': {'rml_header': self._header_a4}}
|
||||
|
||||
def act_discover_fonts(self, cr, uid, ids, context=None):
|
||||
return self.pool.get("res.font").act_discover_fonts(cr, uid, ids, context)
|
||||
return self.pool.get("res.font").discover_fonts(cr, uid, ids, context)
|
||||
|
||||
_defaults = {
|
||||
'currency_id': _get_euro,
|
||||
|
|
|
@ -80,8 +80,15 @@
|
|||
<field name="custom_footer" on_change="onchange_footer(custom_footer, phone, fax, email, website, vat, company_registry, bank_ids)"/>
|
||||
<field name="rml_footer" attrs="{'invisible': [('custom_footer','=',False)]}"/>
|
||||
<field name="rml_footer_readonly" attrs="{'invisible': [('custom_footer','=',True)]}"/>
|
||||
<field name="font" on_change="onchange_font_name(font, rml_header, rml_header2, rml_header3)"/>
|
||||
<button string="Reload fonts" name="act_discover_fonts" type="object" class="oe_link"/>
|
||||
</group>
|
||||
<group>
|
||||
<label for="font" />
|
||||
<div>
|
||||
<div>
|
||||
<field name="font" class="oe_inline" colspan="2"/>
|
||||
<button string="(reload fonts)" name="act_discover_fonts" type="object" class="oe_link" colspan="1"/>
|
||||
</div>
|
||||
</div>
|
||||
</group>
|
||||
</page>
|
||||
<page string="Header/Footer" groups="base.group_no_one">
|
||||
|
|
|
@ -74,11 +74,17 @@ class res_font(osv.Model):
|
|||
if not found_fonts.get(family):
|
||||
found_fonts[family] = {'name': family}
|
||||
|
||||
# remove deleted fonts
|
||||
existing_font_ids = self.search(cr, uid, [], context=context)
|
||||
existing_font_names = []
|
||||
for font in self.browse(cr, uid, existing_font_ids):
|
||||
existing_font_names.append(font.name)
|
||||
if font.name not in found_fonts.keys():
|
||||
self.unlink(cr, uid, font.id, context=context)
|
||||
|
||||
# to make sure we always have updated list, delete all and recreate
|
||||
self.unlink(cr, uid, self.search(cr, uid, [], context=context), context=context)
|
||||
# add unknown fonts
|
||||
for family, vals in found_fonts.items():
|
||||
if not self.search(cr, uid, [('name', '=', family)], context=context):
|
||||
if family not in existing_font_names:
|
||||
self.create(cr, uid, vals, context=context)
|
||||
return True
|
||||
|
||||
|
|
Loading…
Reference in New Issue