diff --git a/addons/sale/models/analytic.py b/addons/sale/models/analytic.py
index fc0c25a3a11..cde205d5a98 100644
--- a/addons/sale/models/analytic.py
+++ b/addons/sale/models/analytic.py
@@ -106,9 +106,9 @@ class AccountAnalyticLine(models.Model):
"""
for analytic_line in self.sudo().filtered(lambda aal: not aal.so_line and aal.account_id and aal.product_id and aal.product_id.expense_policy != 'no'):
# determine SO : first SO open linked to AA
- sale_order = self.env['sale.order'].search([('project_id', '=', analytic_line.account_id.id), ('state', '=', 'sale')], limit=1)
+ sale_order = self.env['sale.order'].search([('analytic_account_id', '=', analytic_line.account_id.id), ('state', '=', 'sale')], limit=1)
if not sale_order:
- sale_order = self.env['sale.order'].search([('project_id', '=', analytic_line.account_id.id)], limit=1)
+ sale_order = self.env['sale.order'].search([('analytic_account_id', '=', analytic_line.account_id.id)], limit=1)
if not sale_order:
continue
diff --git a/addons/sale/models/sale.py b/addons/sale/models/sale.py
index 04a7fee45ad..31d6e2053e4 100644
--- a/addons/sale/models/sale.py
+++ b/addons/sale/models/sale.py
@@ -135,7 +135,7 @@ class SaleOrder(models.Model):
pricelist_id = fields.Many2one('product.pricelist', string='Pricelist', required=True, readonly=True, states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}, help="Pricelist for current sales order.")
currency_id = fields.Many2one("res.currency", related='pricelist_id.currency_id', string="Currency", readonly=True, required=True)
- project_id = fields.Many2one('account.analytic.account', 'Analytic Account', readonly=True, states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}, help="The analytic account related to a sales order.", copy=False)
+ analytic_account_id = fields.Many2one('account.analytic.account', 'Analytic Account', readonly=True, states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}, help="The analytic account related to a sales order.", copy=False, oldname='project_id')
order_line = fields.One2many('sale.order.line', 'order_id', string='Order Lines', states={'cancel': [('readonly', True)], 'done': [('readonly', True)]}, copy=True, auto_join=True)
@@ -509,7 +509,7 @@ class SaleOrder(models.Model):
'company_id': order.company_id.id,
'partner_id': order.partner_id.id
})
- order.project_id = analytic
+ order.analytic_account_id = analytic
@api.multi
def order_lines_layouted(self):
@@ -891,7 +891,7 @@ class SaleOrderLine(models.Model):
'product_id': self.product_id.id or False,
'layout_category_id': self.layout_category_id and self.layout_category_id.id or False,
'invoice_line_tax_ids': [(6, 0, self.tax_id.ids)],
- 'account_analytic_id': self.order_id.project_id.id,
+ 'account_analytic_id': self.order_id.analytic_account_id.id,
'analytic_tag_ids': [(6, 0, self.analytic_tag_ids.ids)],
}
return res
diff --git a/addons/sale/report/report_all_channels_sales.py b/addons/sale/report/report_all_channels_sales.py
index ed0219e2e0d..5e1f9eca28b 100644
--- a/addons/sale/report/report_all_channels_sales.py
+++ b/addons/sale/report/report_all_channels_sales.py
@@ -42,7 +42,7 @@ class PosSaleReport(models.Model):
rp.country_id AS country_id,
sol.price_subtotal / COALESCE (cr.rate, 1.0) AS price_subtotal,
(sol.product_uom_qty / u.factor * u2.factor) as product_qty,
- so.project_id AS analytic_account_id,
+ so.analytic_account_id AS analytic_account_id,
so.team_id AS team_id
FROM sale_order_line sol
diff --git a/addons/sale/report/sale_report.py b/addons/sale/report/sale_report.py
index 3e9905ec85b..42c6953f4dc 100644
--- a/addons/sale/report/sale_report.py
+++ b/addons/sale/report/sale_report.py
@@ -71,7 +71,7 @@ class SaleReport(models.Model):
extract(epoch from avg(date_trunc('day',s.date_order)-date_trunc('day',s.create_date)))/(24*60*60)::decimal(16,2) as delay,
t.categ_id as categ_id,
s.pricelist_id as pricelist_id,
- s.project_id as analytic_account_id,
+ s.analytic_account_id as analytic_account_id,
s.team_id as team_id,
p.product_tmpl_id,
partner.country_id as country_id,
@@ -112,7 +112,7 @@ class SaleReport(models.Model):
s.state,
s.company_id,
s.pricelist_id,
- s.project_id,
+ s.analytic_account_id,
s.team_id,
p.product_tmpl_id,
partner.country_id,
diff --git a/addons/sale/tests/test_sale_order.py b/addons/sale/tests/test_sale_order.py
index 2b6c082b150..e0892afed10 100644
--- a/addons/sale/tests/test_sale_order.py
+++ b/addons/sale/tests/test_sale_order.py
@@ -127,7 +127,7 @@ class TestSaleOrder(TestSale):
'name': '',
'type': 'in_invoice',
'partner_id': inv_partner.id,
- 'invoice_line_ids': [(0, 0, {'name': serv_cost.name, 'product_id': serv_cost.id, 'quantity': 2, 'uom_id': serv_cost.uom_id.id, 'price_unit': serv_cost.standard_price, 'account_analytic_id': so.project_id.id, 'account_id': account_income.id})],
+ 'invoice_line_ids': [(0, 0, {'name': serv_cost.name, 'product_id': serv_cost.id, 'quantity': 2, 'uom_id': serv_cost.uom_id.id, 'price_unit': serv_cost.standard_price, 'account_analytic_id': so.analytic_account_id.id, 'account_id': account_income.id})],
'account_id': account_payable.id,
'journal_id': journal.id,
'currency_id': company.currency_id.id,
diff --git a/addons/sale/views/sale_views.xml b/addons/sale/views/sale_views.xml
index 3f858a7ae1d..576c37b923f 100644
--- a/addons/sale/views/sale_views.xml
+++ b/addons/sale/views/sale_views.xml
@@ -383,7 +383,7 @@
-
+
@@ -429,7 +429,7 @@
-
+
diff --git a/addons/sale/wizard/sale_make_invoice_advance.py b/addons/sale/wizard/sale_make_invoice_advance.py
index 01cf2225a95..838f038d9bc 100644
--- a/addons/sale/wizard/sale_make_invoice_advance.py
+++ b/addons/sale/wizard/sale_make_invoice_advance.py
@@ -107,7 +107,7 @@ class SaleAdvancePaymentInv(models.TransientModel):
'product_id': self.product_id.id,
'sale_line_ids': [(6, 0, [so_line.id])],
'invoice_line_tax_ids': [(6, 0, tax_ids)],
- 'account_analytic_id': order.project_id.id or False,
+ 'account_analytic_id': order.analytic_account_id.id or False,
})],
'currency_id': order.pricelist_id.currency_id.id,
'payment_term_id': order.payment_term_id.id,
diff --git a/addons/sale_expense/tests/test_sale_expense.py b/addons/sale_expense/tests/test_sale_expense.py
index 91a094bf901..1fd00aa2a68 100644
--- a/addons/sale_expense/tests/test_sale_expense.py
+++ b/addons/sale_expense/tests/test_sale_expense.py
@@ -40,7 +40,7 @@ class TestSaleExpense(TestSale):
exp = self.env['hr.expense'].create({
'name': 'Air Travel',
'product_id': prod_exp_1.id,
- 'analytic_account_id': so.project_id.id,
+ 'analytic_account_id': so.analytic_account_id.id,
'unit_amount': 621.54,
'employee_id': employee.id,
'sheet_id': sheet.id
@@ -67,7 +67,7 @@ class TestSaleExpense(TestSale):
exp = self.env['hr.expense'].create({
'name': 'Car Travel',
'product_id': prod_exp_2.id,
- 'analytic_account_id': so.project_id.id,
+ 'analytic_account_id': so.analytic_account_id.id,
'product_uom_id': self.env.ref('product.product_uom_km').id,
'unit_amount': 0.15,
'quantity': 100,
diff --git a/addons/sale_timesheet/models/account.py b/addons/sale_timesheet/models/account.py
index 4ac5a9faab8..064559515cd 100644
--- a/addons/sale_timesheet/models/account.py
+++ b/addons/sale_timesheet/models/account.py
@@ -57,7 +57,7 @@ class AccountAnalyticLine(models.Model):
"""
for timesheet in self.filtered(lambda aal: not aal.so_line):
sol = self.env['sale.order.line'].search([
- ('order_id.project_id', '=', timesheet.account_id.id),
+ ('order_id.analytic_account_id', '=', timesheet.account_id.id),
('state', 'in', ('sale', 'done')),
('product_id.track_service', '=', 'timesheet'),
('product_id.type', '=', 'service')
diff --git a/addons/sale_timesheet/models/sale_order.py b/addons/sale_timesheet/models/sale_order.py
index da90a057137..92e154f7d78 100644
--- a/addons/sale_timesheet/models/sale_order.py
+++ b/addons/sale_timesheet/models/sale_order.py
@@ -19,10 +19,10 @@ class SaleOrder(models.Model):
project_project_id = fields.Many2one('project.project', compute='_compute_project_project_id', string='Project associated to this sale')
@api.multi
- @api.depends('project_id.line_ids')
+ @api.depends('analytic_account_id.line_ids')
def _compute_timesheet_ids(self):
for order in self:
- if order.project_id:
+ if order.analytic_account_id:
order.timesheet_ids = self.env['account.analytic.line'].search(
[('so_line', 'in', order.order_line.ids),
('amount', '<=', 0.0),
@@ -39,10 +39,10 @@ class SaleOrder(models.Model):
order.tasks_count = len(order.tasks_ids)
@api.multi
- @api.depends('project_id.project_ids')
+ @api.depends('analytic_account_id.project_ids')
def _compute_project_project_id(self):
for order in self:
- order.project_project_id = self.env['project.project'].search([('analytic_account_id', '=', order.project_id.id)])
+ order.project_project_id = self.env['project.project'].search([('analytic_account_id', '=', order.analytic_account_id.id)])
@api.multi
@api.constrains('order_line')
@@ -175,10 +175,10 @@ class SaleOrderLine(models.Model):
project = self.product_id.with_context(force_company=self.company_id.id).project_id
if not project:
# find the project corresponding to the analytic account of the sales order
- account = self.order_id.project_id
+ account = self.order_id.analytic_account_id
if not account:
self.order_id._create_analytic_account(prefix=self.product_id.default_code or None)
- account = self.order_id.project_id
+ account = self.order_id.analytic_account_id
project = Project.search([('analytic_account_id', '=', account.id)], limit=1)
if not project:
project_id = account.sudo().project_create({'name': account.name})