From f1d53760cf27b7b10a4017437dab538a725ccb10 Mon Sep 17 00:00:00 2001 From: Denis Roussel Date: Sun, 24 Oct 2021 15:54:16 +0200 Subject: [PATCH] [14.0][IMP] intrastat_product: Add hook for test values --- intrastat_product/tests/common_purchase.py | 19 +++++++++++-------- intrastat_product/tests/common_sale.py | 15 +++++++++------ 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/intrastat_product/tests/common_purchase.py b/intrastat_product/tests/common_purchase.py index 1abc011..7574457 100644 --- a/intrastat_product/tests/common_purchase.py +++ b/intrastat_product/tests/common_purchase.py @@ -11,6 +11,16 @@ class IntrastatPurchaseCommon(IntrastatProductCommon): - Supplier in Germany """ + def _get_expected_vals(self, line): + return { + "declaration_type": "arrivals", + "suppl_unit_qty": line.qty_received, + "hs_code_id": line.product_id.hs_code_id, + "product_origin_country_id": line.product_id.origin_country_id, + "amount_company_currency": line.price_subtotal, + "src_dest_country_id": line.partner_id.country_id, + } + def _check_line_values(self, final=False, declaration=None, purchase=None): """ This method allows to test computation lines and declaration @@ -21,14 +31,7 @@ class IntrastatPurchaseCommon(IntrastatProductCommon): if purchase is None: purchase = self.purchase for line in purchase.order_line: - expected_vals = { - "declaration_type": "arrivals", - "suppl_unit_qty": line.qty_received, - "hs_code_id": line.product_id.hs_code_id, - "product_origin_country_id": line.product_id.origin_country_id, - "amount_company_currency": line.price_subtotal, - "src_dest_country_id": line.partner_id.country_id, - } + expected_vals = self._get_expected_vals(line) comp_line = declaration.computation_line_ids.filtered( lambda cline: cline.product_id == line.product_id ) diff --git a/intrastat_product/tests/common_sale.py b/intrastat_product/tests/common_sale.py index 28bc782..4a3a457 100644 --- a/intrastat_product/tests/common_sale.py +++ b/intrastat_product/tests/common_sale.py @@ -11,6 +11,14 @@ class IntrastatSaleCommon(IntrastatProductCommon): - Customer in Netherlands """ + def _get_expected_vals(self, line): + return { + "declaration_type": "dispatches", + "suppl_unit_qty": line.qty_delivered, + "hs_code_id": line.product_id.hs_code_id, + "product_origin_country_id": line.product_id.origin_country_id, + } + def _check_line_values(self, final=False, declaration=None, sale=None): """ This method allows to test computation lines and declaration @@ -21,12 +29,7 @@ class IntrastatSaleCommon(IntrastatProductCommon): if sale is None: sale = self.sale for line in sale.order_line: - expected_vals = { - "declaration_type": "dispatches", - "suppl_unit_qty": line.qty_delivered, - "hs_code_id": line.product_id.hs_code_id, - "product_origin_country_id": line.product_id.origin_country_id, - } + expected_vals = self._get_expected_vals(line) comp_line = declaration.computation_line_ids.filtered( lambda cline: cline.product_id == line.product_id )