From 3751379f1e9a4c215fb6eb898b4ccc67659b9ace Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Tue, 10 May 2022 21:51:50 +0700 Subject: initial commit 2 --- addons/sale_timesheet_edit/models/__init__.py | 5 +++++ .../models/account_analytic_line.py | 20 ++++++++++++++++++++ addons/sale_timesheet_edit/models/project.py | 15 +++++++++++++++ 3 files changed, 40 insertions(+) create mode 100644 addons/sale_timesheet_edit/models/__init__.py create mode 100644 addons/sale_timesheet_edit/models/account_analytic_line.py create mode 100644 addons/sale_timesheet_edit/models/project.py (limited to 'addons/sale_timesheet_edit/models') diff --git a/addons/sale_timesheet_edit/models/__init__.py b/addons/sale_timesheet_edit/models/__init__.py new file mode 100644 index 00000000..bf8826f4 --- /dev/null +++ b/addons/sale_timesheet_edit/models/__init__.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from . import account_analytic_line +from . import project diff --git a/addons/sale_timesheet_edit/models/account_analytic_line.py b/addons/sale_timesheet_edit/models/account_analytic_line.py new file mode 100644 index 00000000..5ff797dd --- /dev/null +++ b/addons/sale_timesheet_edit/models/account_analytic_line.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from odoo import api, fields, models + + +# TODO: [XBO] merge with account.analytic.line in the sale_timesheet module in master. +class AccountAnalyticLine(models.Model): + _inherit = 'account.analytic.line' + + is_so_line_edited = fields.Boolean() + + @api.depends('task_id.sale_line_id', 'project_id.sale_line_id', 'project_id.allow_billable', 'employee_id') + def _compute_so_line(self): + super(AccountAnalyticLine, self.filtered(lambda t: not t.is_so_line_edited))._compute_so_line() + + def _check_sale_line_in_project_map(self): + # TODO: [XBO] remove me in master, now we authorize to manually edit the so_line, then this so_line can be different of the one in task/project/map_entry + # !!! Override of the method in sale_timesheet !!! + return diff --git a/addons/sale_timesheet_edit/models/project.py b/addons/sale_timesheet_edit/models/project.py new file mode 100644 index 00000000..b10bafdd --- /dev/null +++ b/addons/sale_timesheet_edit/models/project.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from odoo import models + + +class Project(models.Model): + _inherit = 'project.project' + + def _get_not_billed_timesheets(self): + """ Get the timesheets not invoiced and the SOL has not manually been edited + FIXME: [XBO] this change must be done in the _update_timesheets_sale_line_id + rather than this method in master to keep the initial behaviour of this method. + """ + return super(Project, self)._get_not_billed_timesheets() - self.mapped('timesheet_ids').filtered('is_so_line_edited') -- cgit v1.2.3