Skip to content

Commit

Permalink
[REF] Move account_invoice_hour_report, account_invoice_hour_report_n…
Browse files Browse the repository at this point in the history
…on_billable, hr_holidays_resource, sale_timesheet_approval, sale_timesheet_approval_non_billable, sale_timesheet_approval_sheet to onesteinbv/addons-generic

[REM] accountancy_install: Not used anymore
  • Loading branch information
tarteo committed Sep 12, 2024
1 parent 232cefa commit 43fa3f3
Show file tree
Hide file tree
Showing 45 changed files with 1,182 additions and 0 deletions.
7 changes: 7 additions & 0 deletions account_invoice_hour_report/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@


=================================
Hour report addition for invoices
=================================

This module attaches an annex consisting of the related work hours made by employees to the invoiced tasks.
3 changes: 3 additions & 0 deletions account_invoice_hour_report/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from . import models
21 changes: 21 additions & 0 deletions account_invoice_hour_report/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright 2024 Onestein (<http://www.onestein.eu>)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
"name": "Invoice hour report addition",
"version": "16.0.1.0.0",
"author": "Onestein",
"category": "Accounting & Finance",
"website": "https://www.onestein.nl",
"license": "AGPL-3",
"depends": [
"sale_timesheet_approval",
"sale_timesheet_custom_fields",
],
"data": [
"templates/hour_report_template.xml",
"views/hours_report.xml",
"views/res_partner.xml",
],
"installable": True,
}
93 changes: 93 additions & 0 deletions account_invoice_hour_report/i18n/nl.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * account_invoice_hour_report
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-03-26 12:47+0000\n"
"PO-Revision-Date: 2024-03-26 12:47+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: account_invoice_hour_report
#: model_terms:ir.ui.view,arch_db:account_invoice_hour_report.invoice_hours_report_document
msgid "<b>Invoice Annex</b>"
msgstr "<b>Factuurbijlage</b>"

#. module: account_invoice_hour_report
#: model_terms:ir.ui.view,arch_db:account_invoice_hour_report.invoice_hours_report_document
msgid "<span><b>Customer Name</b></span>:"
msgstr "<span><b>Klantnaam</b></span>:"

#. module: account_invoice_hour_report
#: model_terms:ir.ui.view,arch_db:account_invoice_hour_report.invoice_hours_report_document
msgid "<span><b>Sale Order</b></span>:"
msgstr "<span><b>Verkooporder</b></span>:
"

#. module: account_invoice_hour_report
#: model_terms:ir.ui.view,arch_db:account_invoice_hour_report.invoice_hours_report_document
msgid "<span><b>Total:</b></span>"
msgstr "<span><b>Totaal:</b></span>"

#. module: account_invoice_hour_report
#: model_terms:ir.ui.view,arch_db:account_invoice_hour_report.invoice_hours_report_document
msgid "<span>Date</span>"
msgstr "<span>Datum</span>"

#. module: account_invoice_hour_report
#: model_terms:ir.ui.view,arch_db:account_invoice_hour_report.invoice_hours_report_document
msgid "<span>Description</span>"
msgstr "<span>Beschrijving</span>"

#. module: account_invoice_hour_report
#: model_terms:ir.ui.view,arch_db:account_invoice_hour_report.invoice_hours_report_document
msgid "<span>Employee</span>"
msgstr ""

#. module: account_invoice_hour_report
#: model_terms:ir.ui.view,arch_db:account_invoice_hour_report.invoice_hours_report_document
msgid "<span>Project</span>:"
msgstr "<span>Werknemer</span>"

#. module: account_invoice_hour_report
#: model_terms:ir.ui.view,arch_db:account_invoice_hour_report.invoice_hours_report_document
msgid "<span>Time to be Invoiced (Hours)</span>"
msgstr "<span>Tijd om te factureren (uren)</span>"

#. module: account_invoice_hour_report
#: model_terms:ir.ui.view,arch_db:account_invoice_hour_report.invoice_hours_report_document
msgid "<span>Total Hours</span>"
msgstr "<span>Totaal aantal uren</span>"

#. module: account_invoice_hour_report
#: model_terms:ir.ui.view,arch_db:account_invoice_hour_report.invoice_hours_report_document
msgid "<span>Week nr.</span>"
msgstr "<span>Weeknr.</span>"

#. module: account_invoice_hour_report
#: model:ir.model,name:account_invoice_hour_report.model_res_partner
msgid "Contact"
msgstr ""

#. module: account_invoice_hour_report
#: model:ir.model.fields,field_description:account_invoice_hour_report.field_res_partner__print_timesheet_employee
#: model:ir.model.fields,field_description:account_invoice_hour_report.field_res_users__print_timesheet_employee
msgid "Print Employee on Timesheet Report"
msgstr "Werknemer afdrukken op urenstaatrapport"

#. module: account_invoice_hour_report
#: model:ir.model,name:account_invoice_hour_report.model_sale_order
msgid "Sales Order"
msgstr "Verkooporder"

#. module: account_invoice_hour_report
#: model:ir.actions.report,name:account_invoice_hour_report.report_invoice_hours_report
msgid "Timesheets"
msgstr "Uren rapport"
4 changes: 4 additions & 0 deletions account_invoice_hour_report/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from . import sale
from . import res_partner
10 changes: 10 additions & 0 deletions account_invoice_hour_report/models/res_partner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Copyright 2024 Onestein (<http://www.onestein.eu>)


from odoo import fields, models


class ResPartner(models.Model):
_inherit = "res.partner"

print_timesheet_employee = fields.Boolean("Print Employee on Timesheet Report")
35 changes: 35 additions & 0 deletions account_invoice_hour_report/models/sale.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Copyright 2024 Onestein (<http://www.onestein.eu>)

import base64

from odoo import models


class SaleOrder(models.Model):
_inherit = "sale.order"

def _create_invoices(self, grouped=False, final=False, date=None):
res = super()._create_invoices(grouped=grouped, final=final, date=date)
report_obj = self.env["ir.actions.report"]
for move in res:
ctx = {
"tz": self.env.user.tz,
"uid": self.env.uid,
"lang": move.partner_id.lang,
}
timesheet_lines = move.timesheet_ids
if timesheet_lines:
pdf, _ = report_obj.with_context(ctx)._render_qweb_pdf(
"account_invoice_hour_report.report_invoice_hours_report",
res_ids=timesheet_lines.ids,
)
self.env["ir.attachment"].create(
{
"name": "timesheet_detail.pdf",
"res_id": move.id,
"res_model": str(move._name),
"datas": base64.b64encode(pdf),
"mimetype": "application/pdf",
}
)
return res
119 changes: 119 additions & 0 deletions account_invoice_hour_report/templates/hour_report_template.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>

<template id="invoice_hours_report_document">
<t t-call="web.html_container">
<t t-call="web.external_layout">
<t t-set="show_project" t-value="len(docs.mapped('project_id')) == 1"/>
<t t-set="show_customer" t-value="len(docs.mapped('partner_id')) == 1"/>
<t t-set="show_sale_order" t-value="len(docs.mapped('order_id')) == 1"/>
<div class="page">

<style type="text/css">
td {
border: 1px solid black;
}
</style>

<b>Invoice Annex</b>
<t t-if="show_customer">
<div>
<span><b>Customer Name</b></span>:
<span t-field="docs[0].partner_id.name" />
</div>
</t>
<t t-if="show_sale_order">
<div>
<span><b>Sale Order</b></span>:
<span t-field="docs[0].order_id.name" />
</div>
<div>
<span t-field="docs[0].order_id.client_order_ref" />
</div>
</t>
<t t-if="show_project">
<div>
<span>Project</span>:
<span t-field="docs[0].project_id.name" />
</div>
</t>
<br />
<t t-set="print_employee" t-value="show_customer and docs[0].partner_id.print_timesheet_employee"/>
<table class="table table-condensed">
<thead
style="border-top: 1px solid black; font-weight: bold;">
<tr>
<td style="text-align: center;">
<span>Week nr.</span>
</td>
<td style="width: 15%; text-align: center;">
<span>Date</span>
</td>
<t t-if="print_employee">
<td style="text-align: left;">
<span>Employee</span>
</td>
</t>
<td style="width: 55%; text-align: left;">
<span>Description</span>
</td>
<td style="width: 12%; text-align: center;">
<span>Total Hours</span>
</td>
<td style="width: 12%; text-align: center;">
<span>Time to be Invoiced (Hours)</span>
</td>
</tr>
</thead>
<t t-set="total" t-value="0"/>
<t t-set="total_to_be_invoiced" t-value="0"/>
<t t-foreach="docs" t-as="time_line">
<t t-set="total" t-value="total + time_line.unit_amount"/>
<t t-set="total_to_be_invoiced" t-value="total_to_be_invoiced + (time_line.unit_amount if time_line.is_approved else 0.0)"/>
<tr>
<td style="text-align: center">
<span
t-esc="time_line.date.isocalendar()[1]" />
</td>
<td style="min-width: 70px; text-align: center;">
<span t-field="time_line.date" />
</td>
<t t-if="print_employee">
<td style="text-align: left;">
<span t-field="time_line.user_id.name" />
</td>
</t>
<td style="height: 2.5em;">
<span t-field="time_line.name" />
</td>
<td style="text-align: right;">
<span t-esc="'{:.2f}'.format(time_line.unit_amount).replace('.', ',')" />
</td>
<td style="text-align: right;">
<span class="hours_to_be_invoiced" t-esc="'{:.2f}'.format(time_line.unit_amount if time_line.is_approved else 0.0).replace('.', ',')"/>
</td>
</tr>
</t>
<tr>
<t t-if="print_employee">
<td colspan="4" style="border: none;"/>
</t>
<t t-if="not print_employee">
<td colspan="3" style="border: none;"/>
</t>
<td style="text-align: right;">
<span><b>Total:</b></span>
<span t-esc="'{:.2f}'.format(total).replace('.', ',')"/>
</td>
<td style="text-align: right;">
<span><b>Total:</b></span>
<span t-esc="'{:.2f}'.format(total_to_be_invoiced).replace('.', ',')"/>
</td>
</tr>
</table>
</div>
</t>
</t>
</template>

</odoo>
12 changes: 12 additions & 0 deletions account_invoice_hour_report/views/hours_report.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0"?>
<odoo>
<record id="report_invoice_hours_report" model="ir.actions.report">
<field name="name">Hours To Be Invoiced Report</field>
<field name="model">account.analytic.line</field>
<field name="report_type">qweb-pdf</field>
<field name="report_name">account_invoice_hour_report.invoice_hours_report_document</field>
<field name="report_file">account_invoice_hour_report.invoice_hours_report_document</field>
<field name="binding_model_id" ref="analytic.model_account_analytic_line"/>
<field name="binding_type">report</field>
</record>
</odoo>
14 changes: 14 additions & 0 deletions account_invoice_hour_report/views/res_partner.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>

<record id="view_partner_form" model="ir.ui.view">
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='industry_id']" position='after'>
<field name="print_timesheet_employee"/>
</xpath>
</field>
</record>

</odoo>
7 changes: 7 additions & 0 deletions account_invoice_hour_report_non_billable/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@


==============================================================
Hour report addition With Non Billable Timesheets for invoices
==============================================================

This module is the bridge between account_invoice_hour_report and sale_timesheet_line_non_billable module.
Empty file.
17 changes: 17 additions & 0 deletions account_invoice_hour_report_non_billable/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright 2024 Onestein (<http://www.onestein.eu>)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
"name": "Invoice Hour Report With Non Billable Timesheets",
"version": "16.0.1.0.0",
"author": "Onestein",
"license": "AGPL-3",
"category": "Accounting & Finance",
"website": "https://www.onestein.nl",
"depends": ["account_invoice_hour_report", "sale_timesheet_line_non_billable"],
"data": [
"templates/hour_report_template.xml",
],
"installable": True,
"auto_install": True,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>

<template id="invoice_hours_report_document" inherit_id="account_invoice_hour_report.invoice_hours_report_document">
<xpath expr="//t[@t-foreach]/t[@t-set='total_to_be_invoiced']" position="replace">
<t t-set="total_to_be_invoiced" t-value="total_to_be_invoiced + (time_line.unit_amount if time_line.is_approved and not time_line.is_non_billable else 0.0)"/>
</xpath>
<xpath expr="//span[hasclass('hours_to_be_invoiced')]" position="attributes">
<attribute name="t-esc">'{:.2f}'.format(time_line.unit_amount if time_line.is_approved and not time_line.is_non_billable else 0.0).replace('.', ',')</attribute>
</xpath>
</template>

</odoo>
1 change: 1 addition & 0 deletions hr_holidays_resource/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
16 changes: 16 additions & 0 deletions hr_holidays_resource/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2024 Onestein (<http://www.onestein.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

{
"name": "Time Off Resource",
"version": "16.0.1.0.0",
"license": "AGPL-3",
"category": "Productivity/Calendar",
"author": "Onestein",
"website": "https://www.onestein.nl",
"depends": ["hr_holidays"],
"data": [
"data/hr_holidays_data.xml",
"data/ir_cron_data.xml",
],
}
Loading

0 comments on commit 43fa3f3

Please sign in to comment.