summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorjem-odoo <jem@openerp.com>2018-08-02 17:26:25 +0200
committerjem-odoo <jem@openerp.com>2018-08-13 14:39:50 +0200
commit8db463d124a04f4264862a5cfd78c612064c8a34 (patch)
treefb28fde98824cb5179737f122ae3ffec60592218 /addons
parent71bf212a2131ee582c36b604e1ad520ab3ce4c2a (diff)
[MOV] analytic: move uom field from account to analytic
Diffstat (limited to 'addons')
-rw-r--r--addons/account/models/account_analytic_line.py1
-rw-r--r--addons/account/views/account_analytic_view.xml3
-rw-r--r--addons/analytic/__manifest__.py2
-rw-r--r--addons/analytic/models/analytic_account.py1
-rw-r--r--addons/analytic/views/analytic_account_views.xml1
-rw-r--r--addons/hr_timesheet/models/hr_timesheet.py4
-rw-r--r--addons/sale_timesheet/models/account.py17
7 files changed, 8 insertions, 21 deletions
diff --git a/addons/account/models/account_analytic_line.py b/addons/account/models/account_analytic_line.py
index 4e610fd6dcf..85156bcaf48 100644
--- a/addons/account/models/account_analytic_line.py
+++ b/addons/account/models/account_analytic_line.py
@@ -9,7 +9,6 @@ class AccountAnalyticLine(models.Model):
_description = 'Analytic Line'
_order = 'date desc'
- product_uom_id = fields.Many2one('uom.uom', string='Unit of Measure')
product_id = fields.Many2one('product.product', string='Product')
general_account_id = fields.Many2one('account.account', string='Financial Account', ondelete='restrict', readonly=True,
related='move_id.account_id', store=True, domain=[('deprecated', '=', False)],
diff --git a/addons/account/views/account_analytic_view.xml b/addons/account/views/account_analytic_view.xml
index 7874cd2a094..e3d0dddcf7e 100644
--- a/addons/account/views/account_analytic_view.xml
+++ b/addons/account/views/account_analytic_view.xml
@@ -11,9 +11,8 @@
<field name="ref"/>
<field name="partner_id"/>
</xpath>
- <xpath expr="//field[@name='amount']" position="after">
+ <xpath expr="//field[@name='product_uom_id']" position="before">
<field name="product_id"/>
- <field name="product_uom_id" class="oe_inline"/>
</xpath>
<group name="amount" position="after">
<group/> <!-- put Accounting group under Amount group -->
diff --git a/addons/analytic/__manifest__.py b/addons/analytic/__manifest__.py
index ffadeae54a8..47815af682e 100644
--- a/addons/analytic/__manifest__.py
+++ b/addons/analytic/__manifest__.py
@@ -5,7 +5,7 @@
'name' : 'Analytic Accounting',
'version': '1.1',
'category': 'Hidden/Dependency',
- 'depends' : ['base', 'decimal_precision', 'mail'],
+ 'depends' : ['base', 'decimal_precision', 'mail', 'uom'],
'description': """
Module for defining analytic accounting object.
===============================================
diff --git a/addons/analytic/models/analytic_account.py b/addons/analytic/models/analytic_account.py
index b84046ab9fe..5f488b786ae 100644
--- a/addons/analytic/models/analytic_account.py
+++ b/addons/analytic/models/analytic_account.py
@@ -177,6 +177,7 @@ class AccountAnalyticLine(models.Model):
date = fields.Date('Date', required=True, index=True, default=fields.Date.context_today)
amount = fields.Monetary('Amount', required=True, default=0.0)
unit_amount = fields.Float('Quantity', default=0.0)
+ product_uom_id = fields.Many2one('uom.uom', string='Unit of Measure')
account_id = fields.Many2one('account.analytic.account', 'Analytic Account', required=True, ondelete='restrict', index=True)
partner_id = fields.Many2one('res.partner', string='Partner')
user_id = fields.Many2one('res.users', string='User', default=_default_user)
diff --git a/addons/analytic/views/analytic_account_views.xml b/addons/analytic/views/analytic_account_views.xml
index 095146e3124..ce4f8b11435 100644
--- a/addons/analytic/views/analytic_account_views.xml
+++ b/addons/analytic/views/analytic_account_views.xml
@@ -289,6 +289,7 @@
<group name="amount" string="Amount">
<field name="amount"/>
<field name="unit_amount"/>
+ <field name="product_uom_id" class="oe_inline"/>
<field name="currency_id" invisible="1"/>
</group>
</group>
diff --git a/addons/hr_timesheet/models/hr_timesheet.py b/addons/hr_timesheet/models/hr_timesheet.py
index f46a5464015..aac3e474862 100644
--- a/addons/hr_timesheet/models/hr_timesheet.py
+++ b/addons/hr_timesheet/models/hr_timesheet.py
@@ -95,6 +95,10 @@ class AccountAnalyticLine(models.Model):
partner_id = self.env['project.project'].browse(vals['project_id']).partner_id.id
if partner_id:
vals['partner_id'] = partner_id
+ # set timesheet UoM from the employee company (employee implies uom)
+ if 'product_uom_id' not in vals and all([v in vals for v in ['employee_id', 'project_id']]): # project_id required to check this is timesheet flow
+ employee = self.env['hr.employee'].sudo().browse(vals['employee_id'])
+ vals['product_uom_id'] = employee.company_id.project_time_mode_id.id
return vals
@api.multi
diff --git a/addons/sale_timesheet/models/account.py b/addons/sale_timesheet/models/account.py
index 074038db697..55a7f83c339 100644
--- a/addons/sale_timesheet/models/account.py
+++ b/addons/sale_timesheet/models/account.py
@@ -52,21 +52,4 @@ class AccountAnalyticLine(models.Model):
if 'task_id' in values:
task = self.env['project.task'].sudo().browse(values['task_id'])
values['so_line'] = task.sale_line_id.id or values.get('so_line', False)
-
- # Set product_uom_id now so delivered qty is computed in SO line
- if not 'product_uom_id' in values and all([v in values for v in ['employee_id', 'project_id']]):
- employee = self.env['hr.employee'].sudo().browse(values['employee_id'])
- values['product_uom_id'] = employee.company_id.project_time_mode_id.id
return values
-
- @api.multi
- def _timesheet_postprocess_values(self, values):
- result = super(AccountAnalyticLine, self)._timesheet_postprocess_values(values)
- # (re)compute the UoM from the employee company
- if any([field_name in values for field_name in ['employee_id']]):
- for timesheet in self:
- uom = timesheet.employee_id.company_id.project_time_mode_id
- result[timesheet.id].update({
- 'product_uom_id': uom.id,
- })
- return result