Skip to content

Commit

Permalink
[IMP] account_cutoff_accrual_*
Browse files Browse the repository at this point in the history
Add support for service products
  • Loading branch information
jbaudoux committed Jan 24, 2024
1 parent a92bdaf commit 23e3c60
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 8 deletions.
11 changes: 10 additions & 1 deletion account_cutoff_accrual_order_base/models/order_line_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,18 @@ def _get_cutoff_accrual_line_delivered_after(self, cutoff):
"""Return order lines"""
return self.browse()

Check warning on line 73 in account_cutoff_accrual_order_base/models/order_line_mixin.py

View check run for this annotation

Codecov / codecov/patch

account_cutoff_accrual_order_base/models/order_line_mixin.py#L73

Added line #L73 was not covered by tests

def _get_cutoff_accrual_delivered_quantity(self, cutoff):
def _get_cutoff_accrual_delivered_service_quantity(self, cutoff):
return NotImplemented()

Check warning on line 76 in account_cutoff_accrual_order_base/models/order_line_mixin.py

View check run for this annotation

Codecov / codecov/patch

account_cutoff_accrual_order_base/models/order_line_mixin.py#L76

Added line #L76 was not covered by tests

def _get_cutoff_accrual_delivered_stock_quantity(self, cutoff):
return NotImplemented()

Check warning on line 79 in account_cutoff_accrual_order_base/models/order_line_mixin.py

View check run for this annotation

Codecov / codecov/patch

account_cutoff_accrual_order_base/models/order_line_mixin.py#L79

Added line #L79 was not covered by tests

def _get_cutoff_accrual_delivered_quantity(self, cutoff):
self.ensure_one()
if self.product_id.detailed_type == "service":
return self._get_cutoff_accrual_delivered_service_quantity(cutoff)

Check warning on line 84 in account_cutoff_accrual_order_base/models/order_line_mixin.py

View check run for this annotation

Codecov / codecov/patch

account_cutoff_accrual_order_base/models/order_line_mixin.py#L84

Added line #L84 was not covered by tests
return self._get_cutoff_accrual_delivered_stock_quantity(cutoff)

def _get_cutoff_accrual_lines_delivered_after(self, cutoff):
return self.browse()

Expand Down
10 changes: 8 additions & 2 deletions account_cutoff_accrual_purchase/models/purchase_order_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ def _get_cutoff_accrual_lines_invoiced_after(self, cutoff):
purchases = self.env["purchase.order"].browse(purchase_ids)
return purchases.order_line

def _get_cutoff_accrual_delivered_quantity(self, cutoff):
def _get_cutoff_accrual_delivered_service_quantity(self, cutoff):
# By default, no cutoff on purchase. Set received as invoiced.
self.ensure_one()
return self.qty_received
return self._get_cutoff_accrual_invoiced_quantity(cutoff)

Check warning on line 64 in account_cutoff_accrual_purchase/models/purchase_order_line.py

View check run for this annotation

Codecov / codecov/patch

account_cutoff_accrual_purchase/models/purchase_order_line.py#L63-L64

Added lines #L63 - L64 were not covered by tests

def _get_cutoff_accrual_delivered_stock_quantity(self, cutoff):
# By default, no cutoff on purchase. Set received as invoiced.
self.ensure_one()
return self._get_cutoff_accrual_invoiced_quantity(cutoff)

Check warning on line 69 in account_cutoff_accrual_purchase/models/purchase_order_line.py

View check run for this annotation

Codecov / codecov/patch

account_cutoff_accrual_purchase/models/purchase_order_line.py#L68-L69

Added lines #L68 - L69 were not covered by tests
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ def _get_cutoff_accrual_delivered_min_date(self):
return

Check warning on line 38 in account_cutoff_accrual_purchase_stock/models/purchase_order_line.py

View check run for this annotation

Codecov / codecov/patch

account_cutoff_accrual_purchase_stock/models/purchase_order_line.py#L38

Added line #L38 was not covered by tests
return min(stock_moves.mapped("date")).date()

def _get_cutoff_accrual_delivered_quantity(self, cutoff):
def _get_cutoff_accrual_delivered_stock_quantity(self, cutoff):
self.ensure_one()
received_qty = super()._get_cutoff_accrual_delivered_quantity(cutoff)
received_qty = self.qty_received
# The quantity received on the PO line must be deducted from all
# moves done after the cutoff date.
cutoff_nextday = cutoff._nextday_start_dt()
Expand Down
10 changes: 9 additions & 1 deletion account_cutoff_accrual_sale/models/sale_order_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@ def _get_cutoff_accrual_lines_invoiced_after(self, cutoff):
sales = self.env["sale.order"].browse(sale_ids)
return sales.order_line

def _get_cutoff_accrual_delivered_quantity(self, cutoff):
def _get_cutoff_accrual_delivered_service_quantity(self, cutoff):
self.ensure_one()

Check warning on line 68 in account_cutoff_accrual_sale/models/sale_order_line.py

View check run for this annotation

Codecov / codecov/patch

account_cutoff_accrual_sale/models/sale_order_line.py#L68

Added line #L68 was not covered by tests
if self.product_id.invoice_policy == "order":
return self.product_uom_qty
return self.qty_delivered

Check warning on line 71 in account_cutoff_accrual_sale/models/sale_order_line.py

View check run for this annotation

Codecov / codecov/patch

account_cutoff_accrual_sale/models/sale_order_line.py#L70-L71

Added lines #L70 - L71 were not covered by tests

def _get_cutoff_accrual_delivered_stock_quantity(self, cutoff):
self.ensure_one()

Check warning on line 74 in account_cutoff_accrual_sale/models/sale_order_line.py

View check run for this annotation

Codecov / codecov/patch

account_cutoff_accrual_sale/models/sale_order_line.py#L74

Added line #L74 was not covered by tests
if self.product_id.invoice_policy == "order":
return self.product_uom_qty
return self.qty_delivered

Check warning on line 77 in account_cutoff_accrual_sale/models/sale_order_line.py

View check run for this annotation

Codecov / codecov/patch

account_cutoff_accrual_sale/models/sale_order_line.py#L76-L77

Added lines #L76 - L77 were not covered by tests
4 changes: 2 additions & 2 deletions account_cutoff_accrual_sale_stock/models/sale_order_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ def _get_cutoff_accrual_delivered_min_date(self):
return

Check warning on line 37 in account_cutoff_accrual_sale_stock/models/sale_order_line.py

View check run for this annotation

Codecov / codecov/patch

account_cutoff_accrual_sale_stock/models/sale_order_line.py#L37

Added line #L37 was not covered by tests
return min(stock_moves.mapped("date")).date()

def _get_cutoff_accrual_delivered_quantity(self, cutoff):
def _get_cutoff_accrual_delivered_stock_quantity(self, cutoff):
self.ensure_one()
delivered_qty = super()._get_cutoff_accrual_delivered_quantity(cutoff)
delivered_qty = self.qty_delivered
# The quantity delivered on the SO line must be deducted from all
# moves done after the cutoff date.
cutoff_nextday = cutoff._nextday_start_dt()
Expand Down

0 comments on commit 23e3c60

Please sign in to comment.