diff --git a/addons/account/account.py b/addons/account/account.py index a95e6107a68..3772a660de9 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -416,15 +416,27 @@ class account_account(osv.osv): default['child_parent_ids'] = False return super(account_account, self).copy(cr, uid, id, default, context=context) + def _check_moves(self, cr, uid, ids, method, context): + line_obj = self.pool.get('account.move.line') + account_ids = self.search(cr, uid, [('id', 'child_of', ids)]) + if line_obj.search(cr, uid, [('account_id', 'in', account_ids)]): + if method == 'write': + raise osv.except_osv(_('Error !'), _('You cannot deactivate an account that contains account moves.')) + elif method == 'unlink': + raise osv.except_osv(_('Error !'), _('You cannot remove an account which has account entries!. ')) + return True + def write(self, cr, uid, ids, vals, context=None): if not context: context = {} if 'active' in vals and not vals['active']: - line_obj = self.pool.get('account.move.line') - account_ids = self.search(cr, uid, [('id', 'child_of', ids)]) - if line_obj.search(cr, uid, [('account_id', 'in', account_ids)]): - raise osv.except_osv(_('Error !'), _('You can not deactivate an account that contains Ledger Postings.')) + self._check_moves(cr, uid, ids, "write", context) return super(account_account, self).write(cr, uid, ids, vals, context=context) + + def unlink(self, cr, uid, ids, context={}): + self._check_moves(cr, uid, ids, "unlink", context) + return super(account_account, self).unlink(cr, uid, ids, context) + account_account() class account_journal_view(osv.osv): @@ -767,6 +779,23 @@ class account_move(osv.osv): for id in ids: result.setdefault(id, 0.0) return result + + def _search_amount(self, cr, uid, obj, name, args, context): + ids = [] + cr.execute('select move_id,sum(debit) from account_move_line group by move_id') + result = dict(cr.fetchall()) + + for item in args: + if item[1] == '>=': + res = [('id', 'in', [k for k,v in result.iteritems() if v >= item[2]])] + else: + res = [('id', 'in', [k for k,v in result.iteritems() if v <= item[2]])] + ids += res + + if not ids: + return [('id', '>', '0')] + + return ids _columns = { 'name': fields.char('Number', size=64, required=True), @@ -778,7 +807,7 @@ class account_move(osv.osv): 'line_id': fields.one2many('account.move.line', 'move_id', 'Entries', states={'posted':[('readonly',True)]}), 'to_check': fields.boolean('To Be Verified'), 'partner_id': fields.related('line_id', 'partner_id', type="many2one", relation="res.partner", string="Partner"), - 'amount': fields.function(_amount_compute, method=True, string='Amount', digits=(16,int(config['price_accuracy']))), + 'amount': fields.function(_amount_compute, method=True, string='Amount', digits=(16,int(config['price_accuracy'])), type='float', fnct_search=_search_amount), 'date': fields.date('Date', required=True), 'type': fields.selection([ ('pay_voucher','Cash Payment'), @@ -956,7 +985,7 @@ class account_move(osv.osv): else: context.update({'journal_id': move.journal_id.id, 'period_id': move.period_id.id}) line_id = self.pool.get('account.move.line').create(cr, uid, { - 'name': _t(cr, None, 'selection', context.get('lang'), source=(mode.capitalize()+' Centralisation')) or (mode.capitalize()+' Centralisation'), + 'name': _(mode.capitalize()+' Centralisation'), 'centralisation': mode, 'account_id': account_id, 'move_id': move.id, @@ -1084,8 +1113,8 @@ class account_move_reconcile(osv.osv): 'name': lambda self,cr,uid,ctx={}: self.pool.get('ir.sequence').get(cr, uid, 'account.reconcile') or '/', } def reconcile_partial_check(self, cr, uid, ids, type='auto', context={}): + total = 0.0 for rec in self.browse(cr, uid, ids, context): - total = 0.0 for line in rec.line_partial_ids: total += (line.debit or 0.0) - (line.credit or 0.0) if not total: @@ -1546,7 +1575,8 @@ class account_model(osv.osv): def generate(self, cr, uid, ids, datas={}, context={}): move_ids = [] for model in self.browse(cr, uid, ids, context): - period_id = self.pool.get('account.period').find(cr,uid, context=context) + context.update({'date':datas['date']}) + period_id = self.pool.get('account.period').find(cr, uid, dt=context.get('date',False)) if not period_id: raise osv.except_osv(_('No period found !'), _('Unable to find a valid period !')) period_id = period_id[0] @@ -1554,6 +1584,7 @@ class account_model(osv.osv): 'ref': model.ref, 'period_id': period_id, 'journal_id': model.journal_id.id, + 'date': context.get('date',time.strftime('%Y-%m-%d')) }) move_ids.append(move_id) for line in model.lines_id: @@ -1571,7 +1602,7 @@ class account_model(osv.osv): 'move_id': move_id, 'ref': line.ref, 'partner_id': line.partner_id.id, - 'date': time.strftime('%Y-%m-%d'), + 'date': context.get('date',time.strftime('%Y-%m-%d')), 'date_maturity': time.strftime('%Y-%m-%d') }) c = context.copy() diff --git a/addons/account/account_bank_statement.py b/addons/account/account_bank_statement.py index c78d1c289fb..88c8e53fa6a 100644 --- a/addons/account/account_bank_statement.py +++ b/addons/account/account_bank_statement.py @@ -143,8 +143,7 @@ class account_bank_statement(osv.osv): 'period_id': _get_period, } - def button_confirm(self, cr, uid, ids, context=None): - context = context or {} + def button_confirm(self, cr, uid, ids, context={}): done = [] res_currency_obj = self.pool.get('res.currency') res_users_obj = self.pool.get('res.users') @@ -166,7 +165,7 @@ class account_bank_statement(osv.osv): _('The expected balance (%.2f) is different than the computed one. (%.2f)') % (st.balance_end_real, st.balance_end)) if (not st.journal_id.default_credit_account_id) \ or (not st.journal_id.default_debit_account_id): - raise osv.except_osv(_('Configration Error !'), + raise osv.except_osv(_('Configuration Error !'), _('Please verify that an account is defined in the journal.')) for line in st.move_line_ids: @@ -178,10 +177,10 @@ class account_bank_statement(osv.osv): # in bank stat.rec we get line_new_ids on bank.stat.rec.line for move in st.line_ids: context.update({'date':move.date}) - move_id = account_move_obj.create(cr, uid, { 'journal_id': st.journal_id.id, 'period_id': st.period_id.id, + 'date': move.date, }, context=context) account_bank_statement_line_obj.write(cr, uid, [move.id], { 'move_ids': [(4,move_id, False)] diff --git a/addons/account/account_move_line.py b/addons/account/account_move_line.py index 4afb7e7837c..9b126658157 100644 --- a/addons/account/account_move_line.py +++ b/addons/account/account_move_line.py @@ -294,7 +294,7 @@ class account_move_line(osv.osv): return [('id', '=', '0')] return [('id', 'in', [x[0] for x in res])] - def _invoice_search(self, cursor, user, obj, name, args): + def _invoice_search(self, cursor, user, obj, name, args, context): if not len(args): return [] invoice_obj = self.pool.get('account.invoice') diff --git a/addons/account/account_view.xml b/addons/account/account_view.xml index caeb642101a..82f49d83cae 100644 --- a/addons/account/account_view.xml +++ b/addons/account/account_view.xml @@ -1582,6 +1582,8 @@ + + diff --git a/addons/account/invoice.py b/addons/account/invoice.py index c2024c86eb3..7bfc4b702a7 100644 --- a/addons/account/invoice.py +++ b/addons/account/invoice.py @@ -153,7 +153,9 @@ class account_invoice(osv.osv): if not move_lines: res[id] = [] continue + res[id] = [] data_lines = self.pool.get('account.move.line').browse(cr,uid,move_lines) + partial_ids = []# Keeps the track of ids where partial payments are done with payment terms for line in data_lines: ids_line = [] if line.reconcile_id: @@ -161,7 +163,8 @@ class account_invoice(osv.osv): elif line.reconcile_partial_id: ids_line = line.reconcile_partial_id.line_partial_ids l = map(lambda x: x.id, ids_line) - res[id]=[x for x in l if x <> line.id] + partial_ids.append(line.id) + res[id] =[x for x in l if x <> line.id and x not in partial_ids] return res def _get_invoice_line(self, cr, uid, ids, context=None): @@ -183,11 +186,14 @@ class account_invoice(osv.osv): src = [] lines = [] for m in self.pool.get('account.move.line').browse(cr, uid, moves, context): + temp_lines = []#Added temp list to avoid duplicate records if m.reconcile_id: - lines += map(lambda x: x.id, m.reconcile_id.line_id) + temp_lines = map(lambda x: x.id, m.reconcile_id.line_id) elif m.reconcile_partial_id: - lines += map(lambda x: x.id, m.reconcile_partial_id.line_partial_ids) + temp_lines = map(lambda x: x.id, m.reconcile_partial_id.line_partial_ids) + lines += [x for x in temp_lines if x not in lines] src.append(m.id) + lines = filter(lambda x: x not in src, lines) result[invoice.id] = lines return result @@ -991,14 +997,17 @@ class account_invoice(osv.osv): else: amount_currency = False currency_id = False - + if invoice.type in ('in_invoice', 'in_refund'): + ref = invoice.reference + else: + ref = self._convert_ref(cr, uid, invoice.number) # Pay attention to the sign for both debit/credit AND amount_currency l1 = { 'debit': direction * pay_amount>0 and direction * pay_amount, 'credit': direction * pay_amount<0 and - direction * pay_amount, 'account_id': src_account_id, 'partner_id': invoice.partner_id.id, - 'ref':invoice.number, + 'ref':ref, 'date': date, 'currency_id':currency_id, 'amount_currency':amount_currency and direction * amount_currency or 0.0, @@ -1009,7 +1018,7 @@ class account_invoice(osv.osv): 'credit': direction * pay_amount>0 and direction * pay_amount, 'account_id': pay_account_id, 'partner_id': invoice.partner_id.id, - 'ref':invoice.number, + 'ref':ref, 'date': date, 'currency_id':currency_id, 'amount_currency':amount_currency and - direction * amount_currency or 0.0, @@ -1022,7 +1031,7 @@ class account_invoice(osv.osv): l2['name'] = name lines = [(0, 0, l1), (0, 0, l2)] - move = {'ref': invoice.number, 'line_id': lines, 'journal_id': pay_journal_id, 'period_id': period_id, 'date': date} + move = {'ref': ref, 'line_id': lines, 'journal_id': pay_journal_id, 'period_id': period_id, 'date': date} move_id = self.pool.get('account.move').create(cr, uid, move, context=context) line_ids = [] diff --git a/addons/account/partner.py b/addons/account/partner.py index 54c902f4f86..a3985ee68e9 100644 --- a/addons/account/partner.py +++ b/addons/account/partner.py @@ -117,7 +117,7 @@ class res_partner(osv.osv): res[pid][maps[type]] = (type=='receivable') and val or -val return res - def _credit_search(self, cr, uid, obj, name, args): + def _credit_search(self, cr, uid, obj, name, args, context): if not len(args): return [] where = ' and '.join(map(lambda x: '(sum(debit-credit)'+x[1]+str(x[2])+')',args)) @@ -128,7 +128,7 @@ class res_partner(osv.osv): return [('id','=','0')] return [('id','in',map(lambda x:x[0], res))] - def _debit_search(self, cr, uid, obj, name, args): + def _debit_search(self, cr, uid, obj, name, args, context): if not len(args): return [] query = self.pool.get('account.move.line')._query_get(cr, uid, context={}) diff --git a/addons/account/wizard/wizard_fiscalyear_close.py b/addons/account/wizard/wizard_fiscalyear_close.py index a3400d0ddf1..7e48f7c496c 100644 --- a/addons/account/wizard/wizard_fiscalyear_close.py +++ b/addons/account/wizard/wizard_fiscalyear_close.py @@ -79,10 +79,12 @@ def _data_save(self, cr, uid, data, context): if move_ids: raise wizard.except_wizard(_('UserError'), _('The opening journal must not have any entry in the new fiscal year !')) - - + query = "SELECT id FROM account_fiscalyear WHERE date_stop < '" + str(new_fyear.date_start) + "'" + cr.execute(query) + result = cr.dictfetchall() + fy_ids = ','.join([str(x['id']) for x in result]) query_line = pool.get('account.move.line')._query_get(cr, uid, - obj='account_move_line', context={'fiscalyear': fy_id}) + obj='account_move_line', context={'fiscalyear': fy_ids}) cr.execute('select id from account_account WHERE active') ids = map(lambda x: x[0], cr.fetchall()) for account in pool.get('account.account').browse(cr, uid, ids, diff --git a/addons/account/wizard/wizard_statement_from_invoice.py b/addons/account/wizard/wizard_statement_from_invoice.py index be4a01c94c4..5bb9a0d9772 100644 --- a/addons/account/wizard/wizard_statement_from_invoice.py +++ b/addons/account/wizard/wizard_statement_from_invoice.py @@ -58,15 +58,35 @@ def _search_invoices(obj, cr, uid, data, context): journal_obj = pool.get('account.journal') statement = statement_obj.browse(cr, uid, data['id'], context=context) + args_move_line = [] + repeated_move_line_ids = [] + # Creating a group that is unique for importing move lines(move lines, once imported into statement lines, should not appear again) + for st_line in statement.line_ids: + args_move_line = [] + args_move_line.append(('name','=', st_line.name)) + args_move_line.append(('ref','=',st_line.ref)) + if st_line.partner_id: + args_move_line.append(('partner_id','=',st_line.partner_id.id)) + args_move_line.append(('account_id','=',st_line.account_id.id)) + + move_line_id = line_obj.search(cr, uid, args_move_line,context=context) + if move_line_id: + repeated_move_line_ids.append(move_line_id) + journal_ids = data['form']['journal_id'][0][2] if journal_ids == []: journal_ids = journal_obj.search(cr, uid, [('type', 'in', ('sale','cash','purchase'))], context=context) - - line_ids = line_obj.search(cr, uid, [ + + args = [ ('reconcile_id', '=', False), ('journal_id', 'in', journal_ids), - ('account_id.reconcile', '=', True)], + ('account_id.reconcile', '=', True)] + + if repeated_move_line_ids: + args.append(('id','not in',repeated_move_line_ids)) + + line_ids = line_obj.search(cr, uid, args, #order='date DESC, id DESC', #doesn't work context=context) diff --git a/addons/account/wizard/wizard_subscription_generate.py b/addons/account/wizard/wizard_subscription_generate.py index 49344b1d870..51cbad9ec3a 100644 --- a/addons/account/wizard/wizard_subscription_generate.py +++ b/addons/account/wizard/wizard_subscription_generate.py @@ -29,7 +29,7 @@ import pooler _subscription_form = '''
- + ''' % ('Subscription Compute',) @@ -38,7 +38,7 @@ _subscription_fields = { } class wiz_subscription(wizard.interface): - def _action_generate(self, cr, uid, data, context): + def _action_generate(self, cr, uid, data, context={}): cr.execute('select id from account_subscription_line where date<%s and move_id is null', (data['form']['date'],)) ids = map(lambda x: x[0], cr.fetchall()) pooler.get_pool(cr.dbname).get('account.subscription.line').move_create(cr, uid, ids) diff --git a/addons/account_analytic_default/__terp__.py b/addons/account_analytic_default/__terp__.py index 79459a22935..9c3982990b3 100644 --- a/addons/account_analytic_default/__terp__.py +++ b/addons/account_analytic_default/__terp__.py @@ -34,7 +34,7 @@ Allows to automatically select analytic accounts based on criterions: """, 'author': 'Tiny', 'website': 'http://www.openerp.com', - 'depends': ['account'], + 'depends': ['account', 'sale'], 'init_xml': [], 'update_xml': ['security/ir.model.access.csv', 'account_analytic_default_view.xml'], 'demo_xml': [], diff --git a/addons/account_analytic_default/account_analytic_default.py b/addons/account_analytic_default/account_analytic_default.py index 0e5a5219b71..f22e37e5e71 100644 --- a/addons/account_analytic_default/account_analytic_default.py +++ b/addons/account_analytic_default/account_analytic_default.py @@ -70,12 +70,51 @@ account_analytic_default() class account_invoice_line(osv.osv): _inherit = 'account.invoice.line' _description = 'account invoice line' - def product_id_change(self, cr, uid, ids, product, uom, qty=0, name='', type='out_invoice', partner_id=False, fposition=False, price_unit=False, address_invoice_id=False, context=None): + + def product_id_change(self, cr, uid, ids, product, uom, qty=0, name='', type='out_invoice', partner_id=False, fposition=False, price_unit=False, address_invoice_id=False, context={}): res_prod = super(account_invoice_line,self).product_id_change(cr, uid, ids, product, uom, qty, name, type, partner_id, fposition, price_unit, address_invoice_id, context) rec = self.pool.get('account.analytic.default').account_get(cr, uid, product, partner_id, uid, time.strftime('%Y-%m-%d'), context) if rec: res_prod['value'].update({'account_analytic_id':rec.analytic_id.id}) + else: + res_prod['value'].update({'account_analytic_id':False}) return res_prod account_invoice_line() + +class stock_picking(osv.osv): + _inherit = "stock.picking" + + def _get_account_analytic_invoice(self, cursor, user, picking, move_line): + partner_id = picking.address_id and picking.address_id.partner_id or False + rec = self.pool.get('account.analytic.default').account_get(cursor, user, move_line.product_id.id, partner_id and partner_id.id, user, time.strftime('%Y-%m-%d'), context={}) + + if rec: + return rec.analytic_id.id + + return super(stock_picking, self)._get_account_analytic_invoice(cursor, + user, picking, move_line) + +stock_picking() + +class sale_order_line(osv.osv): + _inherit = 'sale.order.line' + + # Method overridden to set the analytic account by default on criterion match + def invoice_line_create(self, cr, uid, ids, context={}): + create_ids = super(sale_order_line,self).invoice_line_create(cr, uid, ids, context) + sale_line_obj = self.browse(cr, uid, ids[0], context) + pool_inv_line = self.pool.get('account.invoice.line') + + for line in pool_inv_line.browse(cr, uid, create_ids, context): + rec = self.pool.get('account.analytic.default').account_get(cr, uid, line.product_id.id, sale_line_obj.order_id.partner_id.id, uid, time.strftime('%Y-%m-%d'), context) + + if rec: + pool_inv_line.write(cr, uid, [line.id], {'account_analytic_id':rec.analytic_id.id}, context=context) + return create_ids + +sale_order_line() + + + # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account_analytic_plans/account_analytic_plans.py b/addons/account_analytic_plans/account_analytic_plans.py index d870976c5e4..51b37fdebb2 100644 --- a/addons/account_analytic_plans/account_analytic_plans.py +++ b/addons/account_analytic_plans/account_analytic_plans.py @@ -374,4 +374,25 @@ class analytic_default(osv.osv): } analytic_default() +class sale_order_line(osv.osv): + _inherit = 'sale.order.line' + + # Method overridden to set the analytic account by default on criterion match + def invoice_line_create(self, cr, uid, ids, context={}): + create_ids = super(sale_order_line,self).invoice_line_create(cr, uid, ids, context) + if ids: + sale_line_obj = self.browse(cr, uid, ids[0], context) + pool_inv_line = self.pool.get('account.invoice.line') + + for line in pool_inv_line.browse(cr, uid, create_ids, context): + rec = self.pool.get('account.analytic.default').account_get(cr, uid, line.product_id.id, sale_line_obj.order_id.partner_id.id, uid, time.strftime('%Y-%m-%d'), context) + + if rec: + pool_inv_line.write(cr, uid, [line.id], {'analytics_id':rec.analytics_id.id}, context=context) + cr.commit() + return create_ids + +sale_order_line() + + # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account_date_check/i18n/lt.po b/addons/account_date_check/i18n/lt.po index c88acc4f3d9..6cb3f7303a1 100644 --- a/addons/account_date_check/i18n/lt.po +++ b/addons/account_date_check/i18n/lt.po @@ -13,7 +13,7 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2010-01-21 04:34+0000\n" +"X-Launchpad-Export-Date: 2010-01-22 04:34+0000\n" "X-Generator: Launchpad (build Unknown)\n" #. module: account_date_check diff --git a/addons/account_followup/wizard/wizard_followup_print.py b/addons/account_followup/wizard/wizard_followup_print.py index 9d7e62d9a37..2f82ec6ba60 100644 --- a/addons/account_followup/wizard/wizard_followup_print.py +++ b/addons/account_followup/wizard/wizard_followup_print.py @@ -125,12 +125,13 @@ class followup_all_print(wizard.interface): def _update_partners(self, cr, uid, data, context): to_update = data['form']['to_update'] for id in to_update.keys(): - cr.execute( - "UPDATE account_move_line "\ - "SET followup_line_id=%s, followup_date=%s "\ - "WHERE id=%s", - (to_update[id], - data['form']['date'], int(id),)) + if to_update[id]['partner_id'] in data['form']['partner_ids'][0][2]: + cr.execute( + "UPDATE account_move_line "\ + "SET followup_line_id=%s, followup_date=%s "\ + "WHERE id=%s", + (to_update[id]['level'], + data['form']['date'], int(id),)) return {} def _sendmail(self ,cr, uid, data, context): @@ -263,12 +264,12 @@ class followup_all_print(wizard.interface): if date_maturity <= fups[followup_line_id][0].strftime('%Y-%m-%d'): if partner_id not in partner_list: partner_list.append(partner_id) - to_update[str(id)] = fups[followup_line_id][1] + to_update[str(id)]= {'level': fups[followup_line_id][1], 'partner_id': partner_id} elif date and date <= fups[followup_line_id][0].strftime('%Y-%m-%d'): if partner_id not in partner_list: partner_list.append(partner_id) - to_update[str(id)] = fups[followup_line_id][1] - + to_update[str(id)]= {'level': fups[followup_line_id][1], 'partner_id': partner_id} + message = pool.get('res.users').browse(cr, uid, uid, context=context).company_id.follow_up_msg return {'partner_ids': partner_list, 'to_update': to_update, 'email_body':message} diff --git a/addons/account_payment/account_move_line.py b/addons/account_payment/account_move_line.py index d501975f565..0c7f61928c3 100644 --- a/addons/account_payment/account_move_line.py +++ b/addons/account_payment/account_move_line.py @@ -46,7 +46,7 @@ class account_move_line(osv.osv): r=dict(cr.fetchall()) return r - def _to_pay_search(self, cr, uid, obj, name, args): + def _to_pay_search(self, cr, uid, obj, name, args, context): if not len(args): return [] line_obj = self.pool.get('account.move.line') diff --git a/addons/account_tax_include/invoice_tax_incl.py b/addons/account_tax_include/invoice_tax_incl.py index 62c2dca1a48..f47c587babc 100644 --- a/addons/account_tax_include/invoice_tax_incl.py +++ b/addons/account_tax_include/invoice_tax_incl.py @@ -23,6 +23,7 @@ import time import netsvc from osv import fields, osv import ir +from tools import config class account_invoice(osv.osv): _inherit = "account.invoice" @@ -45,7 +46,9 @@ class account_invoice_line(osv.osv): """ res = {} tax_obj = self.pool.get('account.tax') + cur_obj = self.pool.get('res.currency') for line in self.browse(cr, uid, ids): + cur = line.invoice_id and line.invoice_id.currency_id or False res_init = super(account_invoice_line, self)._amount_line(cr, uid, [line.id], name, args, context) res[line.id] = { 'price_subtotal': 0.0, @@ -63,13 +66,13 @@ class account_invoice_line(osv.osv): product_taxes = filter(lambda x: x.price_include, line.product_id.supplier_taxes_id) if ((set(product_taxes) == set(line.invoice_line_tax_id)) or not product_taxes) and (line.invoice_id.price_type == 'tax_included'): - res[line.id]['price_subtotal_incl'] = res_init[line.id] + res[line.id]['price_subtotal_incl'] = cur and cur_obj.round(cr, uid, cur, res_init[line.id]) or res_init[line.id] else: - res[line.id]['price_subtotal'] = res_init[line.id] + res[line.id]['price_subtotal'] = cur and cur_obj.round(cr, uid, cur, res_init[line.id]) or res_init[line.id] for tax in tax_obj.compute_inv(cr, uid, product_taxes, res_init[line.id]/line.quantity, line.quantity): - res[line.id]['price_subtotal'] = res[line.id]['price_subtotal'] - round(tax['amount'], 2) + res[line.id]['price_subtotal'] = res[line.id]['price_subtotal'] - round(tax['amount'], int(config['price_accuracy'])) else: - res[line.id]['price_subtotal'] = res_init[line.id] + res[line.id]['price_subtotal'] = cur and cur_obj.round(cr, uid, cur, res_init[line.id]) or res_init[line.id] if res[line.id]['price_subtotal']: res[line.id]['price_subtotal_incl'] = res[line.id]['price_subtotal'] @@ -82,8 +85,8 @@ class account_invoice_line(osv.osv): res[line.id]['price_subtotal'] = res[line.id]['price_subtotal'] - tax['amount'] res[line.id]['data'].append( tax) - res[line.id]['price_subtotal']= round(res[line.id]['price_subtotal'], 2) - res[line.id]['price_subtotal_incl']= round(res[line.id]['price_subtotal_incl'], 2) + res[line.id]['price_subtotal']= round(res[line.id]['price_subtotal'], int(config['price_accuracy'])) + res[line.id]['price_subtotal_incl']= round(res[line.id]['price_subtotal_incl'], int(config['price_accuracy'])) return res def _price_unit_default(self, cr, uid, context=None): diff --git a/addons/account_voucher/account.py b/addons/account_voucher/account.py index 8d6d59acf84..ec886bef6c6 100644 --- a/addons/account_voucher/account.py +++ b/addons/account_voucher/account.py @@ -28,7 +28,7 @@ import mx.DateTime from mx.DateTime import RelativeDateTime from tools import config -class Account(osv.osv): +class account_account(osv.osv): _inherit = "account.account" def _get_level(self, cr, uid, ids, field_name, arg, context={}): @@ -108,7 +108,7 @@ class Account(osv.osv): vals['type1'] = 'none' journal_ids=self.pool.get('account.journal').search(cr,uid,[('name','=','Opening Journal')]) vals['journal_id'] = journal_ids and journal_ids[0] or False - account_id = super(Account, self).create(cr, uid, vals, context) + account_id = super(account_account, self).create(cr, uid, vals, context) if vals.get('type1', False) != False: journal_id = vals.get('journal_id',False) if journal_id and vals.has_key('open_bal'): @@ -157,7 +157,7 @@ class Account(osv.osv): vals['type1'] = 'cr' else: vals['type1'] = 'none' - super(Account, self).write(cr, uid,ids, vals, context) + super(account_account, self).write(cr, uid,ids, vals, context) if vals.has_key('open_bal'): self_obj= self.browse(cr,uid,ids) move_pool=self.pool.get('account.move') @@ -213,16 +213,16 @@ class Account(osv.osv): return { 'value' : {'type1' : type1} } -Account() +account_account() -class AccountMove(osv.osv): +class account_move(osv.osv): _inherit = "account.move" _columns = { 'name':fields.char('Name', size=256, required=True, readonly=True, states={'draft':[('readonly',False)]}), 'narration':fields.text('Narration', readonly=True, select=True, states={'draft':[('readonly',False)]}), } -AccountMove() +account_move() class res_currency(osv.osv): _inherit = "res.currency" diff --git a/addons/account_voucher/report/report_voucher.rml b/addons/account_voucher/report/report_voucher.rml index 9be52c064d7..93b767e5416 100755 --- a/addons/account_voucher/report/report_voucher.rml +++ b/addons/account_voucher/report/report_voucher.rml @@ -30,7 +30,7 @@ - + @@ -63,26 +63,29 @@ - - - + + + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + @@ -91,27 +94,76 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - [[ repeatIn(objects,'voucher') ]] + [[ repeatIn(objects,'voucher') ]] [[ company.name ]] - [[ company.partner_id.address and company.partner_id.address[0].street ]], [[ company.partner_id.address and company.partner_id.address[0].street2 ]] + [[ company.partner_id.address and company.partner_id.address[0].street ]] [[ company.partner_id.address and company.partner_id.address[0].zip ]] [[ company.partner_id.address and company.partner_id.address[0].city ]] - [[ company.partner_id.address and company.partner_id.address[0].country_id and company.partner_id.address[0].country_id.name ]] [[ company.partner_id.address and company.partner_id.address[0].phone ]] [[ company.partner_id.address and company.partner_id.address[0].email ]] - Cash Receipt Voucher [[ (voucher.type == 'rec_voucher' or removeParentNode('para')) and '' ]] + + + + Cash Receipt Voucher [[ (voucher.type == 'rec_voucher' or removeParentNode('para')) and '' ]] Cash Payment Voucher [[ (voucher.type == 'pay_voucher' or removeParentNode('para')) and '' ]] - Bank Receipt Voucher [[ (voucher.type == 'bank_rec_voucher' or removeParentNode('para')) and '' ]] + Bank Receipt Voucher [[ (voucher.type == 'bank_rec_voucher' or removeParentNode('para')) and '' ]] Bank Payment Voucher [[ (voucher.type == 'bank_pay_voucher' or removeParentNode('para')) and '' ]] - + + + No. - [[ voucher.number ]] + [[ voucher.number ]] @@ -122,7 +174,7 @@ Dated : - [[ time.strftime('%d %B,%Y', time.strptime(voucher.date , '%Y-%m-%d')) or '' ]] + [[ time.strftime('%d %B,%Y', time.strptime(voucher.date , '%Y-%m-%d')) or '' ]] @@ -130,10 +182,10 @@ State : - PRO-FORMA [[ ((voucher.state == 'proforma') or removeParentNode('para')) and '' ]] - Draft[[ ((voucher.state == 'draft') or removeParentNode('para')) and '' ]] - Canceled [[ ((voucher.state == 'cancel') or removeParentNode('para')) and '' ]] - Posted [[ ((voucher.state == 'posted') or removeParentNode('para')) and '' ]] + PRO-FORMA [[ ((voucher.state == 'proforma') or removeParentNode('para')) and '' ]] + Draft[[ ((voucher.state == 'draft') or removeParentNode('para')) and '' ]] + Canceled [[ ((voucher.state == 'cancel') or removeParentNode('para')) and '' ]] + Posted [[ ((voucher.state == 'posted') or removeParentNode('para')) and '' ]] @@ -144,51 +196,58 @@ Ref. : - [[ voucher.reference ]] + [[ voucher.reference ]] - + - + - Particulars + Particulars - Debit + Debit - Credit + Credit - + - [[ repeatIn(voucher.move_ids,'move_ids') ]] - - - - [[ (move_ids.partner_id and move_ids.partner_id.name) or 'Account']] : - [[ move_ids.account_id.name ]] - [[ move_ids.name ]] - [[ get_ref(voucher.id,move_ids) ]] - - - - [[ move_ids.debit ]] - - - [[ move_ids.credit ]] - - - - + + + +
+ [[ repeatIn(voucher.move_ids,'move_ids') ]] + + + + [[ (move_ids.partner_id and move_ids.partner_id.name) or '']] : + [[ move_ids.account_id.name ]] + [[ get_ref(voucher.id,move_ids) ]] + + + [[ move_ids.debit ]] + + + [[ move_ids.credit ]] + + + + + + +
+ @@ -197,7 +256,7 @@ - + @@ -214,7 +273,7 @@ - Through : + Through : @@ -229,7 +288,7 @@ - [[ voucher.narration or '']] + [[ voucher.narration or '']] @@ -244,7 +303,7 @@ - On Account of : + On Account of : @@ -259,7 +318,7 @@ - [[ voucher.name ]] + [[ voucher.name ]] @@ -274,7 +333,22 @@ - Amount (in words) : + Amount (in words) : + + + + + + + + + + + + + + + [[ convert(voucher.amount,voucher.currency_id.name) ]] @@ -289,34 +363,19 @@ - [[ convert(voucher.amount,voucher.currency_id.name) ]] - - - + - - - - - - - - - - + [[ debit(voucher.move_ids)]] - [[ debit(voucher.move_ids)]] - - - [[ credit(voucher.move_ids) ]] + [[ credit(voucher.move_ids) ]] - + @@ -353,20 +412,20 @@ - Receiver's Signature + Receiver's Signature - + - + - Authorised Signatory + Authorised Signatory diff --git a/addons/account_voucher/report/report_voucher_amount.rml b/addons/account_voucher/report/report_voucher_amount.rml index bcc47fa6434..d8175fe3b58 100755 --- a/addons/account_voucher/report/report_voucher_amount.rml +++ b/addons/account_voucher/report/report_voucher_amount.rml @@ -16,7 +16,7 @@
- D + @@ -27,7 +27,7 @@ - + @@ -57,25 +57,25 @@ - + - - - - - - - - - - - - + + + + + + + + + + + + @@ -84,10 +84,54 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - [[ repeatIn(objects,'voucher') ]] + [[ repeatIn(objects,'voucher') ]] [[ company.name ]] [[ company.partner_id.address and company.partner_id.address[0].street ]] [[ company.partner_id.address and company.partner_id.address[0].zip ]] [[ company.partner_id.address and company.partner_id.address[0].city ]] - [[ company.partner_id.address and company.partner_id.address[0].country_id and company.partner_id.address[0].country_id.name ]] @@ -96,11 +140,11 @@ - Cash Receipt Voucher [[ (voucher.type == 'rec_voucher' or removeParentNode('para')) and '' ]] + Cash Receipt Voucher [[ (voucher.type == 'rec_voucher' or removeParentNode('para')) and '' ]] Cash Payment Voucher [[ (voucher.type == 'pay_voucher' or removeParentNode('para')) and '' ]] - Bank Receipt Voucher [[ (voucher.type == 'bank_rec_voucher' or removeParentNode('para')) and '' ]] + Bank Receipt Voucher [[ (voucher.type == 'bank_rec_voucher' or removeParentNode('para')) and '' ]] Bank Payment Voucher [[ (voucher.type == 'bank_pay_voucher' or removeParentNode('para')) and '' ]] - + @@ -109,7 +153,7 @@ No. - [[ voucher.number ]] + [[ voucher.number ]] @@ -120,7 +164,7 @@ Dated : - [[ time.strftime('%d %B,%Y', time.strptime(voucher.date , '%Y-%m-%d')) or '' ]] + [[ time.strftime('%d %B,%Y', time.strptime(voucher.date , '%Y-%m-%d')) or '' ]] @@ -128,10 +172,10 @@ State : - PRO-FORMA [[ ((voucher.state == 'proforma') or removeParentNode('para')) and '' ]] - Draft[[ ((voucher.state == 'draft') or removeParentNode('para')) and '' ]] - Canceled [[ ((voucher.state == 'cancel') or removeParentNode('para')) and '' ]] - Posted [[ ((voucher.state == 'posted') or removeParentNode('para')) and '' ]] + PRO-FORMA [[ ((voucher.state == 'proforma') or removeParentNode('para')) and '' ]] + Draft[[ ((voucher.state == 'draft') or removeParentNode('para')) and '' ]] + Canceled [[ ((voucher.state == 'cancel') or removeParentNode('para')) and '' ]] + Posted [[ ((voucher.state == 'posted') or removeParentNode('para')) and '' ]] @@ -142,7 +186,7 @@ Ref. : - [[ voucher.reference ]] + [[ voucher.reference ]] @@ -150,7 +194,7 @@ Account : - [[ voucher.account_id.name ]] + [[ voucher.account_id.name ]] @@ -163,17 +207,19 @@ - + - - + + + + Particulars @@ -183,26 +229,31 @@ - - - - [[ repeatIn(voucher.payment_ids,'payment_ids') ]] - - - - [[ payment_ids.partner_id.name ]] : - [[ payment_ids.account_id.name ]] - [[ payment_ids.ref ]] [[ payment_ids.amount ]] [[ payment_ids.type ]] - - - [[ payment_ids.amount ]] - - - - + + + +
+ [[ repeatIn(voucher.payment_ids,'payment_ids') ]] + + + + [[ payment_ids.partner_id.name ]] : + [[ payment_ids.account_id.name ]] + [[ payment_ids.ref ]] [[ payment_ids.amount ]] [[ payment_ids.type ]] + + + [[ payment_ids.amount ]] + + + + + + +
+ @@ -233,10 +284,10 @@ - [[ voucher.narration or '' ]] + [[ voucher.narration or '' ]] - + @@ -253,10 +304,10 @@ - [[ voucher.name ]] + [[ voucher.name ]] - + @@ -273,7 +324,7 @@ - [[ convert(voucher.amount,voucher.currency_id.name) ]] + [[ convert(voucher.amount,voucher.currency_id.name) ]] @@ -329,20 +380,20 @@ - Receiver's Signature + Receiver's Signature - + - + - Authorised Signatory + Authorised Signatory
diff --git a/addons/auction/i18n/bg.po b/addons/auction/i18n/bg.po index 62643ecb9e2..ec0d6815581 100644 --- a/addons/auction/i18n/bg.po +++ b/addons/auction/i18n/bg.po @@ -13,7 +13,7 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2010-01-20 04:36+0000\n" +"X-Launchpad-Export-Date: 2010-01-22 04:34+0000\n" "X-Generator: Launchpad (build Unknown)\n" #. module: auction diff --git a/addons/auction/i18n/pt_BR.po b/addons/auction/i18n/pt_BR.po index af1925e9ff4..d94054a792c 100644 --- a/addons/auction/i18n/pt_BR.po +++ b/addons/auction/i18n/pt_BR.po @@ -13,7 +13,7 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2010-01-20 04:36+0000\n" +"X-Launchpad-Export-Date: 2010-01-22 04:34+0000\n" "X-Generator: Launchpad (build Unknown)\n" #. module: auction diff --git a/addons/audittrail/i18n/pt_BR.po b/addons/audittrail/i18n/pt_BR.po index 884f1538e1c..bd8800a027c 100644 --- a/addons/audittrail/i18n/pt_BR.po +++ b/addons/audittrail/i18n/pt_BR.po @@ -13,7 +13,7 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2010-01-21 04:34+0000\n" +"X-Launchpad-Export-Date: 2010-01-22 04:34+0000\n" "X-Generator: Launchpad (build Unknown)\n" #. module: audittrail diff --git a/addons/base_calendar/__init__.py b/addons/base_calendar/__init__.py index f2664029c43..c127cc7c124 100644 --- a/addons/base_calendar/__init__.py +++ b/addons/base_calendar/__init__.py @@ -20,5 +20,6 @@ ############################################################################## import base_calendar +import wizard # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/base_calendar/__terp__.py b/addons/base_calendar/__terp__.py index 747958cde38..49b3a2d7389 100644 --- a/addons/base_calendar/__terp__.py +++ b/addons/base_calendar/__terp__.py @@ -42,6 +42,8 @@ "demo_xml" : [], "update_xml" : [ 'security/ir.model.access.csv', + 'base_calendar_wizard.xml', + 'base_calendar_view.xml' ], "installable" : True, "active" : False, diff --git a/addons/base_calendar/base_calendar.py b/addons/base_calendar/base_calendar.py index 6a93b22e7da..1cb79407476 100644 --- a/addons/base_calendar/base_calendar.py +++ b/addons/base_calendar/base_calendar.py @@ -22,7 +22,7 @@ from datetime import datetime, timedelta from dateutil import parser from dateutil.rrule import * -from osv import osv +from osv import osv, fields import pooler import re import vobject @@ -59,6 +59,22 @@ def openobjectid2uid(cr, uidval, oomodel): value = 'OpenObject-%s_%s@%s' % (oomodel, uidval, cr.dbname) return value +def get_attribute_mapping(cr, uid, model, context={}): + pool = pooler.get_pool(cr.dbname) + field_obj = pool.get('basic.calendar.fields') + fids = field_obj.search(cr, uid, [('object_id.model', '=', model)]) + res = {} + for field in field_obj.browse(cr, uid, fids): + attr = field.attribute + res[attr] = {} + res[attr]['field'] = field.field_id.name + res[attr]['type'] = field.field_id.ttype + if res[attr]['type'] in ('one2many', 'many2many', 'many2one'): + res[attr]['object'] = field.field_id.relation + elif res[attr]['type'] in ('selection') and field.mapping: + res[attr]['mapping'] = eval(field.mapping) + return res + def map_data(cr, uid, obj): vals = {} for map_dict in obj.__attribute__: @@ -101,8 +117,8 @@ def map_data(cr, uid, obj): return vals class CalDAV(object): - __attribute__ = { - } + __attribute__ = {} + def get_recurrent_dates(self, rrulestring, exdate, startdate=None): if not startdate: startdate = datetime.now() @@ -129,8 +145,6 @@ class CalDAV(object): val = ','.join(map(lambda x: x.strftime('%Y-%m-%d %H:%M:%S'), val)) else: val = val.strftime('%Y-%m-%d %H:%M:%S') - if valtype and valtype == 'integer' and val: - val = int(val) return val else: return self.__attribute__.get(name, None) @@ -142,6 +156,7 @@ class CalDAV(object): return True def export_ical(self, cr, uid, datas, vobj=None, context={}): + self.__attribute__ = get_attribute_mapping(cr, uid, self._name, context) ical = vobject.iCalendar() for data in datas: vevent = ical.add(vobj) @@ -177,7 +192,7 @@ class CalDAV(object): vevent = alarm_obj.export_ical(cr, uid, model, \ data[map_field][0], vevent, context=context) elif data[map_field]: - if map_type == "text": + if map_type in ("char", "text"): vevent.add(field).value = str(data[map_field]) elif map_type == 'datetime' and data[map_field]: if field in ('exdate'): @@ -188,13 +203,19 @@ class CalDAV(object): vevent.add(field).value = timedelta(hours=data[map_field]) elif map_type == "many2one": vevent.add(field).value = [data.get(map_field)[1]] - if self.__attribute__.get(field).has_key('mapping'): - for key1, val1 in self.ical_get(field, 'mapping').items(): - if val1 == data[map_field]: - vevent.add(field).value = key1 + elif map_type in ("float", "integer"): + vevent.add(field).value = [data.get(map_field)] + elif map_type == "selection": + if not self.ical_get(field, 'mapping'): + vevent.add(field).value = (data[map_field]).upper() + else: + for key1, val1 in self.ical_get(field, 'mapping').items(): + if val1 == data[map_field]: + vevent.add(field).value = key1 return ical def import_ical(self, cr, uid, ical_data): + self.__attribute__ = get_attribute_mapping(cr, uid, self._name) parsedCal = vobject.readOne(ical_data) att_data = [] res = [] @@ -222,7 +243,7 @@ class CalDAV(object): return res -class Calendar(CalDAV, osv.osv_memory): +class Calendar(CalDAV, osv.osv): _name = 'basic.calendar' __attribute__ = { 'prodid': None, # Use: R-1, Type: TEXT, Specifies the identifier for the product that created the iCalendar object. @@ -236,11 +257,65 @@ class Calendar(CalDAV, osv.osv_memory): 'vjournal': None, # Use: O-n, Type: Collection of Journal class 'vfreebusy': None, # Use: O-n, Type: Collection of FreeBusy class 'vtimezone': None, # Use: O-n, Type: Collection of Timezone class - + } + _columns = { + 'name': fields.char("Name", size=64), + 'line_ids': fields.one2many('basic.calendar.lines', 'calendar_id', 'Calendar Lines') } Calendar() + +class basic_calendar_line(osv.osv): + _name = 'basic.calendar.lines' + _description = 'Calendar Lines' + _columns = { + 'name': fields.selection([('event', 'Event'), ('todo', 'TODO'), \ + ('alarm', 'Alarm'), \ + ('attendee', 'Attendee')], \ + string="Type", size=64), + 'object_id': fields.many2one('ir.model', 'Object'), + 'calendar_id': fields.many2one('basic.calendar', 'Calendar', required=True), + 'mapping_ids': fields.one2many('basic.calendar.fields', 'type_id', 'Fields Mapping') + } + +basic_calendar_line() + +class basic_calendar_attribute(osv.osv): + _name = 'basic.calendar.attributes' + _description = 'Calendar attributes' + _columns = { + 'name': fields.char("Name", size=64, required=True), + 'type': fields.selection([('event', 'Event'), ('todo', 'TODO'), \ + ('alarm', 'Alarm'), \ + ('attendee', 'Attendee')], \ + string="Type", size=64, required=True), + } + +basic_calendar_attribute() + +class basic_calendar_fields(osv.osv): + _name = 'basic.calendar.fields' + _description = 'Calendar fields' + + _columns = { + 'field_id': fields.many2one('ir.model.fields', 'OpenObject Field'), + 'name': fields.many2one('basic.calendar.attributes', 'Name', required=True), + 'type_id': fields.many2one('basic.calendar.lines', 'Type', required=True), + 'expr': fields.char("Expression", size=64), + 'fn': fields.selection( [('field', 'Use the field'), + ('const', 'Expression as constant'), + ('hours', 'Interval in hours'), + ],'Function'), + 'mapping': fields.text('Mapping'), + } + + _defaults = { + 'fn': lambda *a: 'field', + } + +basic_calendar_fields() + class Event(CalDAV, osv.osv_memory): _name = 'basic.calendar.event' __attribute__ = { @@ -397,7 +472,7 @@ class Alarm(CalDAV, osv.osv_memory): # Compute other details valarm.add('DESCRIPTION').value = alarm_data['name'] valarm.add('ACTION').value = alarm_data['action'] - + return vevent def import_ical(self, cr, uid, ical_data): for child in ical_data.getChildren(): @@ -461,9 +536,11 @@ class Attendee(CalDAV, osv.osv_memory): def export_ical(self, cr, uid, model, attendee_ids, vevent, context={}): attendee_object = self.pool.get(model) + self.__attribute__ = get_attribute_mapping(cr, uid, self._name, context) for attendee in attendee_object.read(cr, uid, attendee_ids, []): attendee_add = vevent.add('attendee') - for a_key, a_val in attendee_object.__attribute__.items(): + cn_val = '' + for a_key, a_val in self.__attribute__.items(): if attendee[a_val['field']] and a_val['field'] != 'cn': if a_val['type'] == 'text': attendee_add.params[a_key] = [str(attendee[a_val['field']])] diff --git a/addons/base_calendar/base_calendar_view.xml b/addons/base_calendar/base_calendar_view.xml new file mode 100644 index 00000000000..1dc534db87f --- /dev/null +++ b/addons/base_calendar/base_calendar_view.xml @@ -0,0 +1,59 @@ + + + + + + Basic Calendar + basic.calendar + form + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + Calendar + ir.actions.act_window + basic.calendar + form + tree,form + + + + + + +
+
diff --git a/addons/base_calendar/base_calendar_wizard.xml b/addons/base_calendar/base_calendar_wizard.xml new file mode 100644 index 00000000000..153b490750c --- /dev/null +++ b/addons/base_calendar/base_calendar_wizard.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + diff --git a/addons/caldav/wizard/__init__.py b/addons/base_calendar/wizard/__init__.py similarity index 100% rename from addons/caldav/wizard/__init__.py rename to addons/base_calendar/wizard/__init__.py diff --git a/addons/caldav/wizard/wizard_cal_edit_event.py b/addons/base_calendar/wizard/wizard_cal_edit_event.py similarity index 100% rename from addons/caldav/wizard/wizard_cal_edit_event.py rename to addons/base_calendar/wizard/wizard_cal_edit_event.py diff --git a/addons/caldav/wizard/wizard_cal_export.py b/addons/base_calendar/wizard/wizard_cal_export.py similarity index 92% rename from addons/caldav/wizard/wizard_cal_export.py rename to addons/base_calendar/wizard/wizard_cal_export.py index 4b32f02420f..8431e9d1c71 100644 --- a/addons/caldav/wizard/wizard_cal_export.py +++ b/addons/base_calendar/wizard/wizard_cal_export.py @@ -51,15 +51,16 @@ class cal_event_export_wizard(wizard.interface): model_obj = pooler.get_pool(cr.dbname).get(model) calendar = model_obj.export_cal(cr, uid, data['ids'], context) return {'file_path': base64.encodestring(calendar), \ - 'name': 'OpenERP Events.ics'} + 'name': 'OpenERP %s.ics' % (model_obj._description)} states = { 'init': { 'actions': [_process_export_ics], 'result': {'type': 'form', 'arch':form1, 'fields':form1_fields, \ - 'state': [('end', '_Cancel', 'gtk-cancel'), ('end', 'Ok', 'gtk-ok')]}}, + 'state': [('end', '_Cancel', 'gtk-cancel'), \ + ('end', 'Ok', 'gtk-ok')]}}, } -cal_event_export_wizard('caldav.event.export') +cal_event_export_wizard('calendar.event.export') # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/caldav/wizard/wizard_cal_import.py b/addons/base_calendar/wizard/wizard_cal_import.py similarity index 98% rename from addons/caldav/wizard/wizard_cal_import.py rename to addons/base_calendar/wizard/wizard_cal_import.py index 259b3b48b03..d7295f9ce53 100644 --- a/addons/caldav/wizard/wizard_cal_import.py +++ b/addons/base_calendar/wizard/wizard_cal_import.py @@ -81,6 +81,6 @@ class cal_event_import_wizard(wizard.interface): }, } -cal_event_import_wizard('caldav.event.import') +cal_event_import_wizard('calendar.event.import') # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/caldav/wizard/wizard_cal_subscribe.py b/addons/base_calendar/wizard/wizard_cal_subscribe.py similarity index 98% rename from addons/caldav/wizard/wizard_cal_subscribe.py rename to addons/base_calendar/wizard/wizard_cal_subscribe.py index 4fcdeffd89f..c4dceab660c 100644 --- a/addons/caldav/wizard/wizard_cal_subscribe.py +++ b/addons/base_calendar/wizard/wizard_cal_subscribe.py @@ -90,6 +90,6 @@ class cal_event_subscribe_wizard(wizard.interface): }, } -cal_event_subscribe_wizard('caldav.event.subscribe') +cal_event_subscribe_wizard('calendar.event.subscribe') # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/base_contact/base_contact.py b/addons/base_contact/base_contact.py index ec529a96865..457a96a1c6b 100644 --- a/addons/base_contact/base_contact.py +++ b/addons/base_contact/base_contact.py @@ -39,6 +39,13 @@ class res_partner_contact(osv.osv): res = [(r['shortcut'], r['name']) for r in res if r['domain']=='contact'] return res + def _main_job(self, cr, uid, ids, fields, arg, context=None): + res = dict.fromkeys(ids, False) + for contact in self.browse(cr, uid, ids, context): + if contact.job_ids: + res[contact.id] = contact.job_ids[0].name_get()[0] + return res + _columns = { 'name': fields.char('Last Name', size=30,required=True), 'first_name': fields.char('First Name', size=30), @@ -52,7 +59,7 @@ class res_partner_contact(osv.osv): 'active' : fields.boolean('Active', help="If the active field is set to true, it will allow you to hide the partner contact without removing it."), '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 Function'), - 'job_id':fields.related('job_ids',type='many2one', relation='res.partner.job', string='Main Job'), + 'job_id': fields.function(_main_job, method=True, type='many2one', relation='res.partner.job', string='Main Job'), 'email': fields.char('E-Mail', size=240), 'comment' : fields.text('Notes', translate=True), 'photo' : fields.binary('Image'), @@ -81,6 +88,12 @@ res_partner_contact() class res_partner_address(osv.osv): + def search(self, cr, user, args, offset=0, limit=None, order=None, + context=None, count=False): + if context and context.has_key('address_partner_id' ) and context['address_partner_id']: + args.append(('partner_id', '=', context['address_partner_id'])) + return super(res_partner_address, self).search(cr, user, args, offset, limit, order, context, count) + #overriding of the name_get defined in base in order to remove the old contact name def name_get(self, cr, user, ids, context={}): if not len(ids): @@ -155,7 +168,7 @@ class res_partner_job(osv.osv): _defaults = { 'sequence_contact' : lambda *a: 0, - 'state' : lambda *a: 'current', + 'state' : lambda *a: 'current', } res_partner_job() diff --git a/addons/base_contact/base_contact_view.xml b/addons/base_contact/base_contact_view.xml index db7ea54314e..6123e7ed938 100644 --- a/addons/base_contact/base_contact_view.xml +++ b/addons/base_contact/base_contact_view.xml @@ -48,16 +48,13 @@
- - - - - - - - - - + + + + + + + @@ -385,7 +382,7 @@ - + diff --git a/addons/base_module_record/wizard/base_module_record_objects.py b/addons/base_module_record/wizard/base_module_record_objects.py index bd2fb95a67e..c74dd744bdf 100644 --- a/addons/base_module_record/wizard/base_module_record_objects.py +++ b/addons/base_module_record/wizard/base_module_record_objects.py @@ -56,7 +56,7 @@ def _info_default(self, cr, uid, data, context): cr.execute('select max(create_date) from ir_model_data') c=(cr.fetchone())[0].split('.')[0] c = time.strptime(c,"%Y-%m-%d %H:%M:%S") - sec=c.tm_sec + 1 + sec=c.tm_sec!=59 and c.tm_sec + 1 c=(c[0],c[1],c[2],c[3],c[4],sec,c[6],c[7],c[8]) data['form']['check_date']=time.strftime("%Y-%m-%d %H:%M:%S",c) return data['form'] @@ -108,7 +108,7 @@ class base_module_record_objects(wizard.interface): ('record', 'Record', 'gtk-ok'), ] } - }, + }, 'record': { 'actions': [], 'result': {'type':'action','action':_record_objects,'state':'intro'} @@ -124,7 +124,7 @@ class base_module_record_objects(wizard.interface): ('save', 'Continue', 'gtk-ok'), ] }, - }, + }, 'save': { 'actions': [inter_call], 'result': { diff --git a/addons/base_report_creator/base_report_creator.py b/addons/base_report_creator/base_report_creator.py index 5cbe50cf9df..36547f68ae5 100644 --- a/addons/base_report_creator/base_report_creator.py +++ b/addons/base_report_creator/base_report_creator.py @@ -64,8 +64,12 @@ class report_creator(osv.osv): fields = {} i = 0 for f in report.field_ids: - fields['field'+str(i)] = models[f.field_id.model][f.field_id.name] - i+=1 + if f.field_id.model: + fields['field'+str(i)] = models[f.field_id.model][f.field_id.name] + i+=1 + else: + fields['column_count'] = {'readonly': True, 'type': 'integer', 'string': 'Count', 'size': 64, 'name': 'column_count'} + return fields # @@ -81,8 +85,12 @@ class report_creator(osv.osv): fields = {} i = 0 for f in report.field_ids: - fields['field'+str(i)] = models[f.field_id.model][f.field_id.name] - i+=1 + if f.field_id.model: + fields['field'+str(i)] = models[f.field_id.model][f.field_id.name] + i+=1 + else: + fields['column_count'] = {'readonly': True, 'type': 'integer', 'string': 'Count', 'size': 64, 'name': 'column_count'} + arch = '\n' if view_type=='graph': arch +='' % (report.name, report.view_graph_type,report.view_graph_orientation) @@ -90,8 +98,12 @@ class report_creator(osv.osv): i = 0 for f in report.field_ids: if f.graph_mode==val: - arch += '' % ('field'+str(i),) - i+=1 + if f.field_id.model: + arch += '' % ('field'+str(i),) + i+=1 + else: + arch += '' % ('column_count',) + elif view_type=='calendar': required_types = ['date_start','date_delay','color'] set_dict = {'view_type':view_type,'string':report.name} @@ -99,13 +111,21 @@ class report_creator(osv.osv): i=0 for f in report.field_ids: if f.calendar_mode and f.calendar_mode in required_types: - set_dict[f.calendar_mode] = 'field'+str(i) - i+=1 + if f.field_id.model: + field_cal = 'field'+str(i) + i+=1 + else: + field_cal = 'column_count' + set_dict[f.calendar_mode] = field_cal del required_types[required_types.index(f.calendar_mode)] else: - temp_list.append('''''' % {'name':'field'+str(i)}) - i+=1 + if f.field_id.model: + temp_list.append('''''' % {'name':'field'+str(i)}) + i+=1 + else: + temp_list.append('''''' % {'name':'column_count'}) + arch += '''<%(view_type)s string="%(string)s" date_start="%(date_start)s" ''' %set_dict if set_dict.get('date_delay',False): arch +=''' date_delay="%(date_delay)s" '''%set_dict @@ -121,8 +141,11 @@ class report_creator(osv.osv): arch += '<%s string="%s">\n' % (view_type, report.name) i = 0 for f in report.field_ids: - arch += '' % ('field'+str(i),) - i+=1 + if f.field_id.model: + arch += '' % ('field'+str(i),) + i+=1 + else: + arch += '' % ('column_count',) arch += '' % (view_type,) result = { 'arch': arch, @@ -166,14 +189,20 @@ class report_creator(osv.osv): i = 0 fields = {} for f in report.field_ids: - fields['field'+str(i)] = (f.field_id.model, f.field_id.name) - i+=1 + if f.field_id.model: + fields['field'+str(i)] = (f.field_id.model, f.field_id.name) + i+=1 + else: + fields['column_count'] = (False, 'Count') newargs = [] newargs2 = [] for a in args: - res = self.pool.get(fields[a[0]][0])._where_calc(cr, user, [[fields[a[0]][1],a[1],a[2]]], active_test=False, context=context) - newargs+=res[0] - newargs2+=res[1] + if fields[a[0]][0]: + res = self.pool.get(fields[a[0]][0])._where_calc(cr, user, [[fields[a[0]][1],a[1],a[2]]], active_test=False, context=context) + newargs+=res[0] + newargs2+=res[1] + else: + newargs += [("count(*) " + a[1] +" " + str(a[2]))] ctx = context or {} ctx['getid'] = True report = self._sql_query_get(cr, user, [context['report_id']], 'sql_query', None, ctx, where_plus=newargs, limit=limit, offset=offset) @@ -198,7 +227,7 @@ class report_creator(osv.osv): filter_list = [] for model in models: model_dict[model.model] = self.pool.get(model.model)._table - + model_list = model_dict.keys() reference_model_dict = {} for model in model_dict: @@ -207,10 +236,22 @@ class report_creator(osv.osv): rest_list.remove(model) model_pool = self.pool.get(model) fields_get = model_pool.fields_get(cr,uid) - fields_filter = dict(filter(lambda x:x[1].get('relation',False) - and x[1].get('relation') in rest_list - and x[1].get('type')=='many2one' - and not (isinstance(model_pool._columns[x[0]],fields.function) or isinstance(model_pool._columns[x[0]],fields.related) or isinstance(model_pool._columns[x[0]],fields.dummy)), fields_get.items())) + model_columns = {} + + def _get_inherit_fields(obj): + pool_model = self.pool.get(obj) + #Adding the columns of the model itself + model_columns.update(pool_model._columns) + #Adding the columns of its _inherits + for record in pool_model._inherits.keys(): + _get_inherit_fields(record) + + _get_inherit_fields(model) + + fields_filter = dict(filter(lambda x:x[1].get('relation',False) + and x[1].get('relation') in rest_list + and x[1].get('type')=='many2one' + and not (isinstance(model_columns[x[0]],fields.function) or isinstance(model_columns[x[0]],fields.related)), fields_get.items())) if fields_filter: model in model_list and model_list.remove(model) model_count = reference_model_dict.get(model,False) @@ -225,9 +266,10 @@ class report_creator(osv.osv): reference_model_dict[v.get('relation')] = relation_count+1 else: reference_model_dict[v.get('relation')]=1 - - str_where = model_dict.get(model)+"."+ k + "=" + model_dict.get(v.get('relation'))+'.id' - where_list.append(str_where) + if k in self.pool.get(model)._columns: + str_where = model_dict.get(model)+"."+ k + "=" + model_dict.get(v.get('relation'))+'.id' + where_list.append(str_where) + if reference_model_dict: self.model_set_id = model_dict.get(reference_model_dict.keys()[reference_model_dict.values().index(min(reference_model_dict.values()))]) if model_list and not len(model_dict.keys()) == 1: @@ -250,6 +292,7 @@ class report_creator(osv.osv): if where_list: + where_list = list(set(where_list)) ret_str+="\n where \n"+" and\n".join(where_list) ret_str = ret_str.strip() if filter_list: @@ -272,12 +315,16 @@ class report_creator(osv.osv): groupby = [] i = 0 for f in obj.field_ids: + # Allowing to use count(*) + if not f.field_id.model and f.group_method == 'count': + fields.insert(0,('count(*) as column_count')) + continue t = self.pool.get(f.field_id.model_id.model)._table if f.group_method == 'group': fields.append('\t'+t+'.'+f.field_id.name+' as field'+str(i)) - groupby.append(t+'.'+f.field_id.name) else: fields.append('\t'+f.group_method+'('+t+'.'+f.field_id.name+')'+' as field'+str(i)) + groupby.append(t+'.'+f.field_id.name) i+=1 models = self._path_get(cr, uid, obj.model_ids, obj.filter_ids) check = self._id_get(cr, uid, ids[0], context) @@ -336,6 +383,9 @@ class report_creator(osv.osv): this_objs = self.browse(cr, uid, ids) for obj in this_objs: for fld in obj.field_ids: + # Allowing to use count(*) + if not fld.field_id.model and fld.group_method == 'count': + continue model_column = self.pool.get(fld.field_id.model)._columns[fld.field_id.name] if (isinstance(model_column,fields.function) or isinstance(model_column,fields.related)) and not model_column.store: return False @@ -347,7 +397,10 @@ class report_creator(osv.osv): this_objs = self.browse(cr, uid, ids) for obj in this_objs: for fld in obj.field_ids: - model_column = self.pool.get(fld.field_id.model)._columns[fld.field_id.name] + # Allowing to use count(*) + if not fld.field_id.model and fld.group_method == 'count': + continue + model_column = self.pool.get(fld.field_id.model)._columns[fld.field_id.name] if model_column._type not in aggregate_columns and fld.group_method in apply_functions: return False return True @@ -359,6 +412,9 @@ class report_creator(osv.osv): for obj in this_objs: if obj.view_type1=='calendar' or obj.view_type2=='calendar' or obj.view_type3=='calendar': for fld in obj.field_ids: + # Allowing to use count(*) + if not fld.field_id.model and fld.group_method == 'count': + continue model_column = self.pool.get(fld.field_id.model)._columns[fld.field_id.name] if fld.calendar_mode in ('date_start','date_end') and model_column._type not in ('date','datetime'): return False diff --git a/addons/base_report_creator/base_report_creator_view.xml b/addons/base_report_creator/base_report_creator_view.xml index 0d102b18c24..30c6b3735a9 100644 --- a/addons/base_report_creator/base_report_creator_view.xml +++ b/addons/base_report_creator/base_report_creator_view.xml @@ -67,7 +67,7 @@ - + diff --git a/addons/base_report_creator/wizard/base_report_creator_open.py b/addons/base_report_creator/wizard/base_report_creator_open.py index a342114d119..be7420c5744 100644 --- a/addons/base_report_creator/wizard/base_report_creator_open.py +++ b/addons/base_report_creator/wizard/base_report_creator_open.py @@ -25,13 +25,15 @@ import netsvc import time import pooler from osv import osv - +from tools.translate import _ class report_creator_open(wizard.interface): def _open_report(self, cr, uid, data, context): pool = pooler.get_pool(cr.dbname) + if context.get('report_id',False): + raise wizard.except_wizard(_('UserError'),_('No Wizards available for this object!')) rep = pool.get('base_report_creator.report').browse(cr, uid, data['id'], context) view_mode = rep.view_type1 if rep.view_type2: diff --git a/addons/base_report_creator/wizard/wiz_set_filter_fields.py b/addons/base_report_creator/wizard/wiz_set_filter_fields.py index 82083cb3858..cf4accf56e9 100644 --- a/addons/base_report_creator/wizard/wiz_set_filter_fields.py +++ b/addons/base_report_creator/wizard/wiz_set_filter_fields.py @@ -22,6 +22,7 @@ import wizard import netsvc import pooler +import tools relation_type=['one2many','many2one','many2many'] char_type = ['char','text','selection'] @@ -121,7 +122,7 @@ def _set_filter_value(self, cr, uid, data, context): model_pool = pooler.get_pool(cr.dbname).get(model_name) table_name = model_pool._table model_name = model_pool._description - + if field_type: if field_type == 'boolean': if value_data == 1: @@ -138,12 +139,12 @@ def _set_filter_value(self, cr, uid, data, context): fields_list = set_field_operator(self,table_name+"."+field_data['name'],field_data['ttype'],form_data['operator'],value_data) if fields_list: create_dict = { - 'name':model_name + "/" +field_data['field_description'] +" "+ mapping_fields[form_data['operator']] + " " + str(fields_list[2]) + " ", - 'expression':' '.join(map(str,fields_list)), + 'name':model_name + "/" +field_data['field_description'] +" "+ mapping_fields[form_data['operator']] + " " + tools.ustr(fields_list[2]) + " ", + 'expression':' '.join(map(tools.ustr,fields_list)), 'report_id':data['id'], 'condition' : form_data['condition'] } - pooler.get_pool(cr.dbname).get('base_report_creator.report.filter').create(cr,uid,create_dict) + pooler.get_pool(cr.dbname).get('base_report_creator.report.filter').create(cr,uid,create_dict,context) #end if field_type == 'many2many' and value_data and len(value_data): # pooler.get_pool(cr.dbname).get('custom.report.filter').create(cr,uid,form_data) #end if field_type: diff --git a/addons/caldav/__init__.py b/addons/caldav/__init__.py index 88bf2e4389f..7197809ab2c 100644 --- a/addons/caldav/__init__.py +++ b/addons/caldav/__init__.py @@ -20,6 +20,5 @@ ############################################################################## import caldav -import wizard # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/caldav/__terp__.py b/addons/caldav/__terp__.py index 76ead234c03..7360019a638 100644 --- a/addons/caldav/__terp__.py +++ b/addons/caldav/__terp__.py @@ -41,8 +41,7 @@ "demo_xml" : [], "update_xml" : [ 'security/ir.model.access.csv', - 'caldav_view.xml', - 'caldav_wizard.xml', + 'caldav_view.xml' ], "installable" : True, "active" : False, diff --git a/addons/caldav/caldav.py b/addons/caldav/caldav.py index 00d39433d1f..e5739983324 100644 --- a/addons/caldav/caldav.py +++ b/addons/caldav/caldav.py @@ -69,19 +69,7 @@ class calendar_attendee(osv.osv): _description = 'Attendee information' _rec_name = 'cutype' - __attribute__ = { - 'cutype': {'field':'cutype', 'type':'text'}, - 'member': {'field':'member', 'type':'text'}, - 'role': {'field':'role', 'type':'selection'}, - 'partstat': {'field':'state', 'type':'text'}, - 'rsvp': {'field':'rsvp', 'type':'boolean'}, - 'delegated-to': {'field':'delegated_to', 'type':'text'}, - 'delegated-from': {'field':'delegated_from', 'type':'text'}, - 'sent-by': {'field':'sent_by', 'type':'text'}, - 'cn': {'field':'cn', 'type':'text'}, - 'dir': {'field':'dir', 'type':'text'}, - 'language': {'field':'language', 'type':'text'}, - } + __attribute__ = {} def _get_address(self, name=None, email=None): if name and email: @@ -231,7 +219,7 @@ calendar_attendee() class res_alarm(osv.osv): _name = 'res.alarm' - _description = 'basic alarm information' + _description = 'Basic Alarm Information' _columns = { 'name':fields.char('Name', size=256, required=True), 'trigger_occurs': fields.selection([('before', 'Before'), ('after', 'After')], \ @@ -310,19 +298,7 @@ class calendar_alarm(osv.osv): _name = 'calendar.alarm' _description = 'Event alarm information' _inherits = {'res.alarm': "alarm_id"} - __attribute__ = { - 'action': {'field': 'action', 'type': 'text'}, - 'description': {'field': 'name', 'type': 'text'}, - 'summary': {'field': 'description', 'type': 'text'}, - 'attendee': {'field': 'attendee_ids', 'type': 'text'}, - 'trigger_related': {'field': 'trigger_related', 'type': 'text'}, - 'trigger_duration': {'field': 'trigger_duration', 'type': 'text'}, - 'trigger_occurs': {'field': 'trigger_occurs', 'type': 'text'}, - 'trigger_interval': {'field': 'trigger_interval', 'type': 'text'}, - 'duration': {'field': 'duration', 'type': 'text'}, - 'repeat': {'field': 'repeat', 'type': 'text'}, - 'attach': {'field': 'attach', 'type': 'text'}, - } + __attribute__ = {} _columns = { 'alarm_id': fields.many2one('res.alarm', 'Basic Alarm', ondelete='cascade'), @@ -434,41 +410,7 @@ calendar_alarm() class calendar_event(osv.osv): _name = "calendar.event" _description = "Calendar Event" - - #kept it until fields mapping implemented - __attribute__ = { - 'class': {'field': 'class', 'type': 'selection'}, - 'created': {'field': 'create_date', 'type': 'datetime'}, - 'description': {'field': 'description', 'type': 'text'}, - 'dtstart': {'field': 'date', 'type': 'datetime'}, - 'location': {'field': 'location', 'type': 'text'}, - #'organizer': {'field': 'partner_id', 'sub-field': 'name', 'type': 'many2one'}, - 'priority': {'field': 'priority', 'type': 'int'}, - 'dtstamp': {'field': 'date', 'type': 'datetime'}, - 'seq': None, - 'status': {'field': 'state', 'type': 'selection', 'mapping': \ - {'tentative': 'draft', 'confirmed': 'open', \ - 'cancelled': 'cancel'}}, - 'summary': {'field': 'name', 'type': 'text'}, - 'transp': {'field': 'transparent', 'type': 'text'}, - 'uid': {'field': 'id', 'type': 'text'}, - 'url': {'field': 'caldav_url', 'type': 'text'}, - 'recurrence-id': {'field': 'recurrent_id', 'type': 'datetime'}, - 'attendee': {'field': 'attendee_ids', 'type': 'many2many', 'object': 'calendar.attendee'}, -# 'categories': {'field': 'categ_id', 'type': 'many2one', 'object': 'crm.meeting.categ'}, - 'comment': None, - 'contact': None, - 'exdate': {'field': 'exdate', 'type': 'datetime'}, - 'exrule': {'field': 'exrule', 'type': 'text'}, - 'rstatus': None, - 'related': None, - 'resources': None, - 'rdate': None, - 'rrule': {'field': 'rrule', 'type': 'text'}, - 'x-openobject-model': {'value': _name, 'type': 'text'}, - 'dtend': {'field': 'date_deadline', 'type': 'datetime'}, - 'valarm': {'field': 'caldav_alarm_id', 'type': 'many2one', 'object': 'calendar.alarm'}, - } + __attribute__ = {} def onchange_rrule_type(self, cr, uid, ids, rtype, *args, **argv): if rtype == 'none' or not rtype: @@ -501,6 +443,7 @@ class calendar_event(osv.osv): return True _columns = { + 'id': fields.integer('ID'), 'name': fields.char('Description', size=64, required=True), 'date': fields.datetime('Date'), 'date_deadline': fields.datetime('Deadline'), @@ -537,8 +480,6 @@ rule or repeating pattern for anexception to a recurrence set"), ids = map(lambda x: caldav_id2real_id(x), ids) event_data = self.read(cr, uid, ids) event_obj = self.pool.get('basic.calendar.event') - event = self.pool.get('calendar.event') - event_obj.__attribute__.update(event.__attribute__) ical = event_obj.export_ical(cr, uid, event_data, context={'model': self._name}) cal_val = ical.serialize() cal_val = cal_val.replace('"', '').strip() @@ -547,17 +488,6 @@ rule or repeating pattern for anexception to a recurrence set"), def import_cal(self, cr, uid, data, context={}): file_content = base64.decodestring(data) event_obj = self.pool.get('basic.calendar.event') - event = self.pool.get('calendar.event') - event_obj.__attribute__.update(event.__attribute__) - - attendee_obj = self.pool.get('basic.calendar.attendee') - attendee = self.pool.get('calendar.attendee') - attendee_obj.__attribute__.update(attendee.__attribute__) - - alarm_obj = self.pool.get('basic.calendar.alarm') - alarm = self.pool.get('calendar.alarm') - alarm_obj.__attribute__.update(alarm.__attribute__) - vals = event_obj.import_ical(cr, uid, file_content) ids = [] for val in vals: @@ -793,65 +723,17 @@ class calendar_todo(osv.osv): 'duration': fields.integer('Duration'), } - #kept it until fields mapping implemented - __attribute__ = { - 'class': {'field': 'class', 'type': 'text'}, - 'completed': {'field': 'date_close', 'type': 'datetime'}, -# 'created': {'field': 'field', 'type': 'text'}, - 'description': {'field': 'description', 'type': 'text'}, -# 'dtstamp': {'field': 'field', 'type': 'text'}, - 'dtstart': {'field': 'date_start', 'type': 'datetime'}, - 'duration': {'field': 'planned_hours', 'type': 'timedelta'}, - 'due': {'field': 'date_deadline', 'type': 'datetime'}, -# 'geo': {'field': 'field', 'type': 'text'}, -# 'last-mod ': {'field': 'field', 'type': 'text'}, - 'location': {'field': 'location', 'type': 'text'}, - 'organizer': {'field': 'partner_id', 'type': 'many2one', 'object': 'res.partner'}, - 'percent': {'field': 'progress_rate', 'type': 'int'}, - 'priority': {'field': 'priority', 'type': 'text'}, -# 'recurid': {'field': 'field', 'type': 'text'}, - 'seq': {'field': 'sequence', 'type': 'text'}, - 'status': {'field': 'state', 'type': 'selection', \ - 'mapping': {'needs-action': 'draft', \ - 'completed': 'done', 'in-process': 'open', \ - 'cancelled': 'cancelled'}}, - 'summary': {'field': 'name', 'type': 'text'}, - 'uid': {'field': 'id', 'type': 'int'}, - 'url': {'field': 'caldav_url', 'type': 'text'}, -# 'attach': {'field': 'field', 'type': 'text'}, - 'attendee': {'field': 'attendee_ids', 'type': 'many2many', 'object': 'calendar.attendee'}, - 'comment': {'field': 'notes', 'type': 'text'}, -# 'contact': {'field': 'field', 'type': 'text'}, - 'exdate': {'field':'exdate', 'type':'datetime'}, - 'exrule': {'field':'exrule', 'type':'text'}, -# 'rstatus': {'field': 'field', 'type': 'text'}, -# 'related': {'field': 'field', 'type': 'text'}, -# 'resources': {'field': 'field', 'type': 'text'}, -# 'rdate': {'field': 'field', 'type': 'text'}, - 'rrule': {'field': 'rrule', 'type': 'text'}, - 'valarm': {'field':'caldav_alarm_id', 'type':'many2one', 'object': 'calendar.alarm'}, - } + __attribute__ = {} def import_cal(self, cr, uid, data, context={}): file_content = base64.decodestring(data) todo_obj = self.pool.get('basic.calendar.todo') - todo = self.pool.get('calendar.todo') - todo_obj.__attribute__.update(todo.__attribute__) - - attendee_obj = self.pool.get('basic.calendar.attendee') - crm_attendee = self.pool.get('calendar.attendee') - attendee_obj.__attribute__.update(crm_attendee.__attribute__) - - alarm_obj = self.pool.get('basic.calendar.alarm') - crm_alarm = self.pool.get('calendar.alarm') - alarm_obj.__attribute__.update(crm_alarm.__attribute__) - vals = todo_obj.import_ical(cr, uid, file_content) for val in vals: obj_tm = self.pool.get('res.users').browse(cr, uid, uid, context).company_id.project_time_mode_id if not val.has_key('planned_hours'): # 'Computes duration' in days - start = datetime.strptime(val['date_start'], '%Y-%m-%d %H:%M:%S') + start = datetime.strptime(val['date'], '%Y-%m-%d %H:%M:%S') end = datetime.strptime(val['date_deadline'], '%Y-%m-%d %H:%M:%S') diff = end - start plan = (diff.seconds/float(86400) + diff.days) * obj_tm.factor @@ -877,18 +759,7 @@ class calendar_todo(osv.osv): task.pop('planned_hours') tasks.append(task) todo_obj = self.pool.get('basic.calendar.todo') - todo = self.pool.get('calendar.todo') - todo_obj.__attribute__.update(todo.__attribute__) - - attendee_obj = self.pool.get('basic.calendar.attendee') - attendee = self.pool.get('calendar.attendee') - attendee_obj.__attribute__.update(attendee.__attribute__) - - alarm_obj = self.pool.get('basic.calendar.alarm') - alarm = self.pool.get('calendar.alarm') - alarm_obj.__attribute__.update(alarm.__attribute__) - - ical = todo_obj.export_ical(cr, uid, tasks, {'model': 'project.task'}) + ical = todo_obj.export_ical(cr, uid, tasks, context={'model': self._name}) calendar_val = ical.serialize() calendar_val = calendar_val.replace('"', '').strip() return calendar_val diff --git a/addons/caldav/caldav_wizard.xml b/addons/caldav/caldav_wizard.xml deleted file mode 100644 index 62a035889e3..00000000000 --- a/addons/caldav/caldav_wizard.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - diff --git a/addons/crm/crm_meeting_data.xml b/addons/crm/crm_meeting_data.xml index 9d8cbba044e..180d52314b1 100644 --- a/addons/crm/crm_meeting_data.xml +++ b/addons/crm/crm_meeting_data.xml @@ -1,30 +1,31 @@ - - + + - - Customer Meeting - - - - - Internal Meeting - - - - - Phone Call - - - + + Customer Meeting + + + - - Case Meeting - crm.meeting - - + + Internal Meeting + + + - + + Phone Call + + + + + + Case Meeting + crm.meeting + + + diff --git a/addons/crm/crm_meeting_view.xml b/addons/crm/crm_meeting_view.xml index 6892e8bc78f..58a6fa4246a 100644 --- a/addons/crm/crm_meeting_view.xml +++ b/addons/crm/crm_meeting_view.xml @@ -98,7 +98,7 @@