Skip to content

Commit

Permalink
[IMP] fieldservice_isp_account: black, isort, prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
baimont committed Apr 30, 2021
1 parent 5bb3a71 commit 960ed0b
Show file tree
Hide file tree
Showing 12 changed files with 425 additions and 354 deletions.
44 changes: 20 additions & 24 deletions fieldservice_isp_account/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,27 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
'name': 'Field Service - ISP Accounting',
'summary': """Invoice Field Service orders based on employee time
"name": "Field Service - ISP Accounting",
"summary": """Invoice Field Service orders based on employee time
or contractor costs""",
'version': '12.0.2.3.2',
'category': 'Field Service',
'author': 'Open Source Integrators, Odoo Community Association (OCA)',
'website': 'https://github.com/OCA/field-service',
'depends': [
'fieldservice_account_analytic',
'fieldservice_project',
'hr_timesheet',
"version": "12.0.2.3.2",
"category": "Field Service",
"author": "Open Source Integrators, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/field-service",
"depends": [
"fieldservice_account_analytic",
"fieldservice_project",
"hr_timesheet",
],
'data': [
'security/ir.model.access.csv',
'data/time_products.xml',
'views/account.xml',
'views/fsm_order.xml',
'views/fsm_person.xml',
'views/hr_timesheet.xml',
],
'license': 'AGPL-3',
'development_status': 'Beta',
'maintainers': [
'osimallen',
'brian10048',
'bodedra',
"data": [
"security/ir.model.access.csv",
"data/time_products.xml",
"views/account.xml",
"views/fsm_order.xml",
"views/fsm_person.xml",
"views/hr_timesheet.xml",
],
"license": "AGPL-3",
"development_status": "Beta",
"maintainers": ["osimallen", "brian10048", "bodedra"],
}
24 changes: 10 additions & 14 deletions fieldservice_isp_account/data/time_products.xml
Original file line number Diff line number Diff line change
@@ -1,36 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8" ?>
<odoo noupdate="1">

<record id="field_service_travel_time" model="product.template">
<field name="name">FSM Travel Time</field>
<field name="categ_id" ref="product.product_category_all"/>
<field name="categ_id" ref="product.product_category_all" />
<field name="type">service</field>
<field name="uom_id" ref="uom.product_uom_hour"/>
<field name="uom_po_id" ref="uom.product_uom_hour"/>
<field name="uom_id" ref="uom.product_uom_hour" />
<field name="uom_po_id" ref="uom.product_uom_hour" />
<field name="description_sale">Travel time for Field Service
Employees
</field>
</record>

<record id="field_service_regular_time" model="product.template">
<field name="name">FSM Regular Time</field>
<field name="categ_id" ref="product.product_category_all"/>
<field name="categ_id" ref="product.product_category_all" />
<field name="type">service</field>
<field name="uom_id" ref="uom.product_uom_hour"/>
<field name="uom_po_id" ref="uom.product_uom_hour"/>
<field name="uom_id" ref="uom.product_uom_hour" />
<field name="uom_po_id" ref="uom.product_uom_hour" />
<field name="description_sale">Regular time for Field Service
Employees
</field>
</record>

<record id="field_service_overtime" model="product.template">
<field name="name">FSM Overtime</field>
<field name="categ_id" ref="product.product_category_all"/>
<field name="categ_id" ref="product.product_category_all" />
<field name="type">service</field>
<field name="uom_id" ref="uom.product_uom_hour"/>
<field name="uom_po_id" ref="uom.product_uom_hour"/>
<field name="uom_id" ref="uom.product_uom_hour" />
<field name="uom_po_id" ref="uom.product_uom_hour" />
<field name="description_sale">Overtime for Field Service Employees
</field>
</record>

</odoo>
35 changes: 20 additions & 15 deletions fieldservice_isp_account/models/account_invoice_line.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,39 @@
# Copyright (C) 2018 - TODAY, Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import api, models, _
from odoo import _, api, models
from odoo.exceptions import ValidationError


class AccountInvoiceLine(models.Model):
_inherit = "account.invoice.line"

@api.onchange('product_id', 'quantity')
@api.onchange("product_id", "quantity")
def onchange_product_id(self):
for line in self:
if line.fsm_order_id:
partner = line.fsm_order_id.person_id and\
line.fsm_order_id.person_id.partner_id or False
partner = (
line.fsm_order_id.person_id
and line.fsm_order_id.person_id.partner_id
or False
)
if not partner:
raise ValidationError(
_("Please set the field service worker."))
raise ValidationError(_("Please set the field service worker."))
fpos = partner.property_account_position_id
tmpl = line.product_id.product_tmpl_id
if line.product_id:
accounts = tmpl.get_product_accounts()
supinfo = self.env['product.supplierinfo'].search(
[('name', '=', partner.id),
('product_tmpl_id', '=', tmpl.id),
('min_qty', '<=', line.quantity)],
order='min_qty DESC')
line.price_unit = \
supinfo = self.env["product.supplierinfo"].search(
[
("name", "=", partner.id),
("product_tmpl_id", "=", tmpl.id),
("min_qty", "<=", line.quantity),
],
order="min_qty DESC",
)
line.price_unit = (
supinfo and supinfo[0].price or tmpl.standard_price
line.account_id = accounts.get('expense', False)
line.invoice_line_tax_ids = fpos.\
map_tax(tmpl.supplier_taxes_id)
)
line.account_id = accounts.get("expense", False)
line.invoice_line_tax_ids = fpos.map_tax(tmpl.supplier_taxes_id)
line.name = line.product_id.name
Loading

0 comments on commit 960ed0b

Please sign in to comment.