Skip to content

Commit

Permalink
[16.0][MIG] fieldservice_isp_account: Migration to 16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
michelerusti committed Nov 13, 2023
1 parent bca52ac commit 93f7cf6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
13 changes: 4 additions & 9 deletions fieldservice_isp_account/models/fsm_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -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:
Expand Down Expand Up @@ -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"),
Expand All @@ -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,
Expand All @@ -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"),
Expand All @@ -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,
Expand All @@ -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

Expand Down
8 changes: 4 additions & 4 deletions fieldservice_isp_account/tests/test_isp_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
)
Expand Down Expand Up @@ -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}
)
Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
4 changes: 3 additions & 1 deletion fieldservice_isp_account/views/fsm_order.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
</group>
<group name="bill_to" position="after">
<group string="Contractor Costs">
<field name="contractor_cost_ids" nolabel="1">
<field name="contractor_cost_ids" nolabel="1" colspan="2">
<tree editable="bottom">
<field name="product_id" />
<field name="quantity" />
Expand All @@ -56,6 +56,7 @@
name="employee_timesheet_ids"
nolabel="1"
context="{'default_project_id': project_id, 'default_task_id': project_task_id}"
colspan="2"
>
<tree editable="bottom" default_order="date">
<field name="date" />
Expand All @@ -66,6 +67,7 @@
required="1"
domain="[('type','=','service')]"
/>
<field name="company_id" invisible="1" />
<field name="account_id" invisible="1" />
<field name="name" />
<field
Expand Down

0 comments on commit 93f7cf6

Please sign in to comment.