diff --git a/addons/account/account_analytic_line.py b/addons/account/account_analytic_line.py index aff75a80192..f9e09ba78ab 100644 --- a/addons/account/account_analytic_line.py +++ b/addons/account/account_analytic_line.py @@ -77,7 +77,8 @@ class account_analytic_line(osv.osv): unit=False, context=None): uom_obj = self.pool.get('product.uom') product_obj = self.pool.get('product.product') - if unit_amount and prod_id: +# if unit_amount and prod_id: + if prod_id: prod = product_obj.browse(cr, uid, prod_id) a = prod.product_tmpl_id.property_account_expense.id if not a: diff --git a/addons/account/account_invoice_view.xml b/addons/account/account_invoice_view.xml index 9715598eb9c..b48d4ab1606 100644 --- a/addons/account/account_invoice_view.xml +++ b/addons/account/account_invoice_view.xml @@ -141,7 +141,7 @@ - + diff --git a/addons/account/report/general_journal.py b/addons/account/report/general_journal.py index 9aa8b45aa10..926c3603e49 100644 --- a/addons/account/report/general_journal.py +++ b/addons/account/report/general_journal.py @@ -1,7 +1,7 @@ # -*- encoding: utf-8 -*- ############################################################################## # -# OpenERP, Open Source Management Solution +# OpenERP, Open Source Management Solution # Copyright (C) 2004-2009 Tiny SPRL (). All Rights Reserved # $Id$ # @@ -40,8 +40,8 @@ class journal_print(report_sxw.rml_parse): 'sum_credit': self._sum_credit }) - def preprocess(self, objects, datas, ids): - super(journal_print, self).preprocess(objects, datas, ids) + def set_context(self, objects, data, ids, report_type = None): + super(journal_print, self).set_context(objects, data, ids, report_type) self.cr.execute('select period_id, journal_id from account_journal_period where id in (' + ','.join([str(id) for id in ids]) + ')') res = self.cr.fetchall() self.period_ids = ','.join([str(x[0]) for x in res]) diff --git a/addons/account/report/general_ledger.py b/addons/account/report/general_ledger.py index 34c74df08c6..f9c2f30c0e1 100644 --- a/addons/account/report/general_ledger.py +++ b/addons/account/report/general_ledger.py @@ -39,7 +39,7 @@ class general_ledger(rml_parse.rml_parse): - def preprocess(self, objects, data, ids): + def set_context(self, objects, data, ids, report_type = None): ## @@ -55,7 +55,7 @@ class general_ledger(rml_parse.rml_parse): objects = self.pool.get('account.account').browse(self.cr, self.uid, new_ids) - super(general_ledger, self).preprocess(objects, data, new_ids) + super(general_ledger, self).set_context(objects, data, ids, report_type) def __init__(self, cr, uid, name, context): super(general_ledger, self).__init__(cr, uid, name, context) diff --git a/addons/account/report/partner_balance.py b/addons/account/report/partner_balance.py index 451ad7bf744..4551aca1ed4 100755 --- a/addons/account/report/partner_balance.py +++ b/addons/account/report/partner_balance.py @@ -147,7 +147,7 @@ class partner_balance(report_sxw.rml_parse): else: return self.comma_me(new) - def preprocess(self, objects, data, ids): + def set_context(self, objects, data, ids, report_type = None): # Transformation des date # # @@ -168,7 +168,7 @@ class partner_balance(report_sxw.rml_parse): self.date_lst_string ='' if self.date_lst: self.date_lst_string = '\'' + '\',\''.join(map(str,self.date_lst)) + '\'' - + ## Compute Code account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line') @@ -189,7 +189,7 @@ class partner_balance(report_sxw.rml_parse): "AND a.active", (data['form']['company_id'],)) self.account_ids = ','.join([str(a) for (a,) in self.cr.fetchall()]) - super(partner_balance, self).preprocess(objects, data, ids) + super(partner_balance, self).set_context(objects, data, ids, report_type) def lines(self,data): diff --git a/addons/account/report/third_party_ledger.py b/addons/account/report/third_party_ledger.py index bf56470df3f..3004beddd7e 100644 --- a/addons/account/report/third_party_ledger.py +++ b/addons/account/report/third_party_ledger.py @@ -1,7 +1,7 @@ # -*- encoding: utf-8 -*- ############################################################################## # -# OpenERP, Open Source Management Solution +# OpenERP, Open Source Management Solution # Copyright (C) 2004-2009 Tiny SPRL (). All Rights Reserved # $Id$ # @@ -138,7 +138,7 @@ class third_party_ledger(rml_parse.rml_parse): string_map = date_string + ',' return string_map - def preprocess(self, objects, data, ids): + def set_context(self, objects, data, ids, report_type = None): PARTNER_REQUEST = '' if (data['model'] == 'res.partner'): ## Si on imprime depuis les partenaires @@ -160,7 +160,7 @@ class third_party_ledger(rml_parse.rml_parse): self.transform_period_into_date_array(data) elif data['form']['state'] == 'all': self.transform_both_into_date_array(data) - + self.date_lst_string = '' if self.date_lst: self.date_lst_string = '\'' + '\',\''.join(map(str,self.date_lst)) + '\'' @@ -182,12 +182,12 @@ class third_party_ledger(rml_parse.rml_parse): 'AND a.type IN ' + self.ACCOUNT_TYPE + " " \ "AND a.active", (data['form']['company_id'],)) self.account_ids = ','.join([str(a) for (a,) in self.cr.fetchall()]) - + account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line') partner_to_use = [] if self.date_lst and data['form']['soldeinit'] : - + self.cr.execute( "SELECT DISTINCT line.partner_id " \ "FROM account_move_line AS line, account_account AS account " \ @@ -202,7 +202,7 @@ class third_party_ledger(rml_parse.rml_parse): "AND account.active " , (self.date_lst[0],self.date_lst[len(self.date_lst)-1],data['form']['company_id'])) # else: -# +# # self.cr.execute( # "SELECT DISTINCT line.partner_id " \ # "FROM account_move_line AS line, account_account AS account " \ @@ -214,16 +214,16 @@ class third_party_ledger(rml_parse.rml_parse): # "AND account.company_id = %s " \ # "AND account.active " , # (data['form']['company_id'])) - + res = self.cr.dictfetchall() - + for res_line in res: partner_to_use.append(res_line['partner_id']) new_ids = partner_to_use - + self.partner_ids = ','.join(map(str, new_ids)) objects = self.pool.get('res.partner').browse(self.cr, self.uid, new_ids) - super(third_party_ledger, self).preprocess(objects, data, new_ids) + super(third_party_ledger, self).set_context(objects, data, new_ids, report_type) def lines(self, partner,data): account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line') @@ -232,9 +232,9 @@ class third_party_ledger(rml_parse.rml_parse): RECONCILE_TAG = " " else: RECONCILE_TAG = "AND l.reconcile_id IS NULL" - + # if data['form']['soldeinit'] : -# +# # self.cr.execute( # "SELECT l.id,l.date,j.code, l.ref, l.name, l.debit, l.credit " \ # "FROM account_move_line l " \ @@ -271,8 +271,8 @@ class third_party_ledger(rml_parse.rml_parse): sum = r['debit'] - r['credit'] r['progress'] = sum full_account.append(r) - - return full_account + + return full_account def _sum_debit_partner(self, partner,data): @@ -306,7 +306,7 @@ class third_party_ledger(rml_parse.rml_parse): " " + RECONCILE_TAG + " " \ "AND date IN (" + self.date_lst_string + ") " , (partner.id,)) - + contemp = self.cr.fetchone() if contemp != None: result_tmp = contemp[0] or 0.0 @@ -336,7 +336,7 @@ class third_party_ledger(rml_parse.rml_parse): else: result_tmp = result_tmp + 0.0 - if self.date_lst_string: + if self.date_lst_string: self.cr.execute( "SELECT sum(credit) " \ "FROM account_move_line " \ @@ -345,7 +345,7 @@ class third_party_ledger(rml_parse.rml_parse): " " + RECONCILE_TAG + " " \ "AND date IN (" + self.date_lst_string + ") " , (partner.id,)) - + contemp = self.cr.fetchone() if contemp != None: result_tmp = contemp[0] or 0.0 @@ -386,7 +386,7 @@ class third_party_ledger(rml_parse.rml_parse): " " + RECONCILE_TAG + " " \ "AND date IN (" + self.date_lst_string + ") " ) - + contemp = self.cr.fetchone() if contemp != None: result_tmp = contemp[0] or 0.0 @@ -419,7 +419,7 @@ class third_party_ledger(rml_parse.rml_parse): result_tmp = contemp[0] or 0.0 else: result_tmp = result_tmp + 0.0 - + if self.date_lst_string: self.cr.execute( "SELECT sum(credit) " \ diff --git a/addons/account/wizard/wizard_third_party_ledger.py b/addons/account/wizard/wizard_third_party_ledger.py index 749e2f66396..8d7a46868ed 100755 --- a/addons/account/wizard/wizard_third_party_ledger.py +++ b/addons/account/wizard/wizard_third_party_ledger.py @@ -1,7 +1,7 @@ # -*- encoding: utf-8 -*- ############################################################################## # -# OpenERP, Open Source Management Solution +# OpenERP, Open Source Management Solution # Copyright (C) 2004-2009 Tiny SPRL (). All Rights Reserved # $Id$ # @@ -28,7 +28,7 @@ from tools.translate import _ period_form = '''
- + @@ -53,7 +53,7 @@ period_form = ''' - + ''' period_fields = { @@ -85,7 +85,7 @@ period_fields = { class wizard_report(wizard.interface): - + def _get_defaults(self, cr, uid, data, context): fiscalyear_obj = pooler.get_pool(cr.dbname).get('account.fiscalyear') data['form']['fiscalyear'] = fiscalyear_obj.find(cr, uid) @@ -104,9 +104,9 @@ class wizard_report(wizard.interface): data['form']['reconcil'] = False data['form']['soldeinit'] = True return data['form'] - + def _check_date(self, cr, uid, data, context): - + sql = """ SELECT f.id, f.date_start, f.date_stop FROM account_fiscalyear f Where '%s' between f.date_start and f.date_stop """%(data['form']['date1']) cr.execute(sql) @@ -116,17 +116,18 @@ class wizard_report(wizard.interface): raise wizard.except_wizard(_('UserError'),_('Date to must be set between %s and %s') % (str(res[0]['date_start']) , str(res[0]['date_stop']))) else: return 'report' - else: raise wizard.except_wizard(_('UserError'),_('Date not in a defined fiscal year')) - - + def _check_state(self, cr, uid, data, context): if data['form']['state'] == 'bydate' or data['form']['state'] == 'all': data['form']['fiscalyear'] = False else : data['form']['fiscalyear'] = True self._check_date(cr, uid, data, context) + acc_id = pooler.get_pool(cr.dbname).get('account.invoice').search(cr, uid, [('state','=','open')]) + if not acc_id: + raise wizard.except_wizard(_('No Data Available'), _('No records found for your selection!')) return data['form'] diff --git a/addons/auction/report/catalog2.py b/addons/auction/report/catalog2.py index 8887224c746..00b5063bf07 100644 --- a/addons/auction/report/catalog2.py +++ b/addons/auction/report/catalog2.py @@ -1,7 +1,7 @@ # -*- encoding: utf-8 -*- ############################################################################## # -# OpenERP, Open Source Management Solution +# OpenERP, Open Source Management Solution # Copyright (C) 2004-2009 Tiny SPRL (). All Rights Reserved # $Id$ # @@ -37,8 +37,29 @@ import wizard import photo_shadow from tools import config -def escape(s): - return str(s or '').replace('
','').decode('latin1','replace').encode('utf-8') +def _to_unicode(s): + try: + return s.decode('utf-8') + except UnicodeError: + try: + return s.decode('latin') + except UnicodeError: + try: + return s.encode('ascii') + except UnicodeError: + return s + +def _to_decode(s): + try: + return s.encode('utf-8') + except UnicodeError: + try: + return s.encode('latin') + except UnicodeError: + try: + return s.decode('ascii') + except UnicodeError: + return s class auction_catalog(report_rml): @@ -71,22 +92,22 @@ class auction_catalog(report_rml): # name emelment key = 'name' categ = doc.createElement(key) - categ.appendChild(doc.createTextNode(escape(res[0]["name"]))) + categ.appendChild(doc.createTextNode(_to_decode(res[0]["name"]))) catalog.appendChild(categ) #Auctuion Date element categ = doc.createElement("AuctionDate1") - categ.appendChild(doc.createTextNode(escape(res[0]['auction1']))) + categ.appendChild(doc.createTextNode(_to_decode(res[0]['auction1']))) catalog.appendChild(categ) # Action Date 2 element categ = doc.createElement("AuctionDate2") - categ.appendChild(doc.createTextNode(escape(res[0]['auction2']))) + categ.appendChild(doc.createTextNode(_to_decode(res[0]['auction2']))) catalog.appendChild(categ) # promotion element promo = doc.createElement('promotion1') - + fp = file(config['addons_path']+'/auction/report/images/flagey_logo.jpg','r') file_data = fp.read() promo.appendChild(doc.createTextNode(base64.encodestring(file_data))) @@ -113,15 +134,15 @@ class auction_catalog(report_rml): products.appendChild(product) if cat['obj_desc']: infos = doc.createElement('infos') - lines = re.split('
|\n', unicode(cat['obj_desc'],'utf-8').encode('latin1')) + lines = re.split('
|\n', _to_unicode(cat['obj_desc'])) for line in lines: xline = doc.createElement('info') - xline.appendChild(doc.createTextNode(escape(line.decode('latin-1','replace').encode('utf-8')))) + xline.appendChild(doc.createTextNode(_to_decode(line))) infos.appendChild(xline) product.appendChild(infos) if cat['lot_num']: lnum = doc.createElement('lot_num') - lnum.appendChild(doc.createTextNode(escape(cat['lot_num']))) + lnum.appendChild(doc.createTextNode(_to_decode(str(cat['lot_num'])))) infos.appendChild(lnum) if cat['image']: @@ -146,7 +167,7 @@ class auction_catalog(report_rml): for key in ('lot_est1','lot_est2'): ref2 = doc.createElement(key) - ref2.appendChild(doc.createTextNode( escape(cat[key] or 0.0))) + ref2.appendChild(doc.createTextNode( _to_decode(str(cat[key] or 0.0)))) product.appendChild(ref2) oldlength = length length += 2.0 diff --git a/addons/auction/report/catalog2.xsl b/addons/auction/report/catalog2.xsl index b2794ec6763..8124a1f2a6b 100755 --- a/addons/auction/report/catalog2.xsl +++ b/addons/auction/report/catalog2.xsl @@ -11,8 +11,8 @@ - - + + 1cm 3.0cm 20cm 3.0cm Hotel des ventes Flagey @@ -30,7 +30,7 @@ -- +- Vente antiquitée le     --> diff --git a/addons/base_contact/base_contact.py b/addons/base_contact/base_contact.py index f06fe81dfa7..c7ae8077d75 100644 --- a/addons/base_contact/base_contact.py +++ b/addons/base_contact/base_contact.py @@ -46,7 +46,8 @@ class res_partner_contact(osv.osv): 'birthdate':fields.date('Birth Date'), 'active' : fields.boolean('Active'), 'partner_id':fields.related('job_ids','address_id','partner_id',type='many2one', relation='res.partner', string='Main Employer'), - 'function_id':fields.related('job_ids','function_id',type='many2one', relation='res.partner.function', string='Main Job'), + 'function_id':fields.related('job_ids','function_id',type='many2one', relation='res.partner.function', string='Main Function'), + 'job_id':fields.related('job_ids',type='many2one', relation='res.partner.job', string='Main Job'), 'email': fields.char('E-Mail', size=240), } _defaults = { @@ -87,6 +88,7 @@ class res_partner_address(osv.osv): _inherit='res.partner.address' _description ='Partner Address' _columns = { + 'job_id':fields.related('job_ids','contact_id','job_id',type='many2one', relation='res.partner.job', string='Main Job'), 'job_ids':fields.one2many('res.partner.job', 'address_id', 'Contacts'), } res_partner_address() @@ -98,7 +100,8 @@ class res_partner_job(osv.osv): return [] res = [] for r in self.browse(cr, uid, ids): - res.append((r.id, self.pool.get('res.partner.contact').name_get(cr, uid, [r.contact_id.id])[0][1] +", "+ r.function_id.name)) + funct = r.function_id and (", " + r.function_id.name) or "" + res.append((r.id, self.pool.get('res.partner.contact').name_get(cr, uid, [r.contact_id.id])[0][1] + funct )) return res def search(self, cr, user, args, offset=0, limit=None, order=None, diff --git a/addons/base_contact/base_contact_view.xml b/addons/base_contact/base_contact_view.xml index 2298334ca7a..9b2a9c179fc 100644 --- a/addons/base_contact/base_contact_view.xml +++ b/addons/base_contact/base_contact_view.xml @@ -40,6 +40,7 @@ +
@@ -153,42 +154,42 @@ - - res.partner.form - form - res.partner - - - - - - + + res.partner.form + form + res.partner + + + + + + - - res.partner.form - form - res.partner - - - - - + + res.partner.form + form + res.partner + + + + + - - res.partner.form - form - res.partner - - - - - - - - - - + + res.partner.form + form + res.partner + + + + + + + + + + @@ -268,6 +269,7 @@ + diff --git a/addons/base_report_creator/base_report_creator.py b/addons/base_report_creator/base_report_creator.py index 93f2ff837c0..fbe94e38bf3 100644 --- a/addons/base_report_creator/base_report_creator.py +++ b/addons/base_report_creator/base_report_creator.py @@ -47,31 +47,6 @@ from tools.translate import _ # return super(ir_model_fields, self).search(cr, uid, args, offset, limit, order, context) #ir_model_fields() -class ir_model(osv.osv): - _inherit = 'ir.model' - - def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False): - res_model_ids = super(ir_model,self).search(cr, uid, args, offset, limit, order, context=context, count=count) - try: - if 'model_ids' in context and context['model_ids'][0][2]: - model_ids = context['model_ids'][0][2] - result = [] - name_list = [] - if model_ids: - obj = self.read(cr, uid, model_ids,['model']) - for name in obj: - name_list.append(name['model']) - cr.execute("SELECT model_id, relation FROM ir_model_fields WHERE relation in (%s)" % (','.join(map(lambda x: "'"+str(x)+"'",name_list)))) - - for r in cr.fetchall(): - result.append(r[0]) - return result - return res_model_ids - - except Exception,e: - pass - -ir_model() class report_creator(osv.osv): _name = "base_report_creator.report" diff --git a/addons/document_ics/__init__.py b/addons/document_ics/__init__.py index faf96b9d189..a651d00614b 100644 --- a/addons/document_ics/__init__.py +++ b/addons/document_ics/__init__.py @@ -21,4 +21,5 @@ ############################################################################## import document +import document_ics_config_wizard # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/document_ics/__terp__.py b/addons/document_ics/__terp__.py index d5adf71e88f..9e3d85295da 100644 --- a/addons/document_ics/__terp__.py +++ b/addons/document_ics/__terp__.py @@ -30,7 +30,7 @@ 'website': 'http://www.openerp.com', 'depends': ['document', 'crm_configuration'], 'init_xml': ['document_data.xml'], - 'update_xml': ['document_view.xml', 'security/ir.model.access.csv'], + 'update_xml': ['document_view.xml', 'security/ir.model.access.csv','document_ics_config_wizard.xml'], 'demo_xml': ['document_demo.xml'], 'installable': True, 'active': False, diff --git a/addons/document_ics/document.py b/addons/document_ics/document.py index f936c352d83..048a82c7680 100644 --- a/addons/document_ics/document.py +++ b/addons/document_ics/document.py @@ -28,6 +28,7 @@ import base64 import datetime import time import random +import tools ICS_TAGS = { 'summary':'normal', @@ -35,7 +36,7 @@ ICS_TAGS = { 'dtstart':'date' , 'dtend':'date' , 'created':'date' , - 'dt-stamp':'date' , + 'dtstamp':'date' , 'last-modified':'normal' , 'url':'normal' , 'attendee':'multiple', @@ -50,7 +51,7 @@ class document_directory_ics_fields(osv.osv): _name = 'document.directory.ics.fields' _columns = { 'field_id': fields.many2one('ir.model.fields', 'Open ERP Field', required=True), - 'name': fields.selection(map(lambda x: (x,x), ICS_TAGS.keys()),'ICS Value', required=True), + 'name': fields.selection(map(lambda x: (x, x), ICS_TAGS.keys()), 'ICS Value', required=True), 'content_id': fields.many2one('document.directory.content', 'Content', required=True, ondelete='cascade') } document_directory_ics_fields() @@ -105,6 +106,12 @@ class document_directory_content(osv.osv): return True def process_read_ics(self, cr, uid, node, context={}): + def ics_datetime(idate, short=False): + if short: + return datetime.date.fromtimestamp(time.mktime(time.strptime(idate, '%Y-%m-%d'))) + else: + return datetime.datetime.strptime(idate, '%Y-%m-%d %H:%M:%S') + import vobject obj_class = self.pool.get(node.content.ics_object_id.model) # Can be improved to use context and active_id ! @@ -113,21 +120,31 @@ class document_directory_content(osv.osv): cal = vobject.iCalendar() for obj in obj_class.browse(cr, uid, ids, context): event = cal.add('vevent') + # Fix dtstamp et last-modified with create and write date on the object line + perm = obj_class.perm_read(cr, uid, [obj.id], context) + event.add('created').value = ics_datetime(time.strftime('%Y-%m-%d %H:%M:%S')) + event.add('dtstamp').value = ics_datetime(perm[0]['create_date'][:19]) + if perm[0]['write_date']: + event.add('last-modified').value = ics_datetime(perm[0]['write_date'][:19]) for field in node.content.ics_field_ids: value = getattr(obj, field.field_id.name) if (not value) and field.name=='uid': - value = 'OpenERP-'+str(random.randint(1999999999, 9999999999)) + value = 'OpenERP-%s_%s@%s' % (node.content.ics_object_id.model, str(obj.id), cr.dbname,) obj_class.write(cr, uid, [obj.id], {field.field_id.name: value}) if ICS_TAGS[field.name]=='normal': if type(value)==type(obj): value=value.name value = value or '' event.add(field.name).value = value or '' - elif ICS_TAGS[field.name]=='date': - dt = value or time.strftime('%Y-%m-%d %H:%M:%S') - if len(dt)==10: - dt = dt+' 09:00:00' - value = datetime.datetime.strptime(dt, '%Y-%m-%d %H:%M:%S') + elif ICS_TAGS[field.name]=='date' and value: + if field.name == 'dtstart': + date_start = start_date = datetime.datetime.fromtimestamp(time.mktime(time.strptime(value , "%Y-%m-%d %H:%M:%S"))) + if field.name == 'dtend' and isinstance(value, float): + value = (start_date + datetime.timedelta(hours=value)).strftime('%Y-%m-%d %H:%M:%S') + if len(value)==10: + value = ics_datetime(value, True) + else: + value = ics_datetime(value) event.add(field.name).value = value s= StringIO.StringIO(cal.serialize().encode('utf8')) s.name = node @@ -138,8 +155,36 @@ document_directory_content() class crm_case(osv.osv): _inherit = 'crm.case' _columns = { - 'code': fields.char('Calendar Code', size=64) + 'code': fields.char('Calendar Code', size=64), + 'date_deadline': fields.datetime('Deadline', help="Deadline Date is automatically computed from Start Date + Duration"), } + + _defaults = { + 'code': lambda obj, cr, uid, context: obj.pool.get('ir.sequence').get(cr, uid, 'crm.case'), + } + + def copy(self, cr, uid, id, default=None, context=None): + """ + code field must be unique in ICS file + """ + if not default: default = {} + if not context: context = {} + default.update({'code': self.pool.get('ir.sequence').get(cr, uid, 'crm.case'), 'id': False}) + return super(crm_case, self).copy(cr, uid, id, default, context) + + def on_change_duration(self, cr, uid, id, date, duration): + if not date: + return {} + start_date = datetime.datetime.fromtimestamp(time.mktime(time.strptime(date, "%Y-%m-%d %H:%M:%S"))) + if duration >= 0 : + end = start_date + datetime.timedelta(hours=duration) + if duration < 0: + raise osv.except_osv(_('Warning !'), + _('You can not set negative Duration.')) + + res = {'value' : {'date_deadline' : end.strftime('%Y-%m-%d %H:%M:%S')}} + return res + crm_case() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/document_ics/document_data.xml b/addons/document_ics/document_data.xml index 5e2873aee6f..d2e83a35f40 100644 --- a/addons/document_ics/document_data.xml +++ b/addons/document_ics/document_data.xml @@ -6,6 +6,20 @@ .ics ICS Calendar - + + + + + CRM Case Code + crm.case + + + CRM Case + crm.case + CASE + 3 + + + diff --git a/addons/document_ics/document_demo.xml b/addons/document_ics/document_demo.xml index eb939cfd515..964be6511e0 100644 --- a/addons/document_ics/document_demo.xml +++ b/addons/document_ics/document_demo.xml @@ -26,6 +26,11 @@ + + dtend + + + summary @@ -38,7 +43,7 @@ description - + diff --git a/addons/document_ics/document_ics_config_wizard.py b/addons/document_ics/document_ics_config_wizard.py new file mode 100644 index 00000000000..9a2b738ce50 --- /dev/null +++ b/addons/document_ics/document_ics_config_wizard.py @@ -0,0 +1,133 @@ + # -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2009 Tiny SPRL (). All Rights Reserved +# $Id$ +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +############################################################################## + +import time +import tools +from osv import fields, osv, orm +import os +import mx.DateTime +import base64 +import pooler + +SECTION_NAME = { + 'meeting' : 'Meetings', + 'lead':'Prospects', + 'opportunity':'Opportunities', + 'jobs':'Jobs', + 'bugs':'Bug Tracking', + 'fund':'Fund Raising', + 'helpdesk':'HelpDesk', + 'claims':'Claims', + 'phonecall':'Phone Calls', + } + +ICS_TAGS = { + 'summary':'Description', + 'uid':'Calendar Code' , + 'dtstart':'Date' , + 'dtend':'Deadline' , + 'url':'Partner Email' , + 'description':'Your action', + } + +class document_ics_crm_wizard(osv.osv_memory): + _name='document.ics.crm.wizard' + _columns = { + 'name':fields.char('Name', size=64), + 'meeting' : fields.boolean('Calendar of Meetings', help="Manages the calendar of meetings of the users."), + 'lead' : fields.boolean('Prospect', help="Allows you to track and manage prospects which are pre-sales requests or contacts, the very first contact with a customer request."), + 'opportunity' : fields.boolean('Business Opportunities', help="Tracks identified business opportunities for your sales pipeline."), + 'jobs' : fields.boolean('Jobs Hiring Process', help="Help you to organise the jobs hiring process: evaluation, meetings, email integration..."), + 'document_ics':fields.boolean('Shared Calendar', help=" Will allow you to synchronise your Open ERP calendars with your phone, outlook, Sunbird, ical, ..."), + 'bugs' : fields.boolean('Bug Tracking', help="Used by companies to track bugs and support requests on softwares"), + 'helpdesk': fields.boolean('Helpdesk', help="Manages an Helpdesk service."), + 'fund' : fields.boolean('Fund Raising Operations', help="This may help associations in their fund raising process and tracking."), + 'claims' : fields.boolean('Claims', help="Manages the supplier and customers claims, including your corrective or preventive actions."), + 'phonecall' : fields.boolean('Phone Calls', help="Help you to encode the result of a phone call or to planify a list of phone calls to process."), + } + _defaults = { + 'meeting': lambda *args: True, + 'opportunity': lambda *args: True, + 'phonecall': lambda *args: True, + } + + def action_create(self, cr, uid, ids, context=None): + data=self.read(cr, uid, ids, [])[0] + dir_obj = self.pool.get('document.directory') + dir_cont_obj = self.pool.get('document.directory.content') + dir_id = dir_obj.search(cr, uid, [('name', '=', 'Calendars')]) + if dir_id: + dir_id = dir_id[0] + else: + dir_id = dir_obj.create(cr, uid, {'name': 'Calendars' ,'user_id' : uid, 'type': 'directory'}) + for section in ['meeting', 'lead', 'opportunity', 'jobs', 'bugs', 'fund', 'helpdesk', 'claims', 'phonecall']: + if (not data[section]): + continue + else: + section_id=self.pool.get('crm.case.section').search(cr, uid, [('name', '=', SECTION_NAME[section])]) + if not section_id: + continue + else: + object_id=self.pool.get('ir.model').search(cr, uid, [('name', '=', 'Case')])[0] + + vals_cont={ + 'name': SECTION_NAME[section], + 'sequence': 1, + 'directory_id': dir_id, + 'suffix': section, + 'extension': '.ics', + 'ics_object_id': object_id, + 'ics_domain': [('section_id', '=', section_id[0])], + 'include_name' : False + } + + content_id = dir_cont_obj.create(cr, uid, vals_cont) + + ics_obj=self.pool.get('document.directory.ics.fields') + for tag in ['description', 'url', 'summary', 'dtstart', 'dtend', 'uid']: + field_id = self.pool.get('ir.model.fields').search(cr, uid, [('model_id.name', '=', 'Case'), ('field_description', '=', ICS_TAGS[tag])])[0] + vals_ics={ + 'field_id': field_id , + 'name': tag , + 'content_id': content_id , + } + ics_obj.create(cr, uid, vals_ics) + + return { + 'view_type': 'form', + "view_mode": 'form', + 'res_model': 'ir.actions.configuration.wizard', + 'type': 'ir.actions.act_window', + 'target':'new', + } + def action_cancel(self, cr, uid, ids, conect=None): + return { + 'view_type': 'form', + "view_mode": 'form', + 'res_model': 'ir.actions.configuration.wizard', + 'type': 'ir.actions.act_window', + 'target':'new', + } + +document_ics_crm_wizard() + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/document_ics/document_ics_config_wizard.xml b/addons/document_ics/document_ics_config_wizard.xml new file mode 100644 index 00000000000..9c2132bc89d --- /dev/null +++ b/addons/document_ics/document_ics_config_wizard.xml @@ -0,0 +1,50 @@ + + + + + + Configure Calendars for Sections + document.ics.crm.wizard + form + + + + + + + + + + + + + + + +