Skip to content

Commit e3eded4

Browse files
committed
[REF] l10n_it_edi_doi: move 'qty_invoiced_posted' to 'sale'
The field was added in stable for a specific use case. It is now moved to its rightful place, where it was originally needed. closes odoo#164963 Related: odoo/enterprise#62208 Related: odoo/upgrade#6425 Signed-off-by: William André (wan) <[email protected]>
1 parent 4bcfd5c commit e3eded4

File tree

7 files changed

+6
-47
lines changed

7 files changed

+6
-47
lines changed

Diff for: addons/account/models/account_move.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1596,7 +1596,7 @@ def _compute_partner_credit_warning(self):
15961596
move.partner_credit_warning = ''
15971597
show_warning = move.state == 'draft' and \
15981598
move.move_type == 'out_invoice' and \
1599-
self.env.company.account_use_credit_limit
1599+
move.company_id.account_use_credit_limit
16001600
if show_warning:
16011601
total_field = 'amount_total' if move.currency_id == move.company_currency_id else 'amount_total_company_currency'
16021602
current_amount = move.tax_totals[total_field]

Diff for: addons/l10n_it_edi_doi/models/__init__.py

-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,3 @@
77
from . import res_company
88
from . import res_partner
99
from . import sale_order
10-
from . import sale_order_line

Diff for: addons/l10n_it_edi_doi/models/sale_order_line.py

-31
This file was deleted.

Diff for: addons/sale/models/sale_order.py

+3-6
Original file line numberDiff line numberDiff line change
@@ -652,11 +652,8 @@ def _compute_tax_country_id(self):
652652

653653
@api.depends('order_line.amount_to_invoice')
654654
def _compute_amount_to_invoice(self):
655-
if not self.env.company.account_use_credit_limit:
656-
self.amount_to_invoice = 0.0
657-
else:
658-
for order in self:
659-
order.amount_to_invoice = sum(order.order_line.mapped('amount_to_invoice'))
655+
for order in self:
656+
order.amount_to_invoice = sum(order.order_line.mapped('amount_to_invoice'))
660657

661658
@api.depends('order_line.amount_invoiced')
662659
def _compute_amount_invoiced(self):
@@ -669,7 +666,7 @@ def _compute_partner_credit_warning(self):
669666
order.with_company(order.company_id)
670667
order.partner_credit_warning = ''
671668
show_warning = order.state in ('draft', 'sent') and \
672-
self.env.company.account_use_credit_limit
669+
order.company_id.account_use_credit_limit
673670
if show_warning:
674671
order.partner_credit_warning = self.env['account.move']._build_credit_warning_message(
675672
order,

Diff for: addons/sale/models/sale_order_line.py

-2
Original file line numberDiff line numberDiff line change
@@ -1062,8 +1062,6 @@ def _compute_untaxed_amount_to_invoice(self):
10621062

10631063
@api.depends('discount', 'price_total', 'product_uom_qty', 'qty_delivered', 'qty_invoiced_posted')
10641064
def _compute_amount_to_invoice(self):
1065-
if not self.company_id.account_use_credit_limit:
1066-
self.amount_to_invoice = 0.0
10671065
for line in self:
10681066
if line.product_uom_qty:
10691067
uom_qty_to_consider = line.qty_delivered if line.product_id.invoice_policy == 'delivery' else line.product_uom_qty

Diff for: addons/sale/tests/test_credit_limit.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,13 @@ def test_credit_limit_multi_company(self):
4848
'order_line': [Command.create({
4949
'product_id': self.company_data_2['product_order_no'].id,
5050
'price_unit': 1000.0,
51-
})]
51+
})],
5252
})
5353

54-
self.assertEqual(self.partner_a.credit_to_invoice, 0.0)
54+
self.assertEqual(self.partner_a.with_company(company2).credit_to_invoice, 0.0)
5555
sale_order.action_confirm()
5656

5757
self.partner_a.invalidate_recordset(['credit', 'credit_to_invoice'])
58-
self.assertEqual(self.partner_a.credit_to_invoice, 0.0)
5958
self.assertEqual(self.partner_a.with_company(company2).credit_to_invoice, 1000.0)
6059
partner_a_multi_company = self.partner_a.with_context(allowed_company_ids=[self.env.company.id, company2.id])
6160
self.assertEqual(partner_a_multi_company.credit_to_invoice, 0.0)

Diff for: addons/sale/tests/test_sale_to_invoice.py

-3
Original file line numberDiff line numberDiff line change
@@ -938,7 +938,6 @@ def test_amount_to_invoice_multiple_so(self):
938938
""" Testing creating two SOs with the same customer and invoicing them together. We have to ensure
939939
that the amount to invoice is correct for each SO.
940940
"""
941-
self.env.company.account_use_credit_limit = True
942941
sale_order_1 = self.env['sale.order'].create({
943942
'partner_id': self.partner_a.id,
944943
'order_line': [
@@ -977,7 +976,6 @@ def test_amount_to_invoice_one_line_multiple_so(self):
977976
""" Testing creating two SOs linked to the same invoice line. Drawback: the substracted
978977
amount to the amount_total will take both sale order into account.
979978
"""
980-
self.env.company.account_use_credit_limit = True
981979
sale_order_1 = self.env['sale.order'].create({
982980
'partner_id': self.partner_a.id,
983981
'order_line': [
@@ -1020,7 +1018,6 @@ def test_amount_to_invoice_price_unit_change(self):
10201018
We check that the 'amount_to_invoice' relies only on the posted invoice quantity,
10211019
and is not affected by price changes that occurred during invoice creation.
10221020
"""
1023-
self.env.company.account_use_credit_limit = True
10241021
so = self.env['sale.order'].create({
10251022
'partner_id': self.partner_a.id,
10261023
'partner_invoice_id': self.partner_a.id,

0 commit comments

Comments
 (0)