diff --git a/addons/account/account.py b/addons/account/account.py index 00d2ec3dcba..dbff7730fc9 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -281,7 +281,16 @@ class account_account(osv.osv): 'parent_left': fields.integer('Parent Left', select=1), 'parent_right': fields.integer('Parent Right', select=1), - 'check_history': fields.boolean('Display History', help="Check this box if you want to print all entries when printing the General Ledger, otherwise it will only print its balance.") + 'currency_mode': fields.selection([('current','At Date'),('average','Average Rate')], 'Outgoing Currencies Rate', + help= + 'This will select how is computed the current currency rate for outgoing transactions. '\ + 'In most countries the legal method is "average" but only a few softwares are able to '\ + 'manage this. So if you import from another software, you may have to use the rate at date. ' \ + 'Incoming transactions, always use the rate at date.', \ + required=True), + 'check_history': fields.boolean('Display History', + help="Check this box if you want to print all entries when printing the General Ledger, "\ + "otherwise it will only print its balance.") } def _default_company(self, cr, uid, context={}): @@ -296,6 +305,7 @@ class account_account(osv.osv): 'company_id': _default_company, 'active': lambda *a: True, 'check_history': lambda *a: True, + 'currency_mode': lambda *a: 'current' } def _check_recursion(self, cr, uid, ids): diff --git a/addons/account/account_bank_statement.py b/addons/account/account_bank_statement.py index 91ee7d094b1..76e5aeba886 100644 --- a/addons/account/account_bank_statement.py +++ b/addons/account/account_bank_statement.py @@ -191,8 +191,14 @@ class account_bank_statement(osv.osv): continue torec = [] + if move.amount >= 0: + account_id = st.journal_id.default_credit_account_id.id + else: + account_id = st.journal_id.default_debit_account_id.id + acc_cur = ((move.amount<=0) and st.journal_id.default_debit_account_id) or move.account_id amount = res_currency_obj.compute(cr, uid, st.currency.id, - company_currency_id, move.amount, context=context) + company_currency_id, move.amount, context=context, + account=acc_cur) if move.reconcile_id and move.reconcile_id.line_new_ids: for newline in move.reconcile_id.line_new_ids: amount += newline.amount @@ -213,7 +219,8 @@ class account_bank_statement(osv.osv): } amount = res_currency_obj.compute(cr, uid, st.currency.id, - company_currency_id, move.amount, context=context) + company_currency_id, move.amount, context=context, + account=acc_cur) if move.account_id and move.account_id.currency_id: val['currency_id'] = move.account_id.currency_id.id @@ -221,7 +228,8 @@ class account_bank_statement(osv.osv): amount_cur = move.amount else: amount_cur = res_currency_obj.compute(cr, uid, company_currency_id, - move.account_id.currency_id.id, amount, context=context) + move.account_id.currency_id.id, amount, context=context, + account=acc_cur) val['amount_currency'] = amount_cur torec.append(account_move_line_obj.create(cr, uid, val , context=context)) @@ -242,11 +250,6 @@ class account_bank_statement(osv.osv): 'period_id': st.period_id.id, }, context=context) - if amount >= 0: - account_id = st.journal_id.default_credit_account_id.id - else: - account_id = st.journal_id.default_debit_account_id.id - # Fill the secondary amount/currency # if currency is not the same than the company amount_currency = False @@ -370,10 +373,16 @@ class account_bank_statement_reconcile(osv.osv): context=context).company_id.currency_id.id currency_id = context.get('currency_id', company_currency_id) + acc_cur = None + if context.get('journal_id', False) and context.get('account_id',False): + st =self.pool.get('account.journal').browse(cursor, user, context['journal_id']) + acc = self.pool.get('account.account').browse(cursor, user, context['account_id']) + acc_cur = (( context.get('amount',0.0)<=0) and st.default_debit_account_id) or acc + for reconcile_id in ids: res[reconcile_id] = res_currency_obj.compute(cursor, user, currency_id, company_currency_id, - context.get('amount', 0.0), context=context) + context.get('amount', 0.0), context=context, account=acc_cur) return res def _default_amount(self, cursor, user, context=None): @@ -386,9 +395,15 @@ class account_bank_statement_reconcile(osv.osv): context=context).company_id.currency_id.id currency_id = context.get('currency_id', company_currency_id) + acc_cur = None + if context.get('journal_id', False) and context.get('account_id',False): + st =self.pool.get('account.journal').browse(cursor, user, context['journal_id']) + acc = self.pool.get('account.account').browse(cursor, user, context['account_id']) + acc_cur = (( context.get('amount',0.0)<=0) and st.default_debit_account_id) or acc + return res_currency_obj.compute(cursor, user, currency_id, company_currency_id, - context.get('amount', 0.0), context=context) + context.get('amount', 0.0), context=context, account=acc_cur) def _total_currency(self, cursor, user, ids, name, attrs, context=None): res = {} diff --git a/addons/account/account_view.xml b/addons/account/account_view.xml index 8d652e06723..6b793707cb4 100644 --- a/addons/account/account_view.xml +++ b/addons/account/account_view.xml @@ -122,8 +122,9 @@ - + + @@ -323,7 +324,7 @@ - +
@@ -333,7 +334,7 @@ - + diff --git a/addons/mrp/mrp.py b/addons/mrp/mrp.py index 199e60885a4..b72d9ce0503 100644 --- a/addons/mrp/mrp.py +++ b/addons/mrp/mrp.py @@ -1001,7 +1001,7 @@ class mrp_procurement(osv.osv): } taxes_ids = procurement.product_id.product_tmpl_id.supplier_taxes_id - self.pool.get('account.fiscal.position').map_tax(cr, uid, partner, taxes) + self.pool.get('account.fiscal.position').map_tax(cr, uid, partner, taxes_ids) line.update({ 'taxes_id':[(6,0,taxes_ids)] }) diff --git a/addons/product_margin/product_margin_view.xml b/addons/product_margin/product_margin_view.xml index 12f2d436903..34ce72e01c1 100644 --- a/addons/product_margin/product_margin_view.xml +++ b/addons/product_margin/product_margin_view.xml @@ -2,76 +2,79 @@ - - + + - + - - + + product.margin.graph product.product graph + - + - + product.margin.form.inherit product.product - form + form 5 - - - + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + product.margin.tree product.product tree + @@ -89,6 +92,6 @@ - + diff --git a/addons/product_margin/wizard/wizard_product_margin.py b/addons/product_margin/wizard/wizard_product_margin.py index 1c7376d38c1..13ca60bf055 100644 --- a/addons/product_margin/wizard/wizard_product_margin.py +++ b/addons/product_margin/wizard/wizard_product_margin.py @@ -43,9 +43,9 @@ def _action_open_window(self, cr, uid, data, context): 'res_model':'product.product', 'type': 'ir.actions.act_window', 'view_id': view_res, - } - - + } + + class product_margins(wizard.interface): form1 = '''
@@ -58,13 +58,13 @@ class product_margins(wizard.interface): 'from_date': { 'string': 'From', 'type': 'date', - 'default': lambda *a:time.strftime('%Y-01-01'), + 'default': lambda *a:time.strftime('%Y-01-01'), }, 'to_date': { 'string': 'To', 'type': 'date', - 'default': lambda *a:time.strftime('%Y-12-31'), + 'default': lambda *a:time.strftime('%Y-12-31'), }, 'invoice_state': {