forked from OCA/project
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[NEW] project_task_analytic_partner: New module
- Loading branch information
1 parent
6dd667b
commit e9eb085
Showing
10 changed files
with
247 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg | ||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html | ||
:alt: License: AGPL-3 | ||
|
||
========================== | ||
Partner in task work lines | ||
========================== | ||
|
||
This module adds the partner on task work lines and propagate it to the | ||
auto-generated analytic entries on the "Other partner" field. | ||
|
||
This module requires HR Timesheet to work | ||
|
||
Installation | ||
============ | ||
|
||
It requires the module *analytic_partner_hr_timesheet_invoice*, that it's | ||
hosted on https://github.com/OCA/account-analytic. | ||
|
||
Configuration | ||
============= | ||
|
||
* Go to *Settings -> Configuration -> Project -> Project Management*. | ||
* Enable *Record timesheet lines per tasks*. | ||
|
||
Usage | ||
===== | ||
|
||
Go to Project > Tasks, and you will find the partner field in work lines to set | ||
an alternative partner which be propagated to HR Timesheet | ||
|
||
|
||
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas | ||
:alt: Try me on Runbot | ||
:target: https://runbot.odoo-community.org/runbot/87/8.0 | ||
|
||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/ | ||
project/issues>`_. | ||
In case of trouble, please check there if your issue has already been reported. | ||
If you spotted it first, help us smashing it by providing a detailed and welcomed feedback `here <https://github.com/OCA/ | ||
project/issues/new?body=module:%20 | ||
project_task_analytic_partner%0Aversion:%20 | ||
8.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. | ||
|
||
Credits | ||
======= | ||
|
||
Contributors | ||
------------ | ||
* Carlos Dauden <[email protected]> | ||
* Pedro M. Baeza <[email protected]> | ||
|
||
Maintainer | ||
---------- | ||
|
||
.. image:: http://odoo-community.org/logo.png | ||
:alt: Odoo Community Association | ||
:target: http://odoo-community.org | ||
|
||
This module is maintained by the OCA. | ||
|
||
OCA, or the Odoo Community Association, is a nonprofit organization whose | ||
mission is to support the collaborative development of Odoo features and | ||
promote its widespread use. | ||
|
||
To contribute to this module, please visit http://odoo-community.org. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# -*- coding: utf-8 -*- | ||
# © 2016 Carlos Dauden <[email protected]> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
{ | ||
'name': 'Partner in task work lines', | ||
'summary': 'Select alternative partner in task work lines', | ||
'version': '8.0.1.0.0', | ||
'category': 'Project', | ||
'license': 'AGPL-3', | ||
'author': "Tecnativa, " | ||
"Odoo Community Association (OCA)", | ||
'website': 'http://www.tecnativa.com', | ||
'depends': [ | ||
'analytic_partner_hr_timesheet_invoice', | ||
'project_timesheet', | ||
], | ||
'data': [ | ||
'views/project_view.xml', | ||
], | ||
'installable': True, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * project_task_materials_analytic_partner | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 8.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2016-05-19 17:18+0000\n" | ||
"PO-Revision-Date: 2016-05-19 19:20+0100\n" | ||
"Last-Translator: Carlos Dauden <[email protected]>\n" | ||
"Language-Team: Tecnativa <[email protected]>\n" | ||
"Language: es_ES\n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: 8bit\n" | ||
"X-Generator: Poedit 1.5.4\n" | ||
"X-Poedit-SourceCharset: UTF-8\n" | ||
|
||
#. module: project_task_analytic_partner | ||
#: field:project.task,analytic_line_ids:0 | ||
msgid "Analytic Lines" | ||
msgstr "Líneas analíticas" | ||
|
||
#. module: project_task_analytic_partner | ||
#: field:project.task.work,to_invoice:0 | ||
msgid "Invoiceable" | ||
msgstr "Facturable" | ||
|
||
#. module: project_task_analytic_partner | ||
#: field:project.task.materials,other_partner_id:0 | ||
#: field:project.task.work,other_partner_id:0 | ||
msgid "Other Partner" | ||
msgstr "Empresa alternativa" | ||
|
||
#. module: project_task_analytic_partner | ||
#: model:ir.model,name:project_task_analytic_partner.model_project_task_work | ||
msgid "Project Task Work" | ||
msgstr "Trabajo tarea proyecto" | ||
|
||
#. module: project_task_analytic_partner | ||
#: model:ir.model,name:project_task_analytic_partner.model_project_task | ||
msgid "Task" | ||
msgstr "Tarea" | ||
|
||
#. module: project_task_analytic_partner | ||
#: model:ir.model,name:project_task_analytic_partner.model_project_task_materials | ||
msgid "Task Materials Used" | ||
msgstr "Materiales usados en tarea" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from . import project_task_analytic_partner |
38 changes: 38 additions & 0 deletions
38
project_task_analytic_partner/models/project_task_analytic_partner.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# -*- coding: utf-8 -*- | ||
# © 2016 Carlos Dauden <[email protected]> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from openerp import api, fields, models | ||
|
||
|
||
class TaskWork(models.Model): | ||
_inherit = 'project.task.work' | ||
|
||
to_invoice = fields.Many2one( | ||
comodel_name='hr_timesheet_invoice.factor', | ||
string='Invoiceable') | ||
other_partner_id = fields.Many2one( | ||
comodel_name='res.partner', string="Other Partner", | ||
domain="['|', ('parent_id', '=', False), ('is_company', '=', True)]") | ||
|
||
@api.multi | ||
def update_timesheet_vals(self, vals): | ||
timesheet_vals = {} | ||
if 'to_invoice' in vals: | ||
timesheet_vals['to_invoice'] = vals['to_invoice'] | ||
if 'other_partner_id' in vals: | ||
timesheet_vals['other_partner_id'] = vals['other_partner_id'] | ||
if timesheet_vals: | ||
self.hr_analytic_timesheet_id.write(timesheet_vals) | ||
|
||
@api.model | ||
def create(self, vals): | ||
res = super(TaskWork, self).create(vals) | ||
res.update_timesheet_vals(vals) | ||
return res | ||
|
||
@api.multi | ||
def write(self, vals): | ||
res = super(TaskWork, self).write(vals) | ||
self.update_timesheet_vals(vals) | ||
return res |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# -*- coding: utf-8 -*- | ||
# © 2016 Carlos Dauden <[email protected]> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from . import test_project_task_analytic_partner |
37 changes: 37 additions & 0 deletions
37
project_task_analytic_partner/tests/test_project_task_analytic_partner.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# -*- coding: utf-8 -*- | ||
# © 2016 Carlos Dauden <[email protected]> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from openerp.tests.common import TransactionCase | ||
|
||
|
||
class TestTaskAnalyticPartner(TransactionCase): | ||
def setUp(self): | ||
super(TestTaskAnalyticPartner, self).setUp() | ||
self.project = self.env.ref('project.project_project_1') | ||
self.partner1 = self.env.ref('base.res_partner_2') | ||
self.partner2 = self.env.ref('base.res_partner_12') | ||
self.task = self.env['project.task'].create( | ||
{'name': 'Task Test 1', | ||
'project_id': self.project.id}) | ||
self.factor = self.env.ref( | ||
'hr_timesheet_invoice.timesheet_invoice_factor1') | ||
|
||
def test_task_analytic_partner(self): | ||
work_line = self.env['project.task.work'].create({ | ||
'task_id': self.task.id, | ||
'name': 'Work test battery', | ||
'hours': 1, | ||
'to_invoice': self.factor.id, | ||
'other_partner_id': self.partner1.id, | ||
'user_id': self.uid, | ||
}) | ||
self.assertEqual(work_line.hr_analytic_timesheet_id.other_partner_id, | ||
self.partner1) | ||
self.assertEqual(work_line.hr_analytic_timesheet_id.to_invoice, | ||
self.factor) | ||
work_line.other_partner_id = self.partner2 | ||
self.assertEqual(work_line.hr_analytic_timesheet_id.other_partner_id, | ||
self.partner2) | ||
work_line.to_invoice = False | ||
self.assertFalse(work_line.hr_analytic_timesheet_id.to_invoice) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- © 2016 Carlos Dauden <[email protected]> | ||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl-3). --> | ||
<openerp> | ||
<data> | ||
|
||
<record id="view_project_task_form" model="ir.ui.view"> | ||
<field name="name">project.task.form.analytic.partner</field> | ||
<field name="model">project.task</field> | ||
<field name="inherit_id" ref="project.view_task_form2"/> | ||
<field name="arch" type="xml"> | ||
<xpath expr="//field[@name='work_ids']/tree/field[@name='user_id']" position="after"> | ||
<field name="to_invoice"/> | ||
<field name="other_partner_id"/> | ||
</xpath> | ||
</field> | ||
</record> | ||
|
||
</data> | ||
</openerp> |