Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions invoice_recognition_sync/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
19 changes: 19 additions & 0 deletions invoice_recognition_sync/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "Project Revenue Sync",
"version": "1.0",
"category": "Accounting",
"depends": [
"project",
"sale_project",
"sale",
"account",
],
"data": [
"views/project_project_views.xml",
],
'author': 'vivah',
'license': 'AGPL-3',
'sequence': 2,
"installable": True,
"application": False,
}
1 change: 1 addition & 0 deletions invoice_recognition_sync/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import project_project
49 changes: 49 additions & 0 deletions invoice_recognition_sync/models/project_project.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
from odoo import api, fields, models


class ProjectProject(models.Model):
_inherit = "project.project"

needs_recognition_sync = fields.Boolean(
compute="_compute_recognition_sync"
)

recognition_sync_message = fields.Char(
compute="_compute_recognition_sync"
)

def _get_recognition_moves(self):
self.ensure_one()

sale_order = self.sale_order_id

if not sale_order:
return self.env["account.move"]

invoices = sale_order.invoice_ids

return invoices.mapped("adjusting_entries_move_ids")

@api.depends("date_start")
def _compute_recognition_sync(self):
for project in self:
project.needs_recognition_sync = False
project.recognition_sync_message = False

if not project.date_start:
continue

recognition_moves = project._get_recognition_moves()

if not recognition_moves:
continue

recognition_dates = recognition_moves.mapped("date")

if project.date_start not in recognition_dates:
project.needs_recognition_sync = True

project.recognition_sync_message = (
"Revenue recognition entries are not aligned "
"with the project start date."
)
15 changes: 15 additions & 0 deletions invoice_recognition_sync/views/project_project_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="view_project_form_recognition_sync" model="ir.ui.view">
<field name="name">project.project.form.recognition.sync</field>
<field name="model">project.project</field>
<field name="inherit_id" ref="project.edit_project"/>
<field name="arch" type="xml">
<xpath expr="//sheet" position="before">
<div class="alert alert-warning" invisible="not needs_recognition_sync">
<field name="recognition_sync_message" readonly="1"/>
</div>
</xpath>
</field>
</record>
</odoo>