diff --git a/pms_property_account_budget_oca/README.rst b/pms_property_account_budget_oca/README.rst new file mode 100644 index 0000000000..4d2c547aed --- /dev/null +++ b/pms_property_account_budget_oca/README.rst @@ -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 `_. +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 `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Odoo S.A. + +Contributors +~~~~~~~~~~~~ + +* Dario Lodeiros + +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 `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/pms_property_account_budget_oca/__init__.py b/pms_property_account_budget_oca/__init__.py new file mode 100644 index 0000000000..d6210b1285 --- /dev/null +++ b/pms_property_account_budget_oca/__init__.py @@ -0,0 +1,3 @@ +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from . import models diff --git a/pms_property_account_budget_oca/__manifest__.py b/pms_property_account_budget_oca/__manifest__.py new file mode 100644 index 0000000000..83a5ca3bf8 --- /dev/null +++ b/pms_property_account_budget_oca/__manifest__.py @@ -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", + ], +} diff --git a/pms_property_account_budget_oca/models/__init__.py b/pms_property_account_budget_oca/models/__init__.py new file mode 100644 index 0000000000..26194116bf --- /dev/null +++ b/pms_property_account_budget_oca/models/__init__.py @@ -0,0 +1,3 @@ +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from . import account_budget diff --git a/pms_property_account_budget_oca/models/account_budget.py b/pms_property_account_budget_oca/models/account_budget.py new file mode 100644 index 0000000000..ce4ef9d994 --- /dev/null +++ b/pms_property_account_budget_oca/models/account_budget.py @@ -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() diff --git a/pms_property_account_budget_oca/readme/CONTRIBUTORS.rst b/pms_property_account_budget_oca/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000000..1594b6b558 --- /dev/null +++ b/pms_property_account_budget_oca/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Dario Lodeiros diff --git a/pms_property_account_budget_oca/readme/DESCRIPTION.rst b/pms_property_account_budget_oca/readme/DESCRIPTION.rst new file mode 100644 index 0000000000..ca142a09db --- /dev/null +++ b/pms_property_account_budget_oca/readme/DESCRIPTION.rst @@ -0,0 +1,2 @@ +This module allows accountants to manage analytic and crossovered budgets +with pms properties. diff --git a/pms_property_account_budget_oca/readme/ROADMAP.rst b/pms_property_account_budget_oca/readme/ROADMAP.rst new file mode 100644 index 0000000000..71553382ba --- /dev/null +++ b/pms_property_account_budget_oca/readme/ROADMAP.rst @@ -0,0 +1 @@ +* This module is incompatible with Odoo Enterprise account_budget module diff --git a/pms_property_account_budget_oca/static/description/icon.png b/pms_property_account_budget_oca/static/description/icon.png new file mode 100644 index 0000000000..3a0328b516 Binary files /dev/null and b/pms_property_account_budget_oca/static/description/icon.png differ diff --git a/pms_property_account_budget_oca/static/description/index.html b/pms_property_account_budget_oca/static/description/index.html new file mode 100644 index 0000000000..f0ca761e02 --- /dev/null +++ b/pms_property_account_budget_oca/static/description/index.html @@ -0,0 +1,427 @@ + + + + + + +PMS Property Budgets Management Integration + + + +
+

PMS Property Budgets Management Integration

+ + +

Beta License: LGPL-3 OCA/pms Translate me on Weblate Try me on Runbot

+

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

+

Table of contents

+ +
+

Known issues / Roadmap

+
    +
  • This module is incompatible with Odoo Enterprise account_budget module
  • +
+
+
+

Bug Tracker

+

Bugs are tracked on GitHub 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.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • Odoo S.A.
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

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 project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/pms_property_account_budget_oca/views/account_budget_views.xml b/pms_property_account_budget_oca/views/account_budget_views.xml new file mode 100644 index 0000000000..e3e2924029 --- /dev/null +++ b/pms_property_account_budget_oca/views/account_budget_views.xml @@ -0,0 +1,25 @@ + + + + pms.property.crossovered.budget.view.form + crossovered.budget + + + + + + + + + pms.property.crossovered.budget.view.tree + crossovered.budget + + + + + + + + diff --git a/setup/pms_property_account_budget_oca/odoo/addons/pms_property_account_budget_oca b/setup/pms_property_account_budget_oca/odoo/addons/pms_property_account_budget_oca new file mode 120000 index 0000000000..9a12f5193c --- /dev/null +++ b/setup/pms_property_account_budget_oca/odoo/addons/pms_property_account_budget_oca @@ -0,0 +1 @@ +../../../../pms_property_account_budget_oca \ No newline at end of file diff --git a/setup/pms_property_account_budget_oca/setup.py b/setup/pms_property_account_budget_oca/setup.py new file mode 100644 index 0000000000..28c57bb640 --- /dev/null +++ b/setup/pms_property_account_budget_oca/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)