[IMP] project: Remove commercial_partner_id from task/project model
closes odoo/odoo#115155 Taskid: 3231143 Related: odoo/enterprise#38142 Related: odoo/upgrade#4432 Signed-off-by: Xavier Bol (xbo) <xbo@odoo.com>
This commit is contained in:
committed by
Xavier Bol (xbo)
parent
c002e4176a
commit
dcbdb6e690
@@ -26,7 +26,6 @@ PROJECT_TASK_READABLE_FIELDS = {
|
||||
'project_id',
|
||||
'display_project_id',
|
||||
'color',
|
||||
'commercial_partner_id',
|
||||
'allow_subtasks',
|
||||
'subtask_count',
|
||||
'is_private',
|
||||
@@ -314,7 +313,6 @@ class Project(models.Model):
|
||||
help="If the active field is set to False, it will allow you to hide the project without removing it.")
|
||||
sequence = fields.Integer(default=10)
|
||||
partner_id = fields.Many2one('res.partner', string='Customer', auto_join=True, tracking=True, check_company=True)
|
||||
commercial_partner_id = fields.Many2one(related="partner_id.commercial_partner_id")
|
||||
company_id = fields.Many2one('res.company', string='Company', required=True, default=lambda self: self.env.company)
|
||||
currency_id = fields.Many2one('res.currency', related="company_id.currency_id", string="Currency", readonly=True)
|
||||
analytic_account_id = fields.Many2one('account.analytic.account', string="Analytic Account", copy=False, ondelete='set null',
|
||||
@@ -1189,7 +1187,6 @@ class Task(models.Model):
|
||||
string='Customer', recursive=True, tracking=True,
|
||||
compute='_compute_partner_id', store=True, readonly=False,
|
||||
domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]")
|
||||
commercial_partner_id = fields.Many2one(related='partner_id.commercial_partner_id')
|
||||
partner_phone = fields.Char(
|
||||
compute='_compute_partner_phone', inverse='_inverse_partner_phone',
|
||||
string="Phone", readonly=False, store=True, copy=False)
|
||||
|
||||
@@ -755,7 +755,6 @@
|
||||
>
|
||||
<field name="display_name"/>
|
||||
<field name="partner_id"/>
|
||||
<field name="commercial_partner_id"/>
|
||||
<field name="color"/>
|
||||
<field name="task_count"/>
|
||||
<field name="milestone_count_reached"/>
|
||||
|
||||
@@ -587,7 +587,7 @@ class ProjectTask(models.Model):
|
||||
def SELF_READABLE_FIELDS(self):
|
||||
return super().SELF_READABLE_FIELDS | {'allow_billable', 'sale_order_id', 'sale_line_id', 'display_sale_order_button'}
|
||||
|
||||
@api.depends('sale_line_id', 'project_id', 'commercial_partner_id', 'allow_billable')
|
||||
@api.depends('sale_line_id', 'project_id', 'partner_id.commercial_partner_id', 'allow_billable')
|
||||
def _compute_sale_order_id(self):
|
||||
for task in self:
|
||||
if not task.allow_billable:
|
||||
@@ -598,13 +598,13 @@ class ProjectTask(models.Model):
|
||||
sale_order_id = task.sale_line_id.sudo().order_id
|
||||
elif task.project_id.sale_order_id:
|
||||
sale_order_id = task.project_id.sale_order_id
|
||||
if task.commercial_partner_id != sale_order_id.partner_id.commercial_partner_id:
|
||||
if task.partner_id.commercial_partner_id != sale_order_id.partner_id.commercial_partner_id:
|
||||
sale_order_id = False
|
||||
if sale_order_id and not task.partner_id:
|
||||
task.partner_id = sale_order_id.partner_id
|
||||
task.sale_order_id = sale_order_id
|
||||
|
||||
@api.depends('commercial_partner_id', 'sale_line_id.order_partner_id', 'parent_id.sale_line_id', 'project_id.sale_line_id', 'milestone_id.sale_line_id', 'allow_billable')
|
||||
@api.depends('partner_id.commercial_partner_id', 'sale_line_id.order_partner_id', 'parent_id.sale_line_id', 'project_id.sale_line_id', 'milestone_id.sale_line_id', 'allow_billable')
|
||||
def _compute_sale_line(self):
|
||||
for task in self:
|
||||
if not task.allow_billable:
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
<attribute name="context">{'res_partner_search_mode': 'customer'}</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='partner_id']" position="after">
|
||||
<field name="commercial_partner_id" invisible="1" />
|
||||
<field name="sale_line_id" string="Sales Order Item" attrs="{'invisible': [('partner_id', '=', False)]}" options='{"no_open": True}' readonly="1" context="{'create': False, 'edit': False, 'delete': False}"/>
|
||||
</xpath>
|
||||
</field>
|
||||
|
||||
@@ -85,7 +85,6 @@
|
||||
<field name="sale_order_id" attrs="{'invisible': True}" groups="sales_team.group_sale_salesman"/>
|
||||
<field name="sale_line_id" groups="!sales_team.group_sale_salesman" string="Sales Order Item" options='{"no_open": True}' readonly="1" context="{'create': False, 'edit': False, 'delete': False}" attrs="{'invisible': ['|', ('allow_billable', '=', False), ('project_id', '=', False)]}"/>
|
||||
<field name="sale_line_id" groups="sales_team.group_sale_salesman" string="Sales Order Item" options='{"no_create": True}' readonly="0" context="{'create': False, 'edit': False, 'delete': False, 'with_price_unit': True}" placeholder="Non-billable" attrs="{'invisible': ['|', ('allow_billable', '=', False), ('project_id', '=', False)]}"/>
|
||||
<field name="commercial_partner_id" invisible="1" />
|
||||
<field name="allow_billable" invisible="1"/>
|
||||
</xpath>
|
||||
</field>
|
||||
|
||||
@@ -37,10 +37,10 @@ class AccountAnalyticLine(models.Model):
|
||||
is_so_line_edited = fields.Boolean("Is Sales Order Item Manually Edited")
|
||||
allow_billable = fields.Boolean(related="project_id.allow_billable")
|
||||
|
||||
@api.depends('project_id.commercial_partner_id', 'task_id.commercial_partner_id')
|
||||
@api.depends('project_id.partner_id.commercial_partner_id', 'task_id.partner_id.commercial_partner_id')
|
||||
def _compute_commercial_partner(self):
|
||||
for timesheet in self:
|
||||
timesheet.commercial_partner_id = timesheet.task_id.commercial_partner_id or timesheet.project_id.commercial_partner_id
|
||||
timesheet.commercial_partner_id = timesheet.task_id.partner_id.commercial_partner_id or timesheet.project_id.partner_id.commercial_partner_id
|
||||
|
||||
@api.depends('so_line.product_id', 'project_id', 'amount')
|
||||
def _compute_timesheet_invoice_type(self):
|
||||
@@ -115,7 +115,7 @@ class AccountAnalyticLine(models.Model):
|
||||
map_entry = self.project_id.sale_line_employee_ids.filtered(
|
||||
lambda map_entry:
|
||||
map_entry.employee_id == self.employee_id
|
||||
and map_entry.sale_line_id.order_partner_id.commercial_partner_id == self.task_id.commercial_partner_id
|
||||
and map_entry.sale_line_id.order_partner_id.commercial_partner_id == self.task_id.partner_id.commercial_partner_id
|
||||
)
|
||||
if map_entry:
|
||||
return map_entry.sale_line_id
|
||||
|
||||
@@ -555,7 +555,7 @@ class ProjectTask(models.Model):
|
||||
for task in self:
|
||||
task.analytic_account_active = task.analytic_account_active or task.so_analytic_account_id.active
|
||||
|
||||
@api.depends('commercial_partner_id', 'sale_line_id.order_partner_id', 'parent_id.sale_line_id', 'project_id.sale_line_id', 'allow_billable')
|
||||
@api.depends('partner_id.commercial_partner_id', 'sale_line_id.order_partner_id', 'parent_id.sale_line_id', 'project_id.sale_line_id', 'allow_billable')
|
||||
def _compute_sale_line(self):
|
||||
super()._compute_sale_line()
|
||||
for task in self:
|
||||
@@ -575,10 +575,10 @@ class ProjectTask(models.Model):
|
||||
def _get_last_sol_of_customer(self):
|
||||
# Get the last SOL made for the customer in the current task where we need to compute
|
||||
self.ensure_one()
|
||||
if not self.commercial_partner_id or not self.allow_billable:
|
||||
if not self.partner_id.commercial_partner_id or not self.allow_billable:
|
||||
return False
|
||||
domain = [('company_id', '=', self.company_id.id), ('is_service', '=', True), ('order_partner_id', 'child_of', self.commercial_partner_id.id), ('is_expense', '=', False), ('state', 'in', ['sale', 'done']), ('remaining_hours', '>', 0)]
|
||||
if self.project_id.pricing_type != 'task_rate' and self.project_sale_order_id and self.commercial_partner_id == self.project_id.partner_id.commercial_partner_id:
|
||||
domain = [('company_id', '=', self.company_id.id), ('is_service', '=', True), ('order_partner_id', 'child_of', self.partner_id.commercial_partner_id.id), ('is_expense', '=', False), ('state', 'in', ['sale', 'done']), ('remaining_hours', '>', 0)]
|
||||
if self.project_id.pricing_type != 'task_rate' and self.project_sale_order_id and self.partner_id.commercial_partner_id == self.project_id.partner_id.commercial_partner_id:
|
||||
domain.append(('order_id', '=?', self.project_sale_order_id.id))
|
||||
return self.env['sale.order.line'].search(domain, limit=1)
|
||||
|
||||
|
||||
@@ -138,12 +138,12 @@
|
||||
<field name="so_line" groups="!sales_team.group_sale_salesman"
|
||||
attrs="{'column_invisible': [('parent.allow_billable', '=', False)]}"
|
||||
context="{'with_remaining_hours': True, 'with_price_unit': True}" options="{'no_create': True, 'no_open': True}"
|
||||
domain="[('is_service', '=', True), ('order_partner_id', 'child_of', parent.commercial_partner_id), ('is_expense', '=', False), ('state', 'in', ['sale', 'done'])]"
|
||||
domain="[('is_service', '=', True), ('order_partner_id', 'child_of', parent.partner_id), ('is_expense', '=', False), ('state', 'in', ['sale', 'done'])]"
|
||||
optional="hide"/>
|
||||
<field name="so_line" groups="sales_team.group_sale_salesman"
|
||||
attrs="{'column_invisible': [('parent.allow_billable', '=', False)]}"
|
||||
context="{'with_remaining_hours': True, 'with_price_unit': True}" options="{'no_create': True}"
|
||||
domain="[('is_service', '=', True), ('order_partner_id', 'child_of', parent.commercial_partner_id), ('is_expense', '=', False), ('state', 'in', ['sale', 'done'])]"
|
||||
domain="[('is_service', '=', True), ('order_partner_id', 'child_of', parent.partner_id), ('is_expense', '=', False), ('state', 'in', ['sale', 'done'])]"
|
||||
optional="hide"/>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='remaining_hours']" position="after">
|
||||
|
||||
Reference in New Issue
Block a user