diff --git a/project_link_from_invoice/README.rst b/project_link_from_invoice/README.rst new file mode 100644 index 0000000..935e9ec --- /dev/null +++ b/project_link_from_invoice/README.rst @@ -0,0 +1,47 @@ +================= +project_link_from_invoice +================= + +Easily access to your projects from invoices +View project(s) in invoices tree view +Access to related projects of an invoice from a button + +Installation +============ + +Use Odoo normal procedure to install add-ons to install +``project_link_from_invoice``. + +Known issues / Roadmap +====================== + +Bug Tracker +=========== + +Bugs are tracked on `our issues website +`_. 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. + +Credits +======= + +Images +------ +* Elabore: `Icon `_. + +Contributors +------------ +* Clément Thomas + +Funders +------- +The development of this module has been financially supported by: +* Elabore (https://elabore.coop) + + +Maintainer +---------- + +This module is maintained by Elabore. \ No newline at end of file diff --git a/project_link_from_invoice/__init__.py b/project_link_from_invoice/__init__.py new file mode 100644 index 0000000..cde864b --- /dev/null +++ b/project_link_from_invoice/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +from . import models diff --git a/project_link_from_invoice/__manifest__.py b/project_link_from_invoice/__manifest__.py new file mode 100644 index 0000000..ba7d343 --- /dev/null +++ b/project_link_from_invoice/__manifest__.py @@ -0,0 +1,93 @@ +# Copyright 2022 Stéphan Sainléger (Elabore) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "project_link_from_invoice", + "version": "14.0.0.0.0", + "author": "Elabore", + "website": "https://github.com/elabore-coop/project-tools", + "maintainer": "Clément Thomas", + "license": "AGPL-3", + "category": "Tools", + "summary": "Add link from invoice to project", + "description": """ + :image: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +================= +project_link_from_invoice +================= + +Users can access to related project from invoices + +Installation +============ + +Install ``project_link_from_invoice``, all dependencies will be installed by default. + +Known issues / Roadmap +====================== + +None yet. + +Bug Tracker +=========== + +Bugs are tracked on `our issues website +`_. 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. + +Credits +======= + +Images +------ + +* Elabore: `Icon `_. + +Contributors +------------ + +* Clément Thomas + +Funders +------- + +The development of this module has been financially supported by: +* Elabore (https://elabore.coop) + + +Maintainer +---------- +This module is maintained by Elabore. + +""", + # any module necessary for this one to work correctly + "depends": [ + "base", + "project", + "account", + "sale" + ], + "qweb": [ + # "static/src/xml/*.xml", + ], + "external_dependencies": { + "python": [], + }, + # always loaded + "data": [ + "views/account_move_view.xml", + ], + # only loaded in demonstration mode + "demo": [], + "js": [], + "css": [], + "installable": True, + # Install this module automatically if all dependency have been previously + # and independently installed. Used for synergetic or glue modules. + "auto_install": False, + "application": False, +} diff --git a/project_link_from_invoice/i18n/fr.po b/project_link_from_invoice/i18n/fr.po new file mode 100644 index 0000000..5d2320b --- /dev/null +++ b/project_link_from_invoice/i18n/fr.po @@ -0,0 +1,58 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * project_link_from_invoice +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2023-04-27 12:47+0000\n" +"PO-Revision-Date: 2023-04-27 12:47+0000\n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: project_link_from_invoice +#: model:ir.model.fields,field_description:project_link_from_invoice.field_account_move__display_name +msgid "Display Name" +msgstr "Nom affiché" + +#. module: project_link_from_invoice +#: model:ir.model.fields,field_description:project_link_from_invoice.field_account_move__id +msgid "ID" +msgstr "" + +#. module: project_link_from_invoice +#: model:ir.model,name:project_link_from_invoice.model_account_move +msgid "Journal Entry" +msgstr "Pièce comptable" + +#. module: project_link_from_invoice +#: model:ir.model.fields,field_description:project_link_from_invoice.field_account_move____last_update +msgid "Last Modified on" +msgstr "Dernière modification le" + +#. module: project_link_from_invoice +#: model:ir.model.fields,field_description:project_link_from_invoice.field_account_bank_statement_line__project_ids +#: model:ir.model.fields,field_description:project_link_from_invoice.field_account_move__project_ids +#: model:ir.model.fields,field_description:project_link_from_invoice.field_account_payment__project_ids +msgid "Project" +msgstr "Projet" + +#. module: project_link_from_invoice +#: model:ir.model.fields,field_description:project_link_from_invoice.field_account_bank_statement_line__project_count +#: model:ir.model.fields,field_description:project_link_from_invoice.field_account_move__project_count +#: model:ir.model.fields,field_description:project_link_from_invoice.field_account_payment__project_count +msgid "Project Count" +msgstr "Numbre de projets" + +#. module: project_link_from_invoice +#: model_terms:ir.ui.view,arch_db:project_link_from_invoice.view_move_form_project_link_from_invoice_inherit +#: model:ir.model.fields,field_description:project_link_from_invoice.field_account_bank_statement_line__projects_name +#: model:ir.model.fields,field_description:project_link_from_invoice.field_account_move__projects_name +#: model:ir.model.fields,field_description:project_link_from_invoice.field_account_payment__projects_name +msgid "Project(s)" +msgstr "Projet(s)" diff --git a/project_link_from_invoice/models/__init__.py b/project_link_from_invoice/models/__init__.py new file mode 100644 index 0000000..4aeddb0 --- /dev/null +++ b/project_link_from_invoice/models/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +from . import account_move \ No newline at end of file diff --git a/project_link_from_invoice/models/account_move.py b/project_link_from_invoice/models/account_move.py new file mode 100644 index 0000000..df5059b --- /dev/null +++ b/project_link_from_invoice/models/account_move.py @@ -0,0 +1,38 @@ + +from odoo import models, fields, api + + +class AccountMove(models.Model): + _inherit = "account.move" + + project_ids = fields.Many2many('project.project', name="Projects", compute='get_related_project_ids') + project_count = fields.Integer("Project Count", compute='get_related_project_ids') + projects_name = fields.Char('Project(s)', compute='get_related_project_ids') + + def action_open_projects(self): + ''' + Open related projects, in form or tree view depending on project numbers + ''' + project_ids = self.project_ids.ids + action = self.env["ir.actions.actions"]._for_xml_id("project.open_view_project_all") + + if self.project_count == 1: + action['res_id'] = project_ids[0] + action['views'] = [[False, "form"]] + else: + action['views'] = [[False, "tree"], [False, "form"]] + + action['domain'] = [('id', 'in', project_ids)] + + del action['target'] #to display breadcrumbs + + return action + + + @api.depends('line_ids.sale_line_ids') + def get_related_project_ids(self): + for move in self: + projects = self.env['project.task'].search([('sale_order_id','in',move.line_ids.sale_line_ids.order_id.ids)]).project_id + move.project_ids = projects.ids + move.projects_name = ' ; '.join([p.name for p in projects]) + move.project_count = len(projects) \ No newline at end of file diff --git a/project_link_from_invoice/views/account_move_view.xml b/project_link_from_invoice/views/account_move_view.xml new file mode 100644 index 0000000..777f0d7 --- /dev/null +++ b/project_link_from_invoice/views/account_move_view.xml @@ -0,0 +1,32 @@ + + + + account.move.form.project.link + account.move + + + + +