-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: init the module, define models and views #4
base: 16.0
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
.. image:: https://img.shields.io/badge/licence-GPL--3-blue.svg | ||
:target: http://www.gnu.org/licenses/gpl-3.0-standalone.html | ||
:alt: License: GPL-3 | ||
|
||
================== | ||
Account Oss Report | ||
================== | ||
|
||
Module summary. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Summary is missing. |
||
|
||
For a detailed documentation have a look at https://www.odoo-wiki.org/account-oss-report.html | ||
|
||
Configuration | ||
~~~~~~~~~~~~~ | ||
|
||
* No additional configurations needed | ||
|
||
Maintainer | ||
~~~~~~~~~~ | ||
|
||
.. image:: https://raw.githubusercontent.com/Mint-System/Wiki/master/assets/mint-system-logo.png | ||
:target: https://www.mint-system.ch | ||
|
||
This module is maintained by Mint System GmbH. | ||
|
||
For support and more information, please visit `our Website <https://www.mint-system.ch>`__. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import models, wizard |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"name": "Account OSS Report", | ||
"summary": """ | ||
Create OSS tax report for CH. | ||
""", | ||
"author": "Mint System GmbH, Odoo Community Association (OCA)", | ||
"website": "https://www.mint-system.ch", | ||
"category": "Accounting", | ||
"version": "16.0.1.0.0", | ||
"license": "AGPL-3", | ||
"depends": ["account", "l10n_eu_oss"], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please do not depend on |
||
"data": [ | ||
"views/account_oss_report.xml", | ||
"wizard/oss_report_recalculate.xml", | ||
"security/ir.model.access.csv", | ||
"views/menu.xml", | ||
], | ||
"installable": True, | ||
"application": False, | ||
"auto_install": False, | ||
"images": ["images/screen.png"], | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import account_oss_report |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
from odoo import api, fields, models | ||
|
||
class AccountOssReport(models.Model): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "OSS" |
||
_name = "account.oss.report" | ||
_description = "OSS Tax Report" | ||
|
||
country_code = fields.Char() | ||
tax_rate = fields.Float() | ||
base_amount = fields.Float() | ||
tax_amount = fields.Float() | ||
net_amount = fields.Float() | ||
# tax_type = fields.Selection() | ||
|
||
@api.model | ||
def _get_account_move_data(self, data=None, start_date=False, end_date=False): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why |
||
""" | ||
Fetch data from account.move.line with the appropriate domain and calculations. | ||
""" | ||
if data is None: | ||
data = [] | ||
|
||
# Fetch the tag for "OSS" to use in the domain | ||
oss_tag = self.env['account.account.tag'].search([('name', '=', 'OSS')], limit=1) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't like this. The tag should be define as an XML ID. |
||
|
||
# Build the domain to filter by date, tax, and tag "OSS" | ||
domain = [ | ||
('move_id.invoice_date', '>=', start_date), | ||
('move_id.invoice_date', '<=', end_date), | ||
('tax_ids', '!=', False), | ||
('tax_tag_ids', 'in', [oss_tag.id]) | ||
] | ||
|
||
# Fetch move lines that match the criteria | ||
move_lines = self.env['account.move.line'].search(domain) | ||
|
||
for line in move_lines: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The data should be grouped by country code! And you have to distinct between tax included and excluded. |
||
move = line.move_id | ||
base_amount = move.amount_untaxed_signed | ||
tax_amount = move.amount_tax_signed | ||
net_amount = move.amount_total_signed | ||
|
||
# Fetch the first tax's country code and tax rate if they exist | ||
if line.tax_ids: | ||
country_code = line.tax_ids[0].country_id.code | ||
tax_rate = line.tax_ids[0].amount | ||
else: | ||
country_code = 'Unknown' | ||
tax_rate = 0.0 | ||
|
||
data.append({ | ||
'country_code': country_code, | ||
'tax_rate': tax_rate, | ||
'base_amount': base_amount, | ||
'tax_amount': tax_amount, | ||
'net_amount': net_amount, | ||
# 'tax_type': None, | ||
}) | ||
|
||
return data | ||
|
||
@api.model | ||
def get_data(self, start_date=False, end_date=False): | ||
""" | ||
Generate OSS report data for the specified date range. | ||
""" | ||
data = [] | ||
|
||
# Fetch move line data | ||
data = self._get_account_move_data(data, start_date, end_date) | ||
|
||
# Clear existing data from the report | ||
self.env.cr.execute("DELETE FROM account_oss_report") | ||
|
||
# Insert new data into the report | ||
self.create(data) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink | ||
access_account_oss_report,access_account_oss_report,model_account_oss_report,base.group_user,1,1,1,1 | ||
access_oss_report_recalculate,access_oss_report_recalculate,model_oss_report_recalculate,base.group_user,1,1,1,1 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<odoo> | ||
<record id="view_account_oss_report_tree" model="ir.ui.view"> | ||
<field name="name">account.oss.report.tree</field> | ||
<field name="model">account.oss.report</field> | ||
<field name="arch" type="xml"> | ||
<tree> | ||
<field name="country_code"/> | ||
<field name="tax_rate"/> | ||
<field name="base_amount"/> | ||
<field name="tax_amount"/> | ||
<field name="net_amount"/> | ||
</tree> | ||
</field> | ||
</record> | ||
|
||
<record id="action_account_oss_report" model="ir.actions.act_window"> | ||
<field name="name">OSS Tax Report</field> | ||
<field name="res_model">account.oss.report</field> | ||
<field name="view_mode">tree</field> | ||
</record> | ||
|
||
<!-- <menuitem id="menu_account_oss_report" --> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please remove comment code. |
||
<!-- name="OSS Tax Report" --> | ||
<!-- parent="account.menu_finance_reports" --> | ||
<!-- action="action_account_oss_report"/> --> | ||
|
||
</odoo> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<odoo> | ||
|
||
<menuitem id="menu_oss_tax_reporting" | ||
name="OSS Tax Reporting" | ||
parent="account.menu_finance_reports" | ||
sequence="100"/> | ||
|
||
<menuitem id="menu_oss_report_recalculate_wizard" | ||
name="Recalculate OSS Report" | ||
parent="menu_oss_tax_reporting" | ||
action="account_oss_report.action_recalculate_oss_report" | ||
sequence="200"/> | ||
|
||
<menuitem id="menu_account_oss_report" | ||
name="OSS Tax Report" | ||
parent="menu_oss_tax_reporting" | ||
action="account_oss_report.action_account_oss_report" | ||
sequence="300"/> | ||
|
||
</odoo> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import oss_report_recalculate |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we can get rid of the wizard. The calculation should be pretty fast, so not wizard might be required. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from odoo import fields, models | ||
|
||
|
||
class OssReportRecalculate(models.TransientModel): | ||
_name = "oss.report.recalculate" | ||
_description = "Recalculate OSS report" | ||
|
||
start_date = fields.Date(required=True) | ||
end_date = fields.Date(required=True) | ||
|
||
def recalculate_oss_report(self): | ||
self.env["account.oss.report"].get_data(self.start_date, self.end_date) | ||
|
||
tree_view_id = self.env.ref( | ||
"account_oss_report.view_account_oss_report_tree" | ||
).id | ||
|
||
return { | ||
"type": "ir.actions.act_window", | ||
"views": [(tree_view_id, "tree")], | ||
"view_mode": "tree", | ||
"name": "OSS Tax Report", | ||
"res_model": "account.oss.report", | ||
"domain": [], | ||
"context": dict( | ||
self.env.context, start_date=self.start_date, end_date=self.end_date | ||
), | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<odoo> | ||
|
||
<record id="view_oss_report_recalculate_wizard" model="ir.ui.view"> | ||
<field name="name">Recalculate OSS Report</field> | ||
<field name="model">oss.report.recalculate</field> | ||
<field name="arch" type="xml"> | ||
<form string="Recalculate OSS Report"> | ||
<group> | ||
<field name="start_date"/> | ||
<field name="end_date"/> | ||
</group> | ||
<group> | ||
<p>The recalculation of the OSS report may take a few minutes depending on the data.</p> | ||
</group> | ||
<footer> | ||
<button name="recalculate_oss_report" string="Recalculate" type="object" class="btn-primary" /> | ||
<button string="Cancel" class="btn-secondary" special="cancel" /> | ||
</footer> | ||
</form> | ||
</field> | ||
</record> | ||
|
||
<record id="action_recalculate_oss_report" model="ir.actions.act_window"> | ||
<field name="name">Recalculate OSS Report</field> | ||
<field name="res_model">oss.report.recalculate</field> | ||
<field name="view_mode">form</field> | ||
<field name="target">new</field> | ||
</record> | ||
|
||
<!-- <menuitem id="menu_oss_report_recalculate_wizard" --> | ||
<!-- name="Recalculate OSS Report" --> | ||
<!-- parent="account.menu_finance_reports" --> | ||
<!-- action="account_oss_report.action_recalculate_oss_report" --> | ||
<!-- sequence="200"/> --> | ||
|
||
</odoo> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is "OSS"