Skip to content
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

[WIP] pms_property_account_budget_oca #239

Closed
Closed
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
79 changes: 79 additions & 0 deletions pms_property_account_budget_oca/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
===========================================
PMS Property Budgets Management Integration
===========================================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fpms-lightgray.png?logo=github
:target: https://github.com/OCA/pms/tree/14.0/pms_property_account_budget_oca
:alt: OCA/pms
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/pms-14-0/pms-14-0-pms_property_account_budget_oca
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/293/14.0
:alt: Try me on Runbot

|badge1| |badge2| |badge3| |badge4| |badge5|

This module allows accountants to manage analytic and crossovered budgets
with pms properties.

**Table of contents**

.. contents::
:local:

Known issues / Roadmap
======================

* This module is incompatible with Odoo Enterprise account_budget module

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/pms/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/pms/issues/new?body=module:%20pms_property_account_budget_oca%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
~~~~~~~

* Odoo S.A.

Contributors
~~~~~~~~~~~~

* Dario Lodeiros <dario@commitsun.com>

Maintainers
~~~~~~~~~~~

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

This module is part of the `OCA/pms <https://github.com/OCA/pms/tree/14.0/pms_property_account_budget_oca>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
3 changes: 3 additions & 0 deletions pms_property_account_budget_oca/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.

from . import models
14 changes: 14 additions & 0 deletions pms_property_account_budget_oca/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.

{
"name": "PMS Property Budgets Management Integration",
"version": "14.0.1.0.0",
"category": "Accounting",
"license": "LGPL-3",
"author": "Odoo S.A., Odoo Community Association (OCA)",
"website": "https://github.com/OCA/pms",
"depends": ["account_budget_oca"],
"data": [
"views/account_budget_views.xml",
],
}
3 changes: 3 additions & 0 deletions pms_property_account_budget_oca/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.

from . import account_budget
63 changes: 63 additions & 0 deletions pms_property_account_budget_oca/models/account_budget.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.

from odoo import fields, models

from_string = fields.Datetime.from_string


# ---------------------------------------------------------
# Budgets
# ---------------------------------------------------------


class CrossoveredBudget(models.Model):
_inherit = "crossovered.budget"
_check_pms_properties_auto = True

pms_property_id = fields.Many2one(
name="Property",
comodel_name="pms.property",
check_pms_properties=True,
)


class CrossoveredBudgetLines(models.Model):
_name = "crossovered.budget.lines"
_description = "Budget Line"

pms_property_id = fields.Many2one(
name="Property",
comodel_name="pms.property",
related="general_budget_id.pms_property_id",
store=True,
)

def _compute_practical_amount(self):
for line in self:
if line.pms_property_id:
result = 0.0
acc_ids = line.general_budget_id.account_ids.ids
date_to = line.date_to
date_from = line.date_from
if line.analytic_account_id.id:
self.env.cr.execute(
"""
SELECT SUM(amount)
FROM account_analytic_line
WHERE account_id=%s
AND (date between %s
AND %s)
AND general_account_id=ANY(%s)
AND pms_property_id=%s""",
(
line.analytic_account_id.id,
date_from,
date_to,
acc_ids,
line.pms_property_id.id,
),
)
result = self.env.cr.fetchone()[0] or 0.0
line.practical_amount = result
else:
super(CrossoveredBudgetLines, self)._compute_practical_amount()
1 change: 1 addition & 0 deletions pms_property_account_budget_oca/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Dario Lodeiros <dario@commitsun.com>
2 changes: 2 additions & 0 deletions pms_property_account_budget_oca/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This module allows accountants to manage analytic and crossovered budgets
with pms properties.
1 change: 1 addition & 0 deletions pms_property_account_budget_oca/readme/ROADMAP.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* This module is incompatible with Odoo Enterprise account_budget module
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading