Skip to content

Commit

Permalink
Merge 285cab1 into f056ddf
Browse files Browse the repository at this point in the history
  • Loading branch information
ddico committed Jan 29, 2016
2 parents f056ddf + 285cab1 commit 6fed4d4
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 4 deletions.
7 changes: 4 additions & 3 deletions mrp_production_real_cost/README.rst
Expand Up @@ -26,14 +26,15 @@ https://github.com/OCA/product-variant
Usage
=====

Operating with a manufacture order, analytic entries adding costs will be
Processing a manufacture order, analytic entries adding costs will be
created when:

* Some raw material is consumed.
* A work order is finished or paused.
* Also, together with *project_timesheet* module, users time is also translated
to costs in the linked analytic account.

Also, thanks to *project_timesheet* modules, users time is also translated to
costs in the linked analytic account.
The sum of all these analytic entries is the real cost.



Expand Down
3 changes: 2 additions & 1 deletion mrp_project/__openerp__.py
Expand Up @@ -22,7 +22,8 @@
"views/mrp_production_view.xml",
"views/project_project_view.xml",
"views/account_analytic_line_view.xml",
"views/project_task_view.xml"
"views/project_task_view.xml",
"views/hr_analytic_timesheet.xml"
],
'installable': True,
'auto_install': False,
Expand Down
1 change: 1 addition & 0 deletions mrp_project/models/__init__.py
Expand Up @@ -8,3 +8,4 @@
from . import project_project
from . import project_task
from . import project_task_work
from . import hr_analytic_timesheet
16 changes: 16 additions & 0 deletions mrp_project/models/hr_analytic_timesheet.py
@@ -0,0 +1,16 @@
# -*- coding: utf-8 -*-
# (c) 2016 Daniel Dico <dd@oerp.ca>
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html

from openerp import models, api


class HrAnalyticTimesheet(models.Model):
_inherit = "hr.analytic.timesheet"

@api.model
def create(self, vals):
production = self._context.get('production', False)
vals['mrp_production_id'] = vals.get('mrp_production_id', False) or \
production and production.id
return super(HrAnalyticTimesheet, self).create(vals)
5 changes: 5 additions & 0 deletions mrp_project/models/mrp_production.py
Expand Up @@ -91,3 +91,8 @@ class MrpProductionWorkcenterLine(models.Model):
work_ids = fields.One2many(
comodel_name="project.task.work", inverse_name="workorder",
string="Task works")

@api.multi
def write(self, vals, update=True):
return super(MrpProductionWorkcenterLine, self.with_context(
production=self.production_id)).write(vals)
5 changes: 5 additions & 0 deletions mrp_project/models/project_task.py
Expand Up @@ -29,3 +29,8 @@ def name_get(self):
(task.id, "[%s] %s" % (task.user_id.name, task.name)))
return res
return super(ProjectTask, self).name_get()

@api.multi
def write(self, vals):
return super(ProjectTask, self.with_context(
production=self.mrp_production_id)).write(vals)
17 changes: 17 additions & 0 deletions mrp_project/views/hr_analytic_timesheet.xml
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>

<record id="hr_timesheet_line_tree_mrp" model="ir.ui.view">
<field name="name">hr.analytic.timesheet.tree.mrp</field>
<field name="model">hr.analytic.timesheet</field>
<field name="inherit_id" ref="hr_timesheet.hr_timesheet_line_tree"/>
<field name="arch" type="xml">
<field name="account_id" position="after">
<field name="mrp_production_id" domain="[('analytic_account_id','=',account_id)]" options="{'no_open': True, 'no_create': True}"/>
</field>
</field>
</record>

</data>
</openerp>

0 comments on commit 6fed4d4

Please sign in to comment.