From 80ccdb314500542eec00d3194913135bdd6568a2 Mon Sep 17 00:00:00 2001 From: Gert Pellin Date: Thu, 13 Dec 2018 12:13:54 +0000 Subject: [PATCH] [IMP] point_of_sale: Mapping accounts accounts mapping of fiscal positions should work on the PoS as it works in Sales Description of the issue/feature this PR addresses: Setup a fiscal position with account mapping for income account and receivable account Make a pos_order with the fiscal position Current behavior before PR: When pos is closed, account mapping is not done and the account_move does not take the mapped income account nor receivable account Desired behavior after PR is merged: The account_move should take the mapped income account and receivable account task: https://www.odoo.com/web#id=1916865&action=333&active_id=1428&model=project.task&view_type=form&menu_id=4720 closes odoo/odoo#29433 --- addons/point_of_sale/models/pos_order.py | 14 ++++++++++---- addons/point_of_sale/static/src/js/screens.js | 2 +- addons/point_of_sale/views/pos_config_view.xml | 4 ++-- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/addons/point_of_sale/models/pos_order.py b/addons/point_of_sale/models/pos_order.py index 1101c9137c1..96dcc815c51 100644 --- a/addons/point_of_sale/models/pos_order.py +++ b/addons/point_of_sale/models/pos_order.py @@ -276,8 +276,9 @@ class PosOrder(models.Model): raise UserError(_('Please define income ' 'account for this product: "%s" (id:%d).') % (line.product_id.name, line.product_id.id)) - if order.fiscal_position_id.account_ids: - income_account = order.fiscal_position_id.map_account(income_account) + fpos = order.fiscal_position_id or order.partner_id.property_account_position_id + if fpos: + income_account = fpos.map_account(income_account) name = line.product_id.name if line.notice: @@ -385,7 +386,12 @@ class PosOrder(models.Model): current_company = order.sale_journal.company_id account_def = IrProperty.get( 'property_account_receivable_id', 'res.partner') - order_account = order.partner_id.property_account_receivable_id.id or account_def and account_def.id + order_account = order.partner_id.property_account_receivable_id or account_def + # If fiscal position, then map order account + fpos = order.fiscal_position_id or order.partner_id.property_account_position_id + if fpos: + order_account = fpos.map_account(order_account) + partner_id = ResPartner._find_accounting_partner(order.partner_id).id or False if not move: # Create an entry for the sale @@ -462,7 +468,7 @@ class PosOrder(models.Model): amount_total = order.amount_total data = { 'name': _("Trade Receivables"), # order.name, - 'account_id': order_account, + 'account_id': order_account.id, 'credit': ((amount_total < 0) and -amount_total) or 0.0, 'debit': ((amount_total > 0) and amount_total) or 0.0, 'partner_id': partner_id diff --git a/addons/point_of_sale/static/src/js/screens.js b/addons/point_of_sale/static/src/js/screens.js index b0f5ac10dfa..2d017af9934 100644 --- a/addons/point_of_sale/static/src/js/screens.js +++ b/addons/point_of_sale/static/src/js/screens.js @@ -2170,7 +2170,7 @@ var set_fiscal_position_button = ActionButtonWidget.extend({ var selection_list = no_fiscal_position.concat(fiscal_positions); self.gui.show_popup('selection',{ - title: _t('Select tax'), + title: _t('Select Fiscal Position'), list: selection_list, confirm: function (fiscal_position) { var order = self.pos.get_order(); diff --git a/addons/point_of_sale/views/pos_config_view.xml b/addons/point_of_sale/views/pos_config_view.xml index 2994faa3078..9c4616198df 100644 --- a/addons/point_of_sale/views/pos_config_view.xml +++ b/addons/point_of_sale/views/pos_config_view.xml @@ -207,14 +207,14 @@

Taxes

-
+