Skip to content

Commit 7a88199

Browse files
committed
[FIX] account: draft bill entries in partner ledger
--Before-- When creating a new vendor bill through Vendors > 'Example Vendor 1'> Vendor Bills (magic button), if the vendor was changed to 'Example Vendor 2' and the draft saved then it would show up under the 'Example Vendor 1' in the Partner Ledger instead of under the correct 'Example Vendor 2'.  This is due to the partner_id being defined in the context when going through the 'Example Vendor 1' view.  --Now-- During the creation of the account move lines we use a context without the default_partner_id. The Partner Ledger now shows the draft bill entry under the right vendor. opw-4407709 closes odoo#192567 Signed-off-by: William André (wan) <[email protected]>
1 parent 045425f commit 7a88199

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

addons/account/models/account_move.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from odoo import api, fields, models, _, Command
1414
from odoo.addons.account.tools import format_rf_reference
1515
from odoo.exceptions import UserError, ValidationError, AccessError, RedirectWarning
16+
from odoo.tools.misc import clean_context
1617
from odoo.tools import (
1718
date_utils,
1819
email_re,
@@ -30,7 +31,6 @@
3031
sql
3132
)
3233

33-
3434
MAX_HASH_VERSION = 3
3535

3636
PAYMENT_STATE_SELECTION = [
@@ -2141,7 +2141,7 @@ def dirty():
21412141
if to_delete:
21422142
self.env['account.move.line'].browse(to_delete).with_context(dynamic_unlink=True).unlink()
21432143
if to_create:
2144-
self.env['account.move.line'].create([
2144+
self.env['account.move.line'].with_context(clean_context(self.env.context)).create([
21452145
{**key, **values, 'display_type': line_type}
21462146
for key, values in to_create.items()
21472147
])

addons/account/tests/test_account_move_out_invoice.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4165,3 +4165,15 @@ def test_on_quick_encoding_non_accounting_lines(self):
41654165
with move_form.invoice_line_ids.new() as invoice_line_form:
41664166
invoice_line_form.display_type = 'line_section'
41674167
move_form.save()
4168+
4169+
def test_out_invoice_partner_context(self):
4170+
"""No line should take the partner of the context instead of the one specified in the create vals."""
4171+
move = self.env['account.move'].with_context(default_partner_id=self.partner_b.id).create({
4172+
'move_type': 'out_invoice',
4173+
'partner_id': self.partner_a.id,
4174+
'invoice_date': '2017-01-01',
4175+
'invoice_line_ids': [Command.create({
4176+
'price_unit': 1000.0,
4177+
})],
4178+
})
4179+
self.assertEqual(move.line_ids.partner_id, self.partner_a)

0 commit comments

Comments
 (0)