diff --git a/addons/sale/models/analytic.py b/addons/sale/models/analytic.py index 06ae2a552cb..5888e183ef9 100644 --- a/addons/sale/models/analytic.py +++ b/addons/sale/models/analytic.py @@ -7,21 +7,20 @@ from odoo import fields, models class AccountAnalyticLine(models.Model): _inherit = "account.analytic.line" + # [XBO] TODO: remove me in master allowed_so_line_ids = fields.Many2many('sale.order.line', compute='_compute_allowed_so_line_ids') - so_line = fields.Many2one('sale.order.line', string='Sales Order Item', domain="[('id', 'in', allowed_so_line_ids)]") + so_line = fields.Many2one('sale.order.line', string='Sales Order Item', domain=[('qty_delivered_method', '=', 'analytic')]) def _default_sale_line_domain(self): """ This is only used for delivered quantity of SO line based on analytic line, and timesheet (see sale_timesheet). This can be override to allow further customization. + [XBO] TODO: remove me in master """ - self.ensure_one() return [('qty_delivered_method', '=', 'analytic')] def _compute_allowed_so_line_ids(self): - for timesheet in self: - domain = timesheet._default_sale_line_domain() - timesheet.allowed_so_line_ids = self.env['sale.order.line'].search(domain) - + # [XBO] TODO: remove me in master + self.allowed_so_line_ids = False class AccountAnalyticApplicability(models.Model): _inherit = 'account.analytic.applicability' diff --git a/addons/sale_timesheet/models/account.py b/addons/sale_timesheet/models/account.py index 3e3444f3567..5a5f0fabafb 100644 --- a/addons/sale_timesheet/models/account.py +++ b/addons/sale_timesheet/models/account.py @@ -26,6 +26,13 @@ class AccountAnalyticLine(models.Model): commercial_partner_id = fields.Many2one('res.partner', compute="_compute_commercial_partner") timesheet_invoice_id = fields.Many2one('account.move', string="Invoice", readonly=True, copy=False, help="Invoice created from the timesheet", index='btree_not_null') so_line = fields.Many2one(compute="_compute_so_line", store=True, readonly=False, + domain="""[ + ('qty_delivered_method', 'in', ['analytic', 'timesheet']), + ('order_partner_id', '=', commercial_partner_id), + ('is_service', '=', True), + ('is_expense', '=', False), + ('state', '=', 'sale') + ]""", help="Sales order item to which the time spent will be added in order to be invoiced to your customer. Remove the sales order item for the timesheet entry to be non-billable.") # we needed to store it only in order to be able to groupby in the portal order_id = fields.Many2one(related='so_line.order_id', store=True, readonly=True, index=True) @@ -33,6 +40,7 @@ class AccountAnalyticLine(models.Model): allow_billable = fields.Boolean(related="project_id.allow_billable") def _default_sale_line_domain(self): + # [XBO] TODO: remove me in master return expression.OR([[ ('is_service', '=', True), ('is_expense', '=', False), @@ -40,8 +48,8 @@ class AccountAnalyticLine(models.Model): ('order_partner_id', 'child_of', self.sudo().commercial_partner_id.ids) ], super()._default_sale_line_domain()]) - @api.depends('commercial_partner_id') def _compute_allowed_so_line_ids(self): + # [XBO] TODO: remove me in master super()._compute_allowed_so_line_ids() @api.depends('project_id.partner_id.commercial_partner_id', 'task_id.partner_id.commercial_partner_id') diff --git a/addons/sale_timesheet/views/hr_timesheet_views.xml b/addons/sale_timesheet/views/hr_timesheet_views.xml index 35f41fa9766..09adfca6649 100644 --- a/addons/sale_timesheet/views/hr_timesheet_views.xml +++ b/addons/sale_timesheet/views/hr_timesheet_views.xml @@ -42,7 +42,6 @@ - @@ -57,7 +56,6 @@ -