diff --git a/addons/account/account_analytic_line.py b/addons/account/account_analytic_line.py index c42597e785d..70a99adc18e 100644 --- a/addons/account/account_analytic_line.py +++ b/addons/account/account_analytic_line.py @@ -29,69 +29,15 @@ import tools from tools import config class account_analytic_line(osv.osv): - _name = 'account.analytic.line' + _inherit = 'account.analytic.line' _description = 'Analytic lines' - - def _amount_currency(self, cr, uid, ids, field_name, arg, context={}): - result = {} - for rec in self.browse(cr, uid, ids, context): - cmp_cur_id=rec.company_id.currency_id.id - aa_cur_id=rec.account_id.currency_id.id - # Always provide the amount in currency - if cmp_cur_id != aa_cur_id: - cur_obj = self.pool.get('res.currency') - ctx = {} - if rec.date and rec.amount: - ctx['date'] = rec.date - result[rec.id] = cur_obj.compute(cr, uid, rec.company_id.currency_id.id, - rec.account_id.currency_id.id, rec.amount, - context=ctx) - else: - result[rec.id]=rec.amount - return result - - def _get_account_currency(self, cr, uid, ids, field_name, arg, context={}): - result = {} - for rec in self.browse(cr, uid, ids, context): - # Always provide second currency - result[rec.id] = (rec.account_id.currency_id.id,rec.account_id.currency_id.code) - return result - - def _get_account_line(self, cr, uid, ids, context={}): - aac_ids = {} - for acc in self.pool.get('account.analytic.account').browse(cr, uid, ids): - aac_ids[acc.id] = True - aal_ids = [] - if aac_ids: - aal_ids = self.pool.get('account.analytic.line').search(cr, uid, [('account_id','in',aac_ids.keys())], context=context) - return aal_ids - _columns = { - 'name' : fields.char('Description', size=256, required=True), - 'date' : fields.date('Date', required=True), - 'amount' : fields.float('Amount', required=True, help='Calculated by multiplying the quantity and the price given in the Product\'s cost price.'), - 'unit_amount' : fields.float('Quantity', help='Specifies the amount of quantity to count.'), 'product_uom_id' : fields.many2one('product.uom', 'UoM'), 'product_id' : fields.many2one('product.product', 'Product'), - 'account_id' : fields.many2one('account.analytic.account', 'Analytic Account', required=True, ondelete='cascade', select=True), 'general_account_id' : fields.many2one('account.account', 'General Account', required=True, ondelete='cascade'), 'move_id' : fields.many2one('account.move.line', 'Move Line', ondelete='cascade', select=True), 'journal_id' : fields.many2one('account.analytic.journal', 'Analytic Journal', required=True, ondelete='cascade', select=True), 'code' : fields.char('Code', size=8), - 'user_id' : fields.many2one('res.users', 'User',), - 'currency_id': fields.function(_get_account_currency, method=True, type='many2one', relation='res.currency', string='Account currency', - store={ - 'account.analytic.account': (_get_account_line, ['company_id'], 50), - 'account.analytic.line': (lambda self,cr,uid,ids,c={}: ids, ['amount','unit_amount'],10), - }, - help="The related account currency if not equal to the company one."), - 'company_id': fields.many2one('res.company','Company',required=True), - 'amount_currency': fields.function(_amount_currency, method=True, digits_compute= dp.get_precision('Account'), string='Amount currency', - store={ - 'account.analytic.account': (_get_account_line, ['company_id'], 50), - 'account.analytic.line': (lambda self,cr,uid,ids,c={}: ids, ['amount','unit_amount'],10), - }, - help="The amount expressed in the related account currency if not equal to the company one."), 'ref': fields.char('Ref.', size=64), } _defaults = { diff --git a/addons/account/process/customer_invoice_process.xml b/addons/account/process/customer_invoice_process.xml old mode 100755 new mode 100644 diff --git a/addons/account/process/statement_process.xml b/addons/account/process/statement_process.xml old mode 100755 new mode 100644 diff --git a/addons/account/process/supplier_invoice_process.xml b/addons/account/process/supplier_invoice_process.xml old mode 100755 new mode 100644 diff --git a/addons/account/report/account_balance_landscape.py b/addons/account/report/account_balance_landscape.py old mode 100755 new mode 100644 diff --git a/addons/account/report/compare_account_balance.py b/addons/account/report/compare_account_balance.py old mode 100755 new mode 100644 diff --git a/addons/account/report/partner_balance.py b/addons/account/report/partner_balance.py old mode 100755 new mode 100644 diff --git a/addons/account/wizard/account_aged_trial_balance.py b/addons/account/wizard/account_aged_trial_balance.py old mode 100755 new mode 100644 diff --git a/addons/account/wizard/account_compare_account_balance_report.py b/addons/account/wizard/account_compare_account_balance_report.py old mode 100755 new mode 100644 diff --git a/addons/account/wizard/account_third_party_ledger.py b/addons/account/wizard/account_third_party_ledger.py old mode 100755 new mode 100644 diff --git a/addons/account/wizard/account_vat.py b/addons/account/wizard/account_vat.py old mode 100755 new mode 100644 diff --git a/addons/account_report/account_report.xml b/addons/account_report/account_report.xml old mode 100755 new mode 100644 diff --git a/addons/account_voucher/__init__.py b/addons/account_voucher/__init__.py old mode 100755 new mode 100644 diff --git a/addons/account_voucher/__openerp__.py b/addons/account_voucher/__openerp__.py old mode 100755 new mode 100644 diff --git a/addons/account_voucher/account_report.xml b/addons/account_voucher/account_report.xml old mode 100755 new mode 100644 diff --git a/addons/account_voucher/account_view.xml b/addons/account_voucher/account_view.xml old mode 100755 new mode 100644 diff --git a/addons/account_voucher/report/__init__.py b/addons/account_voucher/report/__init__.py old mode 100755 new mode 100644 diff --git a/addons/account_voucher/report/report_voucher.py b/addons/account_voucher/report/report_voucher.py old mode 100755 new mode 100644 diff --git a/addons/account_voucher/report/report_voucher_amount.py b/addons/account_voucher/report/report_voucher_amount.py old mode 100755 new mode 100644 diff --git a/addons/account_voucher/report/rml_parse.py b/addons/account_voucher/report/rml_parse.py old mode 100755 new mode 100644 diff --git a/addons/account_voucher/voucher.py b/addons/account_voucher/voucher.py old mode 100755 new mode 100644 diff --git a/addons/account_voucher/voucher_view.xml b/addons/account_voucher/voucher_view.xml old mode 100755 new mode 100644 diff --git a/addons/analytic/project.py b/addons/analytic/project.py index 9194bd9906b..2ed3fe5a67d 100644 --- a/addons/analytic/project.py +++ b/addons/analytic/project.py @@ -22,8 +22,8 @@ import time import operator -from osv import fields -from osv import osv +from osv import fields, osv +import decimal_precision as dp # # Object definition @@ -282,3 +282,70 @@ class account_analytic_account(osv.osv): account_analytic_account() + +class account_analytic_line(osv.osv): + _name = 'account.analytic.line' + _description = 'Analytic lines' + def _amount_currency(self, cr, uid, ids, field_name, arg, context={}): + result = {} + for rec in self.browse(cr, uid, ids, context): + cmp_cur_id=rec.company_id.currency_id.id + aa_cur_id=rec.account_id.currency_id.id + # Always provide the amount in currency + if cmp_cur_id != aa_cur_id: + cur_obj = self.pool.get('res.currency') + ctx = {} + if rec.date and rec.amount: + ctx['date'] = rec.date + result[rec.id] = cur_obj.compute(cr, uid, rec.company_id.currency_id.id, + rec.account_id.currency_id.id, rec.amount, + context=ctx) + else: + result[rec.id]=rec.amount + return result + + def _get_account_currency(self, cr, uid, ids, field_name, arg, context={}): + result = {} + for rec in self.browse(cr, uid, ids, context): + # Always provide second currency + result[rec.id] = (rec.account_id.currency_id.id,rec.account_id.currency_id.code) + return result + def _get_account_line(self, cr, uid, ids, context={}): + aac_ids = {} + for acc in self.pool.get('account.analytic.account').browse(cr, uid, ids): + aac_ids[acc.id] = True + aal_ids = [] + if aac_ids: + aal_ids = self.pool.get('account.analytic.line').search(cr, uid, [('account_id','in',aac_ids.keys())], context=context) + return aal_ids + + _columns = { + 'name' : fields.char('Description', size=256, required=True), + 'date' : fields.date('Date', required=True), + 'amount' : fields.float('Amount', required=True, help='Calculated by multiplying the quantity and the price given in the Product\'s cost price.'), + 'unit_amount' : fields.float('Quantity', help='Specifies the amount of quantity to count.'), + 'account_id' : fields.many2one('account.analytic.account', 'Analytic Account', required=True, ondelete='cascade', select=True), + 'user_id' : fields.many2one('res.users', 'User',), + 'company_id': fields.many2one('res.company','Company',required=True), + 'currency_id': fields.function(_get_account_currency, method=True, type='many2one', relation='res.currency', string='Account currency', + store={ + 'account.analytic.account': (_get_account_line, ['company_id'], 50), + 'account.analytic.line': (lambda self,cr,uid,ids,c={}: ids, ['amount','unit_amount'],10), + }, + help="The related account currency if not equal to the company one."), + 'amount_currency': fields.function(_amount_currency, method=True, digits_compute= dp.get_precision('Account'), string='Amount currency', + store={ + 'account.analytic.account': (_get_account_line, ['company_id'], 50), + 'account.analytic.line': (lambda self,cr,uid,ids,c={}: ids, ['amount','unit_amount'],10), + }, + help="The amount expressed in the related account currency if not equal to the company one."), + + } + _defaults = { + 'date': lambda *a: time.strftime('%Y-%m-%d'), + 'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'account.analytic.line', c), + } + _order = 'date' +account_analytic_line() + + diff --git a/addons/base_calendar/__init__.py b/addons/base_calendar/__init__.py old mode 100755 new mode 100644 diff --git a/addons/base_calendar/__openerp__.py b/addons/base_calendar/__openerp__.py old mode 100755 new mode 100644 diff --git a/addons/base_calendar/base_calendar_data.xml b/addons/base_calendar/base_calendar_data.xml old mode 100755 new mode 100644 diff --git a/addons/base_calendar/base_calendar_view.xml b/addons/base_calendar/base_calendar_view.xml old mode 100755 new mode 100644 diff --git a/addons/base_calendar/wizard/__init__.py b/addons/base_calendar/wizard/__init__.py old mode 100755 new mode 100644 diff --git a/addons/base_calendar/wizard/base_calendar_invite_attendee.py b/addons/base_calendar/wizard/base_calendar_invite_attendee.py old mode 100755 new mode 100644 diff --git a/addons/base_calendar/wizard/calendar_event_edit_all.py b/addons/base_calendar/wizard/calendar_event_edit_all.py old mode 100755 new mode 100644 diff --git a/addons/base_calendar/wizard/calendar_event_edit_all_view.xml b/addons/base_calendar/wizard/calendar_event_edit_all_view.xml old mode 100755 new mode 100644 diff --git a/addons/base_contact/process/base_contact_process.xml b/addons/base_contact/process/base_contact_process.xml old mode 100755 new mode 100644 diff --git a/addons/caldav/DAV/davcopy.py b/addons/caldav/DAV/davcopy.py old mode 100755 new mode 100644 diff --git a/addons/caldav/DAV/davmove.py b/addons/caldav/DAV/davmove.py old mode 100755 new mode 100644 diff --git a/addons/caldav/DAV/delete.py b/addons/caldav/DAV/delete.py old mode 100755 new mode 100644 diff --git a/addons/caldav/DAV/errors.py b/addons/caldav/DAV/errors.py old mode 100755 new mode 100644 diff --git a/addons/caldav/DAV/propfind.py b/addons/caldav/DAV/propfind.py old mode 100755 new mode 100644 diff --git a/addons/caldav/DAV/utils.py b/addons/caldav/DAV/utils.py old mode 100755 new mode 100644 diff --git a/addons/caldav/wizard/__init__.py b/addons/caldav/wizard/__init__.py old mode 100755 new mode 100644 diff --git a/addons/crm/crm_opportunity_view.xml b/addons/crm/crm_opportunity_view.xml index 4bdc0d90158..9ce2a89ad34 100644 --- a/addons/crm/crm_opportunity_view.xml +++ b/addons/crm/crm_opportunity_view.xml @@ -190,10 +190,13 @@ -