l.product_id as product_id
from pos_order_line as l
left join pos_order s on (s.id=l.order_id)
- left join product_template pt on (pt.id=l.product_id)
+ left join product_product p on (p.id=l.product_id)
+ left join product_template pt on (pt.id=p.product_tmpl_id)
left join product_uom u on (u.id=pt.uom_id)
group by
- to_char(s.date_order, 'dd-MM-YYYY'),to_char(s.date_order, 'YYYY'),to_char(s.date_order, 'MM'),
- to_char(s.date_order, 'YYYY-MM-DD'), s.partner_id,s.state,
- s.user_id,s.shop_id,s.company_id,s.sale_journal,l.product_id,s.create_date
+ s.date_order, s.partner_id,s.state,
+ s.user_id,s.warehouse_id,s.company_id,s.sale_journal,l.product_id,s.create_date
having
sum(l.qty * u.factor) != 0)""")
if not vals['name'].startswith('x_'):
raise except_orm(_('Error'), _("Custom fields must have a name that starts with 'x_' !"))
- if vals.get('relation',False) and not self.pool.get('ir.model').search(cr, user, [('model','=',vals['relation'])]):
+ if vals.get('relation',False) and not self.pool['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']):
+ if vals['model'] in self.pool:
if vals['model'].startswith('x_') and vals['name'] == 'x_name':
self.pool[vals['model']]._rec_name = 'x_name'
+
+ if self.pool.fields_by_model is not None:
+ cr.execute('SELECT * FROM ir_model_fields WHERE id=%s', (res,))
+ self.pool.fields_by_model.setdefault(vals['model'], []).append(cr.dictfetchone())
- self.pool.get(vals['model']).__init__(self.pool, cr)
+ self.pool[vals['model']].__init__(self.pool, cr)
#Added context to _auto_init for special treatment to custom field for select_level
ctx = dict(context,
field_name=vals['name'],
import test_base
import test_expression
+import test_ir_actions
import test_ir_attachment
+ import test_ir_model
import test_ir_values
import test_menu
+import test_res_config
+import test_res_lang
import test_search
import test_views
checks = [
test_base,
test_expression,
+ test_ir_actions,
test_ir_attachment,
+ test_ir_model,
test_ir_values,
test_menu,
+ test_res_config,
+ test_res_lang,
test_search,
test_views,
]
--- /dev/null
+ import unittest2
+
+ import openerp.tests.common as common
+
+ class test_ir_model(common.TransactionCase):
+
+ def test_00(self):
+ # Create some custom model and fields
+ cr, uid, context = self.cr, self.uid, {}
+
+ ir_model = self.registry('ir.model')
+ ir_model_fields = self.registry('ir.model.fields')
+ ir_model_access = self.registry('ir.model.access')
+ candy_model_id = ir_model.create(cr, uid, {
+ 'name': 'Candies',
+ 'model': 'x_candy',
+ 'info': 'List of candies',
+ 'state': 'manual',
+ }, context=context)
+ # security rule to avoid warning
+ ir_model_access.create(cr, uid, {
+ 'name': 'Candies are for everybody',
+ 'model_id': candy_model_id,
+ 'perm_read': True,
+ 'perm_write': True,
+ 'perm_create': True,
+ 'perm_unlink': True,
+ })
+
+ assert self.registry('x_candy'), "Custom model not present in registry"
+
+ ir_model_fields.create(cr, uid, {
+ 'name': 'x_name',
+ 'field_description': 'Name',
+ 'model_id': candy_model_id,
+ 'state': 'manual',
+ 'ttype': 'char',
+ }, context=context)
-
++
+ assert 'x_name' in self.registry('x_candy')._all_columns, "Custom field not present in registry"
+ assert self.registry('x_candy')._rec_name == 'x_name', "The _rec_name on custom model was not updated"
+
+ if __name__ == '__main__':
+ unittest2.main()