[CLN] sale: rename _get_invoice_status

follow code guidelines and use _compute_invoice_status instead.

Part-of: odoo/odoo#98068
This commit is contained in:
Victor Feyens
2022-09-01 19:16:48 +02:00
parent cc5c83e01c
commit 4e2d7b800d
5 changed files with 12 additions and 12 deletions
+2 -2
View File
@@ -134,8 +134,8 @@ class SaleOrder(models.Model):
return u' {pre}{0}{post}'.format(amount, pre=pre, post=post)
@api.depends('order_line.is_delivery', 'order_line.is_downpayment')
def _get_invoice_status(self):
super()._get_invoice_status()
def _compute_invoice_status(self):
super()._compute_invoice_status()
for order in self:
if order.invoice_status in ['no', 'invoiced']:
continue
+2 -2
View File
@@ -226,7 +226,7 @@ class SaleOrder(models.Model):
invoice_status = fields.Selection(
selection=INVOICE_STATUS,
string="Invoice Status",
compute='_get_invoice_status',
compute='_compute_invoice_status',
store=True)
# Payment fields
@@ -471,7 +471,7 @@ class SaleOrder(models.Model):
]
@api.depends('state', 'order_line.invoice_status')
def _get_invoice_status(self):
def _compute_invoice_status(self):
"""
Compute the invoice status of a SO. Possible statuses:
- no: if the SO is not in status 'sale' or 'done', we consider that there is nothing to
+2 -2
View File
@@ -406,12 +406,12 @@ class SaleOrder(models.Model):
self.ensure_one()
return self._get_points_programs() | self._get_reward_programs()
def _get_invoice_status(self):
def _compute_invoice_status(self):
# Handling of a specific situation: an order contains
# a product invoiced on delivery and a promo line invoiced
# on order. We would avoid having the invoice status 'to_invoice'
# if the created invoice will only contain the promotion line
super()._get_invoice_status()
super()._compute_invoice_status()
for order in self:
if order.invoice_status != 'to invoice':
continue
@@ -49,7 +49,7 @@ class TestSaleInvoicing(TestSaleCouponCommon):
invoiceable_lines = order._get_invoiceable_lines()
# Product was not delivered, we cannot invoice
# the product line nor the promotion line
order._get_invoice_status()
order._compute_invoice_status()
self.assertEqual(order.invoice_status, 'no')
self.assertEqual(len(invoiceable_lines), 0)
with self.assertRaises(UserError):
@@ -57,7 +57,7 @@ class TestSaleInvoicing(TestSaleCouponCommon):
order.order_line[0].qty_delivered = 1
# Product is delivered, the two lines can be invoiced.
order._get_invoice_status()
order._compute_invoice_status()
self.assertEqual(order.invoice_status, 'to invoice')
invoiceable_lines = order._get_invoiceable_lines()
self.assertEqual(order.order_line, invoiceable_lines)
@@ -67,8 +67,8 @@ class TestUpsellWarning(TestCommonSaleTimesheet):
timesheet._compute_so_line()
so.order_line._compute_qty_delivered()
so.order_line._compute_invoice_status()
so._get_invoice_status()
# Normally this method is called at the end of _get_invoice_status and other compute method. Here, we simulate for invoice_status field
so._compute_invoice_status()
# Normally this method is called at the end of _compute_invoice_status and other compute method. Here, we simulate for invoice_status field
so._compute_field_value(so._fields['invoice_status'])
self.assertEqual(len(so.activity_search(['sale.mail_act_sale_upsell'])), 0, 'No upsell warning should appear in the SO.')
@@ -78,8 +78,8 @@ class TestUpsellWarning(TestCommonSaleTimesheet):
timesheet._compute_so_line()
so.order_line._compute_qty_delivered()
so.order_line._compute_invoice_status()
so._get_invoice_status()
# Normally this method is called at the end of _get_invoice_status and other compute method. Here, we simulate for invoice_status field
so._compute_invoice_status()
# Normally this method is called at the end of _compute_invoice_status and other compute method. Here, we simulate for invoice_status field
so._compute_field_value(so._fields['invoice_status'])
# 5) Check if the SO has an 'sale.mail_act_sale_upsell' activity.