Skip to content

Commit

Permalink
account_cutoff_accrual_sale_stock: coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
jbaudoux committed Feb 12, 2025
1 parent 9eb720a commit 2f87938
Show file tree
Hide file tree
Showing 5 changed files with 414 additions and 2 deletions.
2 changes: 2 additions & 0 deletions account_cutoff_accrual_sale_stock/models/sale_order_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ def _get_cutoff_accrual_lines_delivered_after(self, cutoff):
def _get_cutoff_accrual_delivered_min_date(self):
"""Return first delivery date"""
self.ensure_one()
if self.qty_delivered_method != "stock_move":
return super()._get_cutoff_accrual_delivered_min_date()
stock_moves = self.move_ids.filtered(lambda m: m.state == "done")
if not stock_moves:
return
Expand Down
3 changes: 2 additions & 1 deletion account_cutoff_accrual_sale_stock/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
from . import test_cutoff_revenue
from . import test_cutoff_revenue_on_delivery
from . import test_cutoff_revenue_on_order
14 changes: 14 additions & 0 deletions account_cutoff_accrual_sale_stock/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@


class TestAccountCutoffAccrualSaleStockCommon(TestAccountCutoffAccrualSaleCommon):
def _get_service_lines(self, cutoff):
return cutoff.line_ids.filtered(
lambda line: line.product_id.detailed_type == "service"
)

def _get_product_lines(self, cutoff):
return cutoff.line_ids.filtered(
lambda line: line.product_id.detailed_type == "product"
)

def _confirm_so_and_do_picking(self, qty_done):
self.so.action_confirm()
# Make invoice for product on order
Expand All @@ -17,6 +27,10 @@ def _confirm_so_and_do_picking(self, qty_done):
"no",
'SO invoice_status should be "nothing to invoice" after confirming',
)
self._do_picking(qty_done)
return invoice

def _do_picking(self, qty_done):
# Deliver
pick = self.so.picking_ids
pick.action_assign()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
from .common import TestAccountCutoffAccrualSaleStockCommon


class TestAccountCutoffAccrualSaleStock(TestAccountCutoffAccrualSaleStockCommon):
class TestAccountCutoffAccrualSaleStockOnDelivery(
TestAccountCutoffAccrualSaleStockCommon
):
def test_accrued_revenue_empty(self):
"""Test cutoff when there is no SO."""
cutoff = self.revenue_cutoff
Expand Down
Loading

0 comments on commit 2f87938

Please sign in to comment.