Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0][FIX] delivery_package_fee: call map_tax in fiscal.position properly #718

Merged
merged 1 commit into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions delivery_package_fee/models/sale_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,8 @@ def _prepare_package_fee_line(self, package_fee, picking, qty, price_unit):
lambda t: t.company_id.id == self.company_id.id
)
taxes_ids = taxes.ids
if self.partner_id and self.fiscal_position_id:
taxes_ids = self.fiscal_position_id.map_tax(
taxes, fee_product, self.partner_id
).ids
if self.fiscal_position_id:
taxes_ids = self.fiscal_position_id.map_tax(taxes).ids

# line description
if fee_product.description_sale:
Expand Down
63 changes: 63 additions & 0 deletions delivery_package_fee/tests/test_package_fee.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,69 @@ def test_package_fee_simple(self):
],
)

def test_package_fee_simple_with_fiscal_position_tax(self):
"""All stock moves processed at once"""

# Creating taxes and fiscal position
tax_price_include = self.env["account.tax"].create(
{
"name": "10% inc",
"type_tax_use": "sale",
"amount_type": "percent",
"amount": 10,
"price_include": True,
"include_base_amount": True,
}
)
tax_price_exclude = self.env["account.tax"].create(
{
"name": "15% exc",
"type_tax_use": "sale",
"amount_type": "percent",
"amount": 15,
}
)

fiscal_position = self.env["account.fiscal.position"].create(
{
"name": "fiscal_pos_a",
"tax_ids": [
(
0,
None,
{
"tax_src_id": tax_price_include.id,
"tax_dest_id": tax_price_exclude.id,
},
),
],
}
)

# Setting tax in fiscal position on fee2 product
self.fee2.taxes_id = tax_price_include
self.sale.fiscal_position_id = fiscal_position

picking = self.sale.picking_ids
self.assertEqual(picking.state, "assigned")
picking.move_line_ids[0].result_package_id = self.pack1
picking.move_line_ids[0].qty_done = 10.0
picking.move_line_ids[1].result_package_id = self.pack2
picking.move_line_ids[1].qty_done = 10.0
picking._action_done()
self.assertEqual(picking.state, "done")

so_line_fee1 = self.sale.order_line.filtered(
lambda l: l.product_id == self.fee1
)
so_line_fee2 = self.sale.order_line.filtered(
lambda l: l.product_id == self.fee2
)

self.assertNotEqual(so_line_fee1.tax_id[0], tax_price_exclude)
# only fee2 has tax tax_price_exclude due to defined fiscal position
self.assertEqual(so_line_fee2.tax_id[0], tax_price_exclude)

def test_package_fee_backorder(self):
"""Stock moves valided in 2 times using a backorder"""
picking = self.sale.picking_ids
Expand Down
Loading