diff --git a/account_spread_cost_revenue_enhanced/README.rst b/account_spread_cost_revenue_enhanced/README.rst new file mode 100644 index 000000000..f96bbc57b --- /dev/null +++ b/account_spread_cost_revenue_enhanced/README.rst @@ -0,0 +1,87 @@ +================================== +Cost-Revenue Spread Extra Features +================================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! 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-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Faccount--financial--tools-lightgray.png?logo=github + :target: https://github.com/OCA/account-financial-tools/tree/14.0/account_spread_cost_revenue_enhanced + :alt: OCA/account-financial-tools +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/account-financial-tools-14-0/account-financial-tools-14-0-account_spread_cost_revenue_enhanced + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/92/14.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module aim to address more business cases by adding extra technical function. + +1. Add action to direct link with journal item (account.move.line) from spread cost/revenue sheet. + This is useful when user want to link spread cost/revenue sheet with journal entry (not with invoice) +2. From spread cost/revenue sheet, allow Create Entry as Invoice (not just entry) + +Note: extra feature in this module is not included in account_spread_cost_revenue to avoid complexity. + +**Table of contents** + +.. contents:: + :local: + +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 +~~~~~~~ + +* Ecosoft + +Contributors +~~~~~~~~~~~~ + +* Kitti U. + +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. + +.. |maintainer-kittiu| image:: https://github.com/kittiu.png?size=40px + :target: https://github.com/kittiu + :alt: kittiu + +Current `maintainer `__: + +|maintainer-kittiu| + +This module is part of the `OCA/account-financial-tools `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/account_spread_cost_revenue_enhanced/__init__.py b/account_spread_cost_revenue_enhanced/__init__.py new file mode 100644 index 000000000..adc6207fd --- /dev/null +++ b/account_spread_cost_revenue_enhanced/__init__.py @@ -0,0 +1,4 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import models +from . import wizards diff --git a/account_spread_cost_revenue_enhanced/__manifest__.py b/account_spread_cost_revenue_enhanced/__manifest__.py new file mode 100644 index 000000000..7f477197a --- /dev/null +++ b/account_spread_cost_revenue_enhanced/__manifest__.py @@ -0,0 +1,21 @@ +# Copyright 2021 Ecosoft Co., Ltd (http://ecosoft.co.th/) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html) + +{ + "name": "Cost-Revenue Spread Extra Features", + "summary": "Extra feature for account spread cost/revenue", + "version": "14.0.1.0.0", + "development_status": "Beta", + "author": "Ecosoft,Odoo Community Association (OCA)", + "maintainers": ["kittiu"], + "license": "AGPL-3", + "website": "https://github.com/OCA/account-financial-tools", + "category": "Accounting & Finance", + "depends": ["account_spread_cost_revenue"], + "data": [ + "security/ir.model.access.csv", + "wizards/account_spread_link_move_line.xml", + "views/account_spread.xml", + ], + "installable": True, +} diff --git a/account_spread_cost_revenue_enhanced/models/__init__.py b/account_spread_cost_revenue_enhanced/models/__init__.py new file mode 100644 index 000000000..b3f041eef --- /dev/null +++ b/account_spread_cost_revenue_enhanced/models/__init__.py @@ -0,0 +1,4 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import account_spread +from . import account_spread_line diff --git a/account_spread_cost_revenue_enhanced/models/account_spread.py b/account_spread_cost_revenue_enhanced/models/account_spread.py new file mode 100644 index 000000000..8445168d8 --- /dev/null +++ b/account_spread_cost_revenue_enhanced/models/account_spread.py @@ -0,0 +1,41 @@ +# Copyright 2021 Ecosoft Co., Ltd (http://ecosoft.co.th/) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html) + +from odoo import _, api, fields, models +from odoo.exceptions import UserError + + +class AccountSpread(models.Model): + _inherit = "account.spread" + + create_move_type = fields.Selection( + selection=[ + ("entry", "Journal Entry"), + ("out_invoice", "Customer Invoice"), + ("in_invoice", "Vendor Bill"), + ("out_refund", "Customer Credit Note"), + ("in_refund", "Vendor Credit Note"), + ], + string="Create Entry As", + default="entry", + required=True, + ) + + @api.constrains("invoice_id", "invoice_type") + def _check_invoice_type(self): + """When linked with journal entry, no check""" + spread = self.filtered(lambda l: not l.invoice_id.move_type == "entry") + super(AccountSpread, spread)._check_invoice_type() + + @api.constrains("create_move_type", "debit_account_id", "credit_account_id") + def _check_entry_type(self): + if self.filtered( + lambda l: l.create_move_type != "entry" + and l.debit_account_id != l.credit_account_id + ): + raise UserError( + _( + "When choose to create move type other than journal " + "entry, debit/credit account must be same" + ) + ) diff --git a/account_spread_cost_revenue_enhanced/models/account_spread_line.py b/account_spread_cost_revenue_enhanced/models/account_spread_line.py new file mode 100644 index 000000000..a0dd79b12 --- /dev/null +++ b/account_spread_cost_revenue_enhanced/models/account_spread_line.py @@ -0,0 +1,20 @@ +# Copyright 2021 Ecosoft Co., Ltd (http://ecosoft.co.th/) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html) + +from odoo import models + + +class AccountInvoiceSpreadLine(models.Model): + _inherit = "account.spread.line" + + def _prepare_move(self): + """Create with move_type, i.e., in_invoice instead of normal entry""" + res = super()._prepare_move() + if self.spread_id.create_move_type != "entry": + invoice_line = res.pop("line_ids")[0][2] + res["name"] = False + res["move_type"] = self.spread_id.create_move_type + res["partner_id"] = self.spread_id.invoice_line_id.partner_id.id + invoice_line["price_unit"] = abs(self.amount) + res["invoice_line_ids"] = [(0, 0, invoice_line)] + return res diff --git a/account_spread_cost_revenue_enhanced/readme/CONTRIBUTORS.rst b/account_spread_cost_revenue_enhanced/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..6ce956d96 --- /dev/null +++ b/account_spread_cost_revenue_enhanced/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Kitti U. diff --git a/account_spread_cost_revenue_enhanced/readme/DESCRIPTION.rst b/account_spread_cost_revenue_enhanced/readme/DESCRIPTION.rst new file mode 100644 index 000000000..e654c6f7d --- /dev/null +++ b/account_spread_cost_revenue_enhanced/readme/DESCRIPTION.rst @@ -0,0 +1,7 @@ +This module aim to address more business cases by adding extra technical function. + +1. Add action to direct link with journal item (account.move.line) from spread cost/revenue sheet. + This is useful when user want to link spread cost/revenue sheet with journal entry (not with invoice) +2. From spread cost/revenue sheet, allow Create Entry as Invoice (not just entry) + +Note: extra feature in this module is not included in account_spread_cost_revenue to avoid complexity. diff --git a/account_spread_cost_revenue_enhanced/security/ir.model.access.csv b/account_spread_cost_revenue_enhanced/security/ir.model.access.csv new file mode 100644 index 000000000..1b27c4873 --- /dev/null +++ b/account_spread_cost_revenue_enhanced/security/ir.model.access.csv @@ -0,0 +1,2 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_account_spread_link_move_line,access_account_spread_link_move_line,model_account_spread_link_move_line,base.group_user,1,1,1,1 diff --git a/account_spread_cost_revenue_enhanced/static/description/icon.png b/account_spread_cost_revenue_enhanced/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/account_spread_cost_revenue_enhanced/static/description/icon.png differ diff --git a/account_spread_cost_revenue_enhanced/static/description/index.html b/account_spread_cost_revenue_enhanced/static/description/index.html new file mode 100644 index 000000000..f4de5b96f --- /dev/null +++ b/account_spread_cost_revenue_enhanced/static/description/index.html @@ -0,0 +1,430 @@ + + + + + + +Cost-Revenue Spread Extra Features + + + +
+

Cost-Revenue Spread Extra Features

+ + +

Beta License: AGPL-3 OCA/account-financial-tools Translate me on Weblate Try me on Runbot

+

This module aim to address more business cases by adding extra technical function.

+
    +
  1. +
    Add action to direct link with journal item (account.move.line) from spread cost/revenue sheet.
    +
    This is useful when user want to link spread cost/revenue sheet with journal entry (not with invoice)
    +
    +
  2. +
  3. From spread cost/revenue sheet, allow Create Entry as Invoice (not just entry)
  4. +
+

Note: extra feature in this module is not included in account_spread_cost_revenue to avoid complexity.

+

Table of contents

+ +
+

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

+
    +
  • Ecosoft
  • +
+
+ +
+

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.

+

Current maintainer:

+

kittiu

+

This module is part of the OCA/account-financial-tools project on GitHub.

+

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

+
+
+
+ + diff --git a/account_spread_cost_revenue_enhanced/views/account_spread.xml b/account_spread_cost_revenue_enhanced/views/account_spread.xml new file mode 100644 index 000000000..6cad79c3e --- /dev/null +++ b/account_spread_cost_revenue_enhanced/views/account_spread.xml @@ -0,0 +1,16 @@ + + + + view.account.spread + account.spread + + + + + + + + diff --git a/account_spread_cost_revenue_enhanced/wizards/__init__.py b/account_spread_cost_revenue_enhanced/wizards/__init__.py new file mode 100644 index 000000000..8eb52ce6c --- /dev/null +++ b/account_spread_cost_revenue_enhanced/wizards/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import account_spread_link_move_line diff --git a/account_spread_cost_revenue_enhanced/wizards/account_spread_link_move_line.py b/account_spread_cost_revenue_enhanced/wizards/account_spread_link_move_line.py new file mode 100644 index 000000000..f129b9ba8 --- /dev/null +++ b/account_spread_cost_revenue_enhanced/wizards/account_spread_link_move_line.py @@ -0,0 +1,37 @@ +# Copyright 2021 Ecosoft Co., Ltd (http://ecosoft.co.th/) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html) + +from odoo import _, api, fields, models +from odoo.exceptions import UserError + + +class AccountSpreadLinkMoveLine(models.TransientModel): + _name = "account.spread.link.move.line" + _description = "Link spread cost/revenue sheet with journal item" + + move_id = fields.Many2one( + comodel_name="account.move", + string="Journal Entry", + required=True, + ) + move_line_id = fields.Many2one( + comodel_name="account.move.line", + string="Journal Item", + domain="[('move_id', '=', move_id), ('spread_id', '=', False)]", + required=True, + ) + + @api.onchange("move_id") + def _onchange_move_id(self): + self.move_line_id = False + + def link_move_line(self): + active_id = self.env.context.get("active_id") + spread = self.env["account.spread"].browse(active_id) + if spread.invoice_line_id: + raise UserError( + _( + "Already linked with a journal item, please unlink the existing one first." + ) + ) + spread.invoice_line_id = self.move_line_id diff --git a/account_spread_cost_revenue_enhanced/wizards/account_spread_link_move_line.xml b/account_spread_cost_revenue_enhanced/wizards/account_spread_link_move_line.xml new file mode 100644 index 000000000..6a71d4cf5 --- /dev/null +++ b/account_spread_cost_revenue_enhanced/wizards/account_spread_link_move_line.xml @@ -0,0 +1,41 @@ + + + + view.account.spread.link.move.line.form + account.spread.link.move.line + +
+

+ Please choose the Journal Entry, and then the Journal Item you want to link with this spread costs/revenues sheet. +

+ + + + +
+
+
+
+
+ + + Link with Journal Item + account.spread.link.move.line + form + + new + + form + +
diff --git a/setup/account_spread_cost_revenue_enhanced/odoo/addons/account_spread_cost_revenue_enhanced b/setup/account_spread_cost_revenue_enhanced/odoo/addons/account_spread_cost_revenue_enhanced new file mode 120000 index 000000000..2a6bab22e --- /dev/null +++ b/setup/account_spread_cost_revenue_enhanced/odoo/addons/account_spread_cost_revenue_enhanced @@ -0,0 +1 @@ +../../../../account_spread_cost_revenue_enhanced \ No newline at end of file diff --git a/setup/account_spread_cost_revenue_enhanced/setup.py b/setup/account_spread_cost_revenue_enhanced/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/account_spread_cost_revenue_enhanced/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)