Skip to content

Commit

Permalink
[IMP] point_of_sale: Mapping accounts
Browse files Browse the repository at this point in the history
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 #29433
  • Loading branch information
Gert Pellin committed Feb 22, 2019
1 parent ec07e72 commit 80ccdb3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
14 changes: 10 additions & 4 deletions addons/point_of_sale/models/pos_order.py
Expand Up @@ -276,8 +276,9 @@ def _flatten_tax_and_children(taxes, group_done=None):
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:
Expand Down Expand Up @@ -385,7 +386,12 @@ def add_anglosaxon_lines(grouped_data):
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
Expand Down Expand Up @@ -462,7 +468,7 @@ def insert_data(data_type, values):
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
Expand Down
2 changes: 1 addition & 1 deletion addons/point_of_sale/static/src/js/screens.js
Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions addons/point_of_sale/views/pos_config_view.xml
Expand Up @@ -207,14 +207,14 @@
</div>
<h2>Taxes</h2>
<div class="row mt16 o_settings_container">
<div class="col-12 col-lg-6 o_setting_box" title="Choose a specific tax regime at the order depending on the kind of customer (tax exempt, onsite vs. takeaway, etc.).">
<div class="col-12 col-lg-6 o_setting_box" title="Choose a specific fiscal position at the order depending on the kind of customer (tax exempt, onsite vs. takeaway, etc.).">
<div class="o_setting_left_pane">
<field name="tax_regime_selection"/>
</div>
<div class="o_setting_right_pane">
<label for="tax_regime_selection" string="Fiscal Position per Order"/>
<div class="text-muted">
Choose among several tax regimes when processing an order
Choose among fiscal positions when processing an order
</div>
<div class="content-group" attrs="{'invisible': [('tax_regime_selection', '=', False)]}">
<div class="mt16">
Expand Down

0 comments on commit 80ccdb3

Please sign in to comment.