[FIX] project,sale_timesheet: fix project update right columns values

Prior to this commit:
- Some of the project update right panel values were wrong (the number of sold and
effective hours were wrong if the service is in units, and eventual down payments are
now removed from the list of SOLs)

task-2703516

closes odoo/odoo#82607

X-original-commit: d1a06012c629f075b6faeaad2b17670e6c0e2aa5
Related: odoo/enterprise#23429
Signed-off-by: Laurent Stukkens (ltu) <ltu@odoo.com>
This commit is contained in:
Cedric Prieels
2022-01-12 13:11:00 +00:00
committed by Cedric Prieels (cpr)
parent 29b1ecb416
commit e2a134b398
2 changed files with 12 additions and 11 deletions
+1 -1
View File
@@ -2118,6 +2118,7 @@ class Task(models.Model):
'res_model': 'project.task',
'type': 'ir.actions.act_window',
'context': {**self._context, 'default_depend_on_ids': [Command.link(self.id)]},
'domain': [('depend_on_ids', '=', self.id)],
}
if self.dependent_tasks_count == 1:
action['view_mode'] = 'form'
@@ -2125,7 +2126,6 @@ class Task(models.Model):
else:
action['name'] = _('Dependent Tasks')
action['view_mode'] = 'tree,form,kanban,calendar,pivot,graph,activity'
action['domain'] = [('depend_on_ids', '=', self.id)]
return action
def action_recurring_tasks(self):
+11 -10
View File
@@ -306,7 +306,7 @@ class Project(models.Model):
def _get_sale_order_lines(self):
sale_orders = self.sale_order_id | self.tasks.sale_order_id
return self.env['sale.order.line'].search([('order_id', 'in', sale_orders.ids), ('is_service', '=', True)], order='id asc')
return self.env['sale.order.line'].search([('order_id', 'in', sale_orders.ids), ('is_service', '=', True), ('is_downpayment', '=', False)], order='id asc')
def _get_sold_items(self):
sols = self._get_sale_order_lines()
@@ -324,15 +324,16 @@ class Project(models.Model):
name = [x[1] for x in sol.name_get()] if number_sale_orders > 1 else sol.name
qty_delivered = sol.product_uom._compute_quantity(sol.qty_delivered, self.env.company.timesheet_encode_uom_id, raise_if_failure=False)
product_uom_qty = sol.product_uom._compute_quantity(sol.product_uom_qty, self.env.company.timesheet_encode_uom_id, raise_if_failure=False)
sold_items['data'].append({
'name': name,
'value': '%s / %s %s' % (formatLang(self.env, qty_delivered, 1), formatLang(self.env, product_uom_qty, 1), sol.product_uom.name if sol.product_uom == product_uom_unit else self.env.company.timesheet_encode_uom_id.name),
'color': 'red' if qty_delivered > product_uom_qty else 'black'
})
#We only want to consider hours and days for this calculation
if sol.product_uom.category_id == self.env.company.timesheet_encode_uom_id.category_id:
sold_items['total_sold'] += product_uom_qty
sold_items['effective_sold'] += sol.product_uom._compute_quantity(qty_delivered, self.env.company.timesheet_encode_uom_id, raise_if_failure=False)
if qty_delivered > 0 or product_uom_qty > 0:
sold_items['data'].append({
'name': name,
'value': '%s / %s %s' % (formatLang(self.env, qty_delivered, 1), formatLang(self.env, product_uom_qty, 1), sol.product_uom.name if sol.product_uom == product_uom_unit else self.env.company.timesheet_encode_uom_id.name),
'color': 'red' if qty_delivered > product_uom_qty else 'black'
})
#We only want to consider hours and days for this calculation, and eventually units if the service policy is not based on milestones
if sol.product_uom.category_id == self.env.company.timesheet_encode_uom_id.category_id or (sol.product_uom == product_uom_unit and sol.product_id.service_policy != 'delivered_manual'):
sold_items['total_sold'] += product_uom_qty
sold_items['effective_sold'] += sol.product_uom._compute_quantity(qty_delivered, self.env.company.timesheet_encode_uom_id, raise_if_failure=False)
remaining = sold_items['total_sold'] - sold_items['effective_sold']
sold_items['remaining'] = {
'value': remaining,