diff --git a/addons/account_sale_timesheet/__init__.py b/addons/account_sale_timesheet/__init__.py deleted file mode 100644 index dc5e6b693d19dcacd224b7ab27b26f75e66cb7b2..0000000000000000000000000000000000000000 --- a/addons/account_sale_timesheet/__init__.py +++ /dev/null @@ -1,4 +0,0 @@ -# -*- coding: utf-8 -*- -# Part of Odoo. See LICENSE file for full copyright and licensing details. - -from . import models diff --git a/addons/account_sale_timesheet/__manifest__.py b/addons/account_sale_timesheet/__manifest__.py deleted file mode 100644 index 792e8e8fb86cf0338411f91d9a9e992cab449fd7..0000000000000000000000000000000000000000 --- a/addons/account_sale_timesheet/__manifest__.py +++ /dev/null @@ -1,19 +0,0 @@ -# -*- coding: utf-8 -*- -# Part of Odoo. See LICENSE file for full copyright and licensing details. - - -{ - 'name': 'Account Sale Timesheet', - 'version': '1.0', - 'category': 'Account/sale/timesheet', - 'summary': 'Account sale timesheet', - 'description': 'Bridge created to add the number of invoices linked to an AA to a project form', - 'depends': ['account', 'sale_timesheet'], - 'data': [ - 'views/project_project_views.xml', - ], - 'demo': [], - 'installable': True, - 'auto_install': True, - 'license': 'OEEL-1', -} diff --git a/addons/account_sale_timesheet/i18n/account_sale_timesheet.pot b/addons/account_sale_timesheet/i18n/account_sale_timesheet.pot deleted file mode 100644 index c70d3bb9049f29314440f6074afdede62491d1da..0000000000000000000000000000000000000000 --- a/addons/account_sale_timesheet/i18n/account_sale_timesheet.pot +++ /dev/null @@ -1,40 +0,0 @@ -# Translation of Odoo Server. -# This file contains the translation of the following modules: -# * account_sale_timesheet -# -msgid "" -msgstr "" -"Project-Id-Version: Odoo Server saas~14.5\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2021-09-14 10:28+0000\n" -"PO-Revision-Date: 2021-09-14 10:28+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: account_sale_timesheet -#: model_terms:ir.ui.view,arch_db:account_sale_timesheet.project_project_view_form -msgid "" -"<span class=\"o_stat_text\">\n" -" Invoices\n" -" </span>" -msgstr "" - -#. module: account_sale_timesheet -#: model:ir.model.fields,field_description:account_sale_timesheet.field_project_project__invoice_count -msgid "Invoice Count" -msgstr "" - -#. module: account_sale_timesheet -#: code:addons/account_sale_timesheet/models/project.py:0 -#, python-format -msgid "Invoices" -msgstr "" - -#. module: account_sale_timesheet -#: model:ir.model,name:account_sale_timesheet.model_project_project -msgid "Project" -msgstr "" diff --git a/addons/account_sale_timesheet/models/__init__.py b/addons/account_sale_timesheet/models/__init__.py deleted file mode 100644 index 527e2954c0683902c683341865fa9d26be501a38..0000000000000000000000000000000000000000 --- a/addons/account_sale_timesheet/models/__init__.py +++ /dev/null @@ -1,4 +0,0 @@ -# -*- coding: utf-8 -*- -# Part of Odoo. See LICENSE file for full copyright and licensing details. - -from . import project diff --git a/addons/account_sale_timesheet/models/project.py b/addons/account_sale_timesheet/models/project.py deleted file mode 100644 index 4dc05e5a2fd2942ed688f4fdae541922796e9e27..0000000000000000000000000000000000000000 --- a/addons/account_sale_timesheet/models/project.py +++ /dev/null @@ -1,27 +0,0 @@ -# -*- coding: utf-8 -*- -# Part of Odoo. See LICENSE file for full copyright and licensing details. - -from odoo import fields, models, _lt - -class Project(models.Model): - _inherit = 'project.project' - - invoice_count = fields.Integer(related='analytic_account_id.invoice_count', groups='account.group_account_readonly') - - # ---------------------------- - # Project Updates - # ---------------------------- - - def _get_stat_buttons(self): - buttons = super(Project, self)._get_stat_buttons() - if self.user_has_groups('account.group_account_readonly'): - buttons.append({ - 'icon': 'pencil-square-o', - 'text': _lt('Invoices'), - 'number': self.invoice_count, - 'action_type': 'object', - 'action': 'action_open_project_invoices', - 'show': bool(self.analytic_account_id) and self.invoice_count > 0, - 'sequence': 30, - }) - return buttons diff --git a/addons/account_sale_timesheet/views/project_project_views.xml b/addons/account_sale_timesheet/views/project_project_views.xml deleted file mode 100644 index bfeda30deaee6f9cc7542bcb935706fd770bccb4..0000000000000000000000000000000000000000 --- a/addons/account_sale_timesheet/views/project_project_views.xml +++ /dev/null @@ -1,27 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<odoo> - - <record id="project_project_view_form" model="ir.ui.view"> - <field name="name">project.project.form.inherit</field> - <field name="model">project.project</field> - <field name="inherit_id" ref="project.edit_project"/> - <field name="priority">50</field> - <field name="arch" type="xml"> - <xpath expr="//button[@name='action_view_analytic_account_entries']" position="after"> - <button name="action_open_project_invoices" type="object" class="oe_stat_button" icon="fa-pencil-square-o" - attrs="{'invisible': ['|', ('invoice_count', '=', 0), ('analytic_account_id', '=', False)]}" - groups="account.group_account_readonly"> - <div class="o_field_widget o_stat_info"> - <span class="o_stat_value"> - <field name="invoice_count" nolabel="1"/> - </span> - <span class="o_stat_text"> - Invoices - </span> - </div> - </button> - </xpath> - </field> - </record> - -</odoo> diff --git a/addons/sale_project/models/project.py b/addons/sale_project/models/project.py index 33f0c58558767b08b32f01d522052c45127d8377..7b41a873165bf05909e82f8e8d8290de8d51e0ff 100644 --- a/addons/sale_project/models/project.py +++ b/addons/sale_project/models/project.py @@ -23,6 +23,8 @@ class Project(models.Model): has_any_so_to_invoice = fields.Boolean('Has SO to Invoice', compute='_compute_has_any_so_to_invoice') sale_order_count = fields.Integer(compute='_compute_sale_order_count', groups='sales_team.group_sale_salesman') has_any_so_with_nothing_to_invoice = fields.Boolean('Has a SO with an invoice status of No', compute='_compute_has_any_so_with_nothing_to_invoice') + invoice_count = fields.Integer(related='analytic_account_id.invoice_count', groups='account.group_account_readonly') + vendor_bill_count = fields.Integer(related='analytic_account_id.vendor_bill_count', groups='account.group_account_readonly') @api.model def _map_tasks_default_valeus(self, task, project): @@ -128,6 +130,27 @@ class Project(models.Model): action['context']['default_advance_payment_method'] = 'percentage' return action + def action_open_project_invoices(self): + invoices = self.env['account.move'].search([ + ('line_ids.analytic_account_id', '!=', False), + ('line_ids.analytic_account_id', 'in', self.analytic_account_id.ids), + ('move_type', '=', 'out_invoice') + ]) + action = { + 'name': _('Invoices'), + 'type': 'ir.actions.act_window', + 'res_model': 'account.move', + 'views': [[False, 'tree'], [False, 'form'], [False, 'kanban']], + 'domain': [('id', 'in', invoices.ids)], + 'context': { + 'create': False, + } + } + if len(invoices) == 1: + action['views'] = [[False, 'form']] + action['res_id'] = invoices.id + return action + # ---------------------------- # Project Updates # ---------------------------- @@ -222,8 +245,45 @@ class Project(models.Model): 'show': self.sale_order_count > 0, 'sequence': 1, }) + if self.user_has_groups('account.group_account_readonly'): + buttons.append({ + 'icon': 'pencil-square-o', + 'text': _lt('Invoices'), + 'number': self.invoice_count, + 'action_type': 'object', + 'action': 'action_open_project_invoices', + 'show': bool(self.analytic_account_id) and self.invoice_count > 0, + 'sequence': 30, + }) + if self.user_has_groups('account.group_account_readonly'): + buttons.append({ + 'icon': 'pencil-square-o', + 'text': _lt('Vendor Bills'), + 'number': self.vendor_bill_count, + 'action_type': 'object', + 'action': 'action_open_project_vendor_bills', + 'show': self.vendor_bill_count > 0, + 'sequence': 48, + }) return buttons + def action_open_project_vendor_bills(self): + vendor_bills = self.env['account.move'].search([('line_ids.analytic_account_id', '!=', False), ('line_ids.analytic_account_id', 'in', self.analytic_account_id.ids), ('move_type', '=', 'in_invoice')]) + action_window = { + 'name': _('Vendor Bills'), + 'type': 'ir.actions.act_window', + 'res_model': 'account.move', + 'views': [[False, 'tree'], [False, 'form'], [False, 'kanban']], + 'domain': [('id', 'in', vendor_bills.ids)], + 'context': { + 'create': False, + } + } + if len(vendor_bills) == 1: + action_window['views'] = [[False, 'form']] + action_window['res_id'] = vendor_bills.id + return action_window + class ProjectTask(models.Model): _inherit = "project.task" diff --git a/addons/sale_project/views/project_task_views.xml b/addons/sale_project/views/project_task_views.xml index 1c97e83aad02b6896087cf3ed9fe7bdc7db67184..3f90b8c8941fb42890a8aaf3c3d01447e8d3ffdb 100644 --- a/addons/sale_project/views/project_task_views.xml +++ b/addons/sale_project/views/project_task_views.xml @@ -16,6 +16,7 @@ <field name="name">project.project.tree.inherit.sale.project</field> <field name="model">project.project</field> <field name="inherit_id" ref="project.view_project"/> + <field name="priority">50</field> <field name="arch" type="xml"> <xpath expr="//field[@name='partner_id']" position="after"> <field name="sale_line_id" optional="hide" readonly="1"/> @@ -59,6 +60,32 @@ </div> </div> </xpath> + <xpath expr="//button[@name='action_view_analytic_account_entries']" position="after"> + <button name="action_open_project_invoices" type="object" class="oe_stat_button" icon="fa-pencil-square-o" + attrs="{'invisible': ['|', ('invoice_count', '=', 0), ('analytic_account_id', '=', False)]}" + groups="account.group_account_readonly"> + <div class="o_field_widget o_stat_info"> + <span class="o_stat_value"> + <field name="invoice_count" nolabel="1"/> + </span> + <span class="o_stat_text"> + Invoices + </span> + </div> + </button> + </xpath> + <xpath expr="//button[@name='action_view_analytic_account_entries']" position="after"> + <button name="action_open_project_vendor_bills" type="object" class="oe_stat_button" icon="fa-pencil-square-o" attrs="{'invisible': [('vendor_bill_count', '=', 0)]}" groups="account.group_account_readonly"> + <div class="o_field_widget o_stat_info"> + <span class="o_stat_value"> + <field name="vendor_bill_count" nolabel="1"/> + </span> + <span class="o_stat_text"> + Vendor Bills + </span> + </div> + </button> + </xpath> </field> </record> <record id="view_sale_project_inherit_form" model="ir.ui.view"> diff --git a/addons/sale_project_account/__init__.py b/addons/sale_project_account/__init__.py deleted file mode 100644 index dc5e6b693d19dcacd224b7ab27b26f75e66cb7b2..0000000000000000000000000000000000000000 --- a/addons/sale_project_account/__init__.py +++ /dev/null @@ -1,4 +0,0 @@ -# -*- coding: utf-8 -*- -# Part of Odoo. See LICENSE file for full copyright and licensing details. - -from . import models diff --git a/addons/sale_project_account/__manifest__.py b/addons/sale_project_account/__manifest__.py deleted file mode 100644 index 161d8cd65ac346491bd16c444cc2dc70481529f1..0000000000000000000000000000000000000000 --- a/addons/sale_project_account/__manifest__.py +++ /dev/null @@ -1,19 +0,0 @@ -# -*- coding: utf-8 -*- -# Part of Odoo. See LICENSE file for full copyright and licensing details. - - -{ - 'name': 'Project Sales Accounting', - 'version': '1.0', - 'category': 'Services/account', - 'summary': 'Project sales accounting', - 'description': 'Bridge created to add the number of vendor bills linked to an AA to a project form', - 'depends': ['sale_timesheet', 'account'], - 'data': [ - 'views/project_project_views.xml', - ], - 'demo': [], - 'installable': True, - 'auto_install': True, - 'license': 'OEEL-1', -} diff --git a/addons/sale_project_account/i18n/sale_project_account.pot b/addons/sale_project_account/i18n/sale_project_account.pot deleted file mode 100644 index 6c71d9c3908d17c6535e45572d5c887f6e9c3c4c..0000000000000000000000000000000000000000 --- a/addons/sale_project_account/i18n/sale_project_account.pot +++ /dev/null @@ -1,41 +0,0 @@ -# Translation of Odoo Server. -# This file contains the translation of the following modules: -# * sale_project_account -# -msgid "" -msgstr "" -"Project-Id-Version: Odoo Server saas~14.5\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2021-09-14 10:29+0000\n" -"PO-Revision-Date: 2021-09-14 10:29+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: sale_project_account -#: model_terms:ir.ui.view,arch_db:sale_project_account.project_project_view_form -msgid "" -"<span class=\"o_stat_text\">\n" -" Vendor Bills\n" -" </span>" -msgstr "" - -#. module: sale_project_account -#: model:ir.model,name:sale_project_account.model_project_project -msgid "Project" -msgstr "" - -#. module: sale_project_account -#: model:ir.model.fields,field_description:sale_project_account.field_project_project__vendor_bill_count -msgid "Vendor Bill Count" -msgstr "" - -#. module: sale_project_account -#: code:addons/sale_project_account/models/project.py:0 -#: code:addons/sale_project_account/models/project.py:0 -#, python-format -msgid "Vendor Bills" -msgstr "" diff --git a/addons/sale_project_account/models/__init__.py b/addons/sale_project_account/models/__init__.py deleted file mode 100644 index 527e2954c0683902c683341865fa9d26be501a38..0000000000000000000000000000000000000000 --- a/addons/sale_project_account/models/__init__.py +++ /dev/null @@ -1,4 +0,0 @@ -# -*- coding: utf-8 -*- -# Part of Odoo. See LICENSE file for full copyright and licensing details. - -from . import project diff --git a/addons/sale_project_account/models/project.py b/addons/sale_project_account/models/project.py deleted file mode 100644 index 2c77c19a41f1ef4fbd64702595c22a4076084ba6..0000000000000000000000000000000000000000 --- a/addons/sale_project_account/models/project.py +++ /dev/null @@ -1,48 +0,0 @@ -# -*- coding: utf-8 -*- -# Part of Odoo. See LICENSE file for full copyright and licensing details. - -from odoo import fields, models, _, _lt - -class Project(models.Model): - _inherit = 'project.project' - - vendor_bill_count = fields.Integer(related='analytic_account_id.vendor_bill_count', groups='account.group_account_readonly') - - # ---------------------------- - # Actions - # ---------------------------- - - def action_open_project_vendor_bills(self): - vendor_bills = self.env['account.move'].search([('line_ids.analytic_account_id', '!=', False), ('line_ids.analytic_account_id', 'in', self.analytic_account_id.ids), ('move_type', '=', 'in_invoice')]) - action_window = { - 'name': _('Vendor Bills'), - 'type': 'ir.actions.act_window', - 'res_model': 'account.move', - 'views': [[False, 'tree'], [False, 'form'], [False, 'kanban']], - 'domain': [('id', 'in', vendor_bills.ids)], - 'context': { - 'create': False, - } - } - if len(vendor_bills) == 1: - action_window['views'] = [[False, 'form']] - action_window['res_id'] = vendor_bills.id - return action_window - - # ---------------------------- - # Project Updates - # ---------------------------- - - def _get_stat_buttons(self): - buttons = super(Project, self)._get_stat_buttons() - if self.user_has_groups('account.group_account_readonly'): - buttons.append({ - 'icon': 'pencil-square-o', - 'text': _lt('Vendor Bills'), - 'number': self.vendor_bill_count, - 'action_type': 'object', - 'action': 'action_open_project_vendor_bills', - 'show': self.vendor_bill_count > 0, - 'sequence': 48, - }) - return buttons diff --git a/addons/sale_project_account/views/project_project_views.xml b/addons/sale_project_account/views/project_project_views.xml deleted file mode 100644 index 4394f752a7ba2c1b9cf3673d481d993551d3d4ca..0000000000000000000000000000000000000000 --- a/addons/sale_project_account/views/project_project_views.xml +++ /dev/null @@ -1,25 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<odoo> - - <record id="project_project_view_form" model="ir.ui.view"> - <field name="name">project.project.form.inherit</field> - <field name="model">project.project</field> - <field name="inherit_id" ref="project.edit_project"/> - <field name="priority">10</field> - <field name="arch" type="xml"> - <xpath expr="//button[@name='action_view_analytic_account_entries']" position="after"> - <button name="action_open_project_vendor_bills" type="object" class="oe_stat_button" icon="fa-pencil-square-o" attrs="{'invisible': [('vendor_bill_count', '=', 0)]}" groups="account.group_account_readonly"> - <div class="o_field_widget o_stat_info"> - <span class="o_stat_value"> - <field name="vendor_bill_count" nolabel="1"/> - </span> - <span class="o_stat_text"> - Vendor Bills - </span> - </div> - </button> - </xpath> - </field> - </record> - -</odoo> diff --git a/addons/sale_timesheet/models/project.py b/addons/sale_timesheet/models/project.py index 76ad494a13d9072e04e2b84ffcc3082e2eb5a5db..bff2f861db07aae2eaa3cf7e09c558f0f9152139 100644 --- a/addons/sale_timesheet/models/project.py +++ b/addons/sale_timesheet/models/project.py @@ -245,27 +245,6 @@ class Project(models.Model): sale_line_id = project.sale_line_employee_ids.filtered(lambda l: l.project_id == project and l.employee_id == employee_id).sale_line_id timesheet_ids.filtered(lambda t: t.employee_id == employee_id).sudo().so_line = sale_line_id - def action_open_project_invoices(self): - invoices = self.env['account.move'].search([ - ('line_ids.analytic_account_id', '!=', False), - ('line_ids.analytic_account_id', 'in', self.analytic_account_id.ids), - ('move_type', '=', 'out_invoice') - ]) - action = { - 'name': _('Invoices'), - 'type': 'ir.actions.act_window', - 'res_model': 'account.move', - 'views': [[False, 'tree'], [False, 'form'], [False, 'kanban']], - 'domain': [('id', 'in', invoices.ids)], - 'context': { - 'create': False, - } - } - if len(invoices) == 1: - action['views'] = [[False, 'form']] - action['res_id'] = invoices.id - return action - def action_view_timesheet(self): self.ensure_one() return {