[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
This commit is contained in:
Gert Pellin
2019-02-22 13:19:22 +00:00
parent ec07e72845
commit 80ccdb3145
3 changed files with 13 additions and 7 deletions
+10 -4
View File
@@ -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
@@ -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();
@@ -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">