bzr revid: nch@tinyerp.com-20090512113120-5h2ox8pak4ahreri
This commit is contained in:
Naresh Choksy 2009-05-12 17:01:20 +05:30
commit 83d52392b3
7 changed files with 27 additions and 31 deletions

View File

@ -244,13 +244,12 @@ class ir_model_fields(osv.osv):
if not vals['name'].startswith('x_'):
raise except_orm(_('Error'), _("Custom fields must have a name that starts with 'x_' !"))
model_ids = self.pool.get('ir.model').search(cr, user, [('model','=',vals['relation'])])
if model_ids:
if self.pool.get(vals['model']):
self.pool.get(vals['model']).__init__(self.pool, cr)
self.pool.get(vals['model'])._auto_init(cr, {})
else:
raise except_orm(_('Error'), _("Model %s Does not Exist !" % vals['relation']))
if 'relation' in vals and not self.pool.get('ir.model').search(cr, user, [('model','=',vals['relation'])]):
raise except_orm(_('Error'), _("Model %s Does not Exist !" % vals['relation']))
if self.pool.get(vals['model']):
self.pool.get(vals['model']).__init__(self.pool, cr)
self.pool.get(vals['model'])._auto_init(cr, {})
return res
ir_model_fields()
@ -451,6 +450,7 @@ class ir_model_data(osv.osv):
cr.execute('select id from '+model_obj._table+' where id=%s', (res_id2,))
result3 = cr.fetchone()
if not result3:
self._get_id.clear_cache(cr.dbname, uid, module, xml_id)
cr.execute('delete from ir_model_data where id=%s', (action_id2,))
res_id = False
else:

View File

@ -24,11 +24,11 @@ import tools
import country
import bank
import res_lang
import partner
import res_currency
import res_company
import res_user
import res_lang
import res_request

View File

@ -118,13 +118,6 @@ def _partner_title_get(self, cr, uid, context={}):
res = obj.read(cr, uid, ids, ['shortcut','name'], context)
return [(r['shortcut'], r['name']) for r in res]
def _lang_get(self, cr, uid, context={}):
obj = self.pool.get('res.lang')
ids = obj.search(cr, uid, [], context=context)
res = obj.read(cr, uid, ids, ['code', 'name'], context)
return [(r['code'], r['name']) for r in res] + [('','')]
class res_partner(osv.osv):
_description='Partner'
_name = "res.partner"
@ -136,7 +129,7 @@ class res_partner(osv.osv):
'parent_id': fields.many2one('res.partner','Main Company', select=2),
'child_ids': fields.one2many('res.partner', 'parent_id', 'Partner Ref.'),
'ref': fields.char('Code', size=64),
'lang': fields.selection(_lang_get, 'Language', size=5, help="If the selected language is loaded in the system, all documents related to this partner will be printed in this language. If not, it will be english."),
'lang': fields.many2one('res.lang', 'Language', help="If the selected language is loaded in the system, all documents related to this partner will be printed in this language. If not, it will be english."),
'user_id': fields.many2one('res.users', 'Dedicated Salesman', help='The internal user that is in charge of communicating with this partner if any.'),
'vat': fields.char('VAT',size=32 ,help="Value Added Tax number. Check the box if the partner is subjected to the VAT. Used by the VAT legal statement."),
'bank_ids': fields.one2many('res.partner.bank', 'partner_id', 'Banks'),

View File

@ -102,7 +102,6 @@
<field name="name">Bank Wealthy and sons</field>
</record>
<record id="res_partner_3" model="res.partner">
<field name="lang">en_US</field>
<field name="name">China Export</field>
<field eval="[(6, 0, [ref('res_partner_category_9')])]" name="category_id"/>
</record>

View File

@ -229,7 +229,7 @@
<field name="ref" select="1"/>
<field name="customer" select="1"/>
<field domain="[('domain', '=', 'partner')]" name="title"/>
<field name="lang" select="2"/>
<field name="lang" select="2" widget="selection"/>
<field name="supplier" select="2"/>
</group>
<notebook colspan="4">

View File

@ -254,8 +254,12 @@ class expression(object):
query = '(%s OR %s IS NULL)' % (query, left)
else:
params = []
if (((right == False) and (type(right)==bool)) or (right is None)) and (operator == '='):
query = '%s.%s IS NULL' % (table._table, left)
if right == False and table._columns[leaf[0]]._type=="boolean" and (operator == '='):
query = '%s.%s IS NULL or %s.%s = false ' % (table._table, left,table._table, left)
elif (((right == False) and (type(right)==bool)) or (right is None)) and (operator == '='):
query = '%s.%s IS NULL ' % (table._table, left)
elif right == False and table._columns[leaf[0]]._type=="boolean" and (operator in ['<>', '!=']):
query = '%s.%s IS NOT NULL and %s.%s != false' % (table._table, left,table._table, left)
elif (((right == False) and (type(right)==bool)) or right is None) and (operator in ['<>', '!=']):
query = '%s.%s IS NOT NULL' % (table._table, left)
else:

View File

@ -200,6 +200,7 @@ class rml_parse(object):
try :
att_id = int(attach_id)
attachment = self.pool.get('ir.attachment').browse(self.cr,self.uid,att_id)
return attachment.datas
except :
return ''
@ -500,20 +501,19 @@ class report_sxw(report_rml, preprocess.report):
report_type = 'html'
context['parents'] = html_parents
rml = report_xml.report_rml_content
rml_parser = self.parser(cr, uid, self.name2, context)
rml_parser.parents = html_parents
rml_parser.tag = sxw_tag
html = report_xml.report_rml_content
html_parser = self.parser(cr, uid, self.name2, context)
html_parser.parents = html_parents
html_parser.tag = sxw_tag
objs = self.getObjects(cr, uid, ids, context)
rml_parser.set_context(objs, data, ids, report_type)
html_parser.set_context(objs, data, ids, report_type)
html_dom = etree.HTML(html)
html_dom = self.preprocess_rml(html_dom,'html2html')
rml_dom = etree.HTML(rml)
rml_dom = self.preprocess_rml(rml_dom,'html2html')
create_doc = self.generators['html2html']
html = etree.tostring(create_doc(rml_dom, rml_parser.localcontext))
return (html, report_type)
html = etree.tostring(create_doc(html_dom, html_parser.localcontext))
return (html.replace('&lt;', '<').replace('&gt;', '>').replace('</br>',''), report_type)