54
54
order = dm_customer_order.browse(cr,uid,order_id)
55
55
customer_ids = map(lambda x:x.customer_id.id,order)
56
56
plugins = d.document_template_id.plugin_ids
57
for plugin in plugins:
60
args['field_name']=str(plugin.field.name)
61
args['field_type']=str(plugin.field.ttype)
62
args['field_relation']=str(plugin.field.relation)
63
path = os.path.join(os.getcwd(), "addons/dm/dm_ddf_plugins",cr.dbname)
64
plugin_name = plugin.file_fname.split('.')[0]
65
arguments = plugin.argument_ids
67
args[str(a.name)]=str(a.value)
70
X = __import__(plugin_name)
71
plugin_func = getattr(X,plugin_name)
72
plugin_value = plugin_func(cr,uid,customer_ids,**args)
74
map(lambda x :dm_plugins_value.create(cr,uid,
75
{'date':time.strftime('%Y-%m-%d'),
77
'plugin_id':plugin.id,
58
for plugin in plugins:
60
if plugin.type=='fields':
61
args['object']=str(plugin.object)
62
args['field_name']=str(plugin.field.name)
63
args['field_type']=str(plugin.field.ttype)
64
args['field_relation']=str(plugin.field.relation)
66
path = os.path.join(os.getcwd(), "addons/dm/")
67
plugin_name = 'customer_function'
69
arguments = plugin.argument_ids
71
args[str(a.name)]=str(a.value)
72
path = os.path.join(os.getcwd(), "addons/dm/dm_ddf_plugins",cr.dbname)
73
plugin_name = plugin.file_fname.split('.')[0]
76
X = __import__(plugin_name)
77
plugin_func = getattr(X,plugin_name)
78
plugin_value = plugin_func(cr,uid,customer_ids,**args)
79
if plugin.store_value :
80
map(lambda x :dm_plugins_value.create(cr,uid,
81
{'date':time.strftime('%Y-%m-%d'),
83
'plugin_id':plugin.id,
83
89
def _data_get(self, cr, uid, ids, name, arg, context):
118
124
desc = 'Value of the field must be of type %s or plugin may be crashed'%arg[1]
119
125
vals = {'name':arg[0],'note':desc,'plugin_id':id,'value':' '}
120
126
new_id = self.pool.get('dm.plugin.argument').create(cr,uid,vals)
122
127
if '__description__' in dir(X):
123
128
self.write(cr,uid,id,{'note':X.__description__})
127
132
'name' : fields.char('DDF Plugin Name', size=64),
133
'store_value' : fields.boolean('Store Value'),
134
'code' : fields.char('Code', size=64),
128
135
'file_id': fields.function(_data_get,method=True,fnct_inv=_data_set,string='File Content',type="binary"),
129
136
'file_fname': fields.char('Filename',size=64),
130
137
'argument_ids' : fields.one2many('dm.plugin.argument', 'plugin_id', 'Argument List'),
131
138
'note' : fields.text('Description'),
132
'field' : fields.many2one('ir.model.fields','Customers Field',
133
domain=[('model_id','=','Partner')],
134
context={'model':'res.partner'}),
139
'type' : fields.selection([('fields','Customer'),('dynamic','Dynamic')], 'Type', required=True),
140
'field' : fields.many2one('ir.model.fields','Customers Field'),
141
'object' : fields.many2one('ir.model','Object',),
145
('code_uniq', 'UNIQUE(code)', 'The code must be unique!'),
138
150
class dm_plugin_argument(osv.osv):
224
236
class dm_offer_document(osv.osv):
225
237
_name = "dm.offer.document"
226
238
_rec_name = 'name'
240
def default_get(self, cr, uid, fields, context=None):
241
value = super(dm_offer_document, self).default_get(cr, uid, fields, context)
242
if 'step_id' in context and context['step_id']:
243
offer = self.pool.get('dm.offer')
244
offer_id = offer.search(cr, uid, [('step_ids','in',[context['step_id']])])
245
browse_id = offer.browse(cr, uid, offer_id)[0]
246
value['lang_id'] = browse_id.lang_orig.id
247
value['copywriter_id'] = browse_id.copywriter_id.id
228
250
def _has_attchment_fnc(self, cr, uid, ids, name, arg, context={}):