From 93f7cf667adf07dee78059f13f1e573eacb17288 Mon Sep 17 00:00:00 2001 From: michelerusti Date: Wed, 1 Nov 2023 17:05:38 +0100 Subject: [PATCH] [16.0][MIG] fieldservice_isp_account: Migration to 16.0 --- fieldservice_isp_account/models/fsm_order.py | 13 ++++--------- fieldservice_isp_account/tests/test_isp_account.py | 8 ++++---- fieldservice_isp_account/views/fsm_order.xml | 4 +++- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/fieldservice_isp_account/models/fsm_order.py b/fieldservice_isp_account/models/fsm_order.py index f800bc7760..378113de57 100644 --- a/fieldservice_isp_account/models/fsm_order.py +++ b/fieldservice_isp_account/models/fsm_order.py @@ -45,7 +45,7 @@ def _compute_total_cost(self): order.total_cost = 0.0 rate = 0 for line in order.employee_timesheet_ids: - rate = line.employee_id.timesheet_cost + rate = line.employee_id.hourly_cost order.total_cost += line.unit_amount * rate for cost in order.contractor_cost_ids: order.total_cost += cost.price_unit * cost.quantity @@ -103,7 +103,6 @@ def prepare_bills(self): 0, 0, { - "analytic_account_id": self.location_id.analytic_account_id.id, "product_id": cost.product_id.id, "quantity": cost.quantity, "name": cost.product_id.display_name, @@ -127,8 +126,7 @@ def prepare_bills(self): def create_bills(self): vals = self.prepare_bills() - bill = self.env["account.move"].sudo().create(vals) - bill._recompute_tax_lines() + self.env["account.move"].sudo().create(vals) def account_confirm(self): for order in self: @@ -175,7 +173,7 @@ def account_prepare_invoice(self): price_list = self.location_id.customer_id.property_product_pricelist invoice_line_vals = [] for cost in self.contractor_cost_ids: - price = price_list.get_product_price( + price = price_list._get_product_price( product=cost.product_id, quantity=cost.quantity, partner=invoice_vals.get("partner_id"), @@ -193,7 +191,6 @@ def account_prepare_invoice(self): 0, { "product_id": cost.product_id.id, - "analytic_account_id": self.location_id.analytic_account_id.id, "quantity": cost.quantity, "name": cost.product_id.display_name, "price_unit": price, @@ -204,7 +201,7 @@ def account_prepare_invoice(self): ) ) for line in self.employee_timesheet_ids: - price = price_list.get_product_price( + price = price_list._get_product_price( product=line.product_id, quantity=line.unit_amount, partner=invoice_vals.get("partner_id"), @@ -221,7 +218,6 @@ def account_prepare_invoice(self): 0, { "product_id": line.product_id.id, - "analytic_account_id": line.account_id.id, "quantity": line.unit_amount, "name": line.name, "price_unit": price, @@ -238,7 +234,6 @@ def account_create_invoice(self): invoice_vals = self.account_prepare_invoice() invoice = self.env["account.move"].sudo().create(invoice_vals) - invoice._recompute_tax_lines() self.account_stage = "invoiced" return invoice diff --git a/fieldservice_isp_account/tests/test_isp_account.py b/fieldservice_isp_account/tests/test_isp_account.py index 328b27aad7..dd1f6981c7 100644 --- a/fieldservice_isp_account/tests/test_isp_account.py +++ b/fieldservice_isp_account/tests/test_isp_account.py @@ -20,7 +20,7 @@ def setUpClass(cls): { "code": "NC1110", "name": "Test Payable Account", - "user_type_id": cls.env.ref("account.data_account_type_payable").id, + "account_type": "liability_payable", "reconcile": True, } ) @@ -134,7 +134,7 @@ def test_fsm_order_exception(self): # Setup required data self.test_location.analytic_account_id = self.test_analytic # Create a new work order with contract = 500 and timesheet = 300 - self.env.ref("hr.employee_qdp").timesheet_cost = 20.0 + self.env.ref("hr.employee_qdp").hourly_cost = 20.0 order = self.env["fsm.order"].create( {"location_id": self.test_location.id, "person_id": self.test_person.id} ) @@ -160,7 +160,7 @@ def test_fsm_order_bill_to_location(self): "price_unit": 200, }, ] - self.env.ref("hr.employee_qdp").timesheet_cost = 100 + self.env.ref("hr.employee_qdp").hourly_cost = 100 timesheets = [ { "name": "timesheet_line_1", @@ -209,7 +209,7 @@ def test_fsm_order_bill_to_contact(self): "price_unit": 300, }, ] - self.env.ref("hr.employee_qdp").timesheet_cost = 20.0 + self.env.ref("hr.employee_qdp").hourly_cost = 20.0 timesheets = [ { "name": "timesheet_line_3", diff --git a/fieldservice_isp_account/views/fsm_order.xml b/fieldservice_isp_account/views/fsm_order.xml index 8c0a29903b..a3670f14b1 100644 --- a/fieldservice_isp_account/views/fsm_order.xml +++ b/fieldservice_isp_account/views/fsm_order.xml @@ -40,7 +40,7 @@ - + @@ -56,6 +56,7 @@ name="employee_timesheet_ids" nolabel="1" context="{'default_project_id': project_id, 'default_task_id': project_task_id}" + colspan="2" > @@ -66,6 +67,7 @@ required="1" domain="[('type','=','service')]" /> +