Skip to content

Commit

Permalink
[MIG]Migrated Business Requirement Deliverable Resource Template from…
Browse files Browse the repository at this point in the history
… 8.0 to 10.0. (#236)

* [MIG]Migrated Business Requirement Deliverable Resource Template from 8.0 to 10.0.

* [IMP]Added Test-cases and Improved test-cases code

* [IMP]Improved code for demo data

* [IMP]Removed unused import statement

* [REM/ADD]Moved demo data files from data folder to demo folder
  • Loading branch information
sudhir-serpentcs authored and elicoidal committed Sep 15, 2017
1 parent 016c084 commit 4793547
Show file tree
Hide file tree
Showing 9 changed files with 123 additions and 64 deletions.
4 changes: 2 additions & 2 deletions business_requirement_deliverable_resource_template/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Business Requirement
Introduction
============

This module is part of a set of modules (`Business Requirements <https://github.com/OCA/business-requirement/blob/8.0/README.md>`_)
This module is part of a set of modules (`Business Requirements <https://github.com/OCA/business-requirement/blob/10.0/README.md>`_)

This module adds the following features particularly useful for sales package with standard resources:

Expand Down Expand Up @@ -58,7 +58,7 @@ Usage

.. figure:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/222/8.0
:target: https://runbot.odoo-community.org/runbot/222/10.0

Known issues / Roadmap
======================
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
'category': 'Business Requirements Management',
'summary': """Manage default resource lines in your
deliverable sales package from product template""",
'version': '8.0.1.0.1',
'version': '10.0.1.0.0',
'website': 'https://www.elico-corp.com/',
"author": "Elico Corp, Odoo Community Association (OCA)",
'depends': [
Expand All @@ -22,8 +22,8 @@
"views/business_requirement_deliverable_default.xml",
],
'demo': [
'data/business_requirement_deliverable_resource_template_demo.xml'
'demo/business_requirement_deliverable_resource_template_demo.xml'
],
'license': 'AGPL-3',
'installable': False,
'installable': True,
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<odoo>
<data noupdate="1">

<record id="resource_template_01"
Expand All @@ -9,9 +9,9 @@
<field name="qty">1</field>
<field name="uom_id" ref="product.product_uom_hour"/>
<field name="product_id"
ref="business_requirement.product_product_1"/>
ref="business_requirement_deliverable.product_product_1"/>
<field name="product_template_id"
ref="business_requirement.product_template_1"/>
ref="business_requirement_deliverable.product_template_1"/>
</record>
<record id="resource_template_02"
model="business.requirement.resource.template">
Expand All @@ -20,9 +20,9 @@
<field name="qty">1</field>
<field name="uom_id" ref="product.product_uom_hour"/>
<field name="product_id"
ref="business_requirement.product_product_2"/>
ref="business_requirement_deliverable.product_product_2"/>
<field name="product_template_id"
ref="business_requirement.product_template_2"/>
ref="business_requirement_deliverable.product_template_2"/>
</record>
<record id="resource_template_03"
model="business.requirement.resource.template">
Expand All @@ -31,9 +31,9 @@
<field name="qty">1</field>
<field name="uom_id" ref="product.product_uom_hour"/>
<field name="product_id"
ref="business_requirement.product_product_3"/>
ref="business_requirement_deliverable.product_product_3"/>
<field name="product_template_id"
ref="business_requirement.product_template_3"/>
ref="business_requirement_deliverable.product_template_3"/>
</record>
<record id="resource_template_04"
model="business.requirement.resource.template">
Expand All @@ -44,7 +44,7 @@
<field name="product_id"
ref="product.product_product_8"/>
<field name="product_template_id"
ref="business_requirement.product_template_5"/>
ref="business_requirement_deliverable.product_template_5"/>
</record>
<record id="resource_template_05"
model="business.requirement.resource.template">
Expand All @@ -53,9 +53,9 @@
<field name="qty">1</field>
<field name="uom_id" ref="product.product_uom_unit"/>
<field name="product_id"
ref="business_requirement.product_product_4"/>
ref="business_requirement_deliverable.product_product_4"/>
<field name="product_template_id"
ref="business_requirement.product_template_5"/>
ref="business_requirement_deliverable.product_template_5"/>
</record>
<record id="resource_template_06"
model="business.requirement.resource.template">
Expand All @@ -64,9 +64,9 @@
<field name="qty">3</field>
<field name="uom_id" ref="product.product_uom_day"/>
<field name="product_id"
ref="business_requirement.product_product_2"/>
ref="business_requirement_deliverable.product_product_2"/>
<field name="product_template_id"
ref="business_requirement.product_template_5"/>
ref="business_requirement_deliverable.product_template_5"/>
</record>
<record id="resource_template_07"
model="business.requirement.resource.template">
Expand All @@ -75,9 +75,9 @@
<field name="qty">7</field>
<field name="uom_id" ref="product.product_uom_day"/>
<field name="product_id"
ref="business_requirement.product_product_1"/>
ref="business_requirement_deliverable.product_product_1"/>
<field name="product_template_id"
ref="business_requirement.product_template_5"/>
ref="business_requirement_deliverable.product_template_5"/>
</record>
<record id="resource_template_08"
model="business.requirement.resource.template">
Expand All @@ -86,9 +86,9 @@
<field name="qty">24</field>
<field name="uom_id" ref="product.product_uom_hour"/>
<field name="product_id"
ref="business_requirement.product_product_3"/>
ref="business_requirement_deliverable.product_product_3"/>
<field name="product_template_id"
ref="business_requirement.product_template_6"/>
ref="business_requirement_deliverable.product_template_6"/>
</record>
<record id="resource_template_09"
model="business.requirement.resource.template">
Expand All @@ -97,10 +97,10 @@
<field name="qty">32</field>
<field name="uom_id" ref="product.product_uom_hour"/>
<field name="product_id"
ref="business_requirement.product_product_1"/>
ref="business_requirement_deliverable.product_product_1"/>
<field name="product_template_id"
ref="business_requirement.product_template_6"/>
ref="business_requirement_deliverable.product_template_6"/>
</record>

</data>
</openerp>
</odoo>
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# -*- coding: utf-8 -*-
# © 2017 Elico Corp (https://www.elico-corp.com).
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from openerp import api, fields, models
from openerp.exceptions import ValidationError
from openerp.tools.translate import _
from odoo import api, fields, models, _
from odoo.exceptions import ValidationError


class BusinessRequirementDeliverable(models.Model):
Expand All @@ -12,11 +11,12 @@ class BusinessRequirementDeliverable(models.Model):
def _prepare_resource_lines(self):
rl_data = self.env['business.requirement.resource.template'].search(
[('product_template_id', '=', self.product_id.product_tmpl_id.id)],
order='sequence'
).copy_data()
return [(0, 0, item) for index, item in enumerate(rl_data)]
order='sequence')
data = []
for rec in rl_data:
data.append(rec.copy_data()[0])
return [(0, 0, item) for index, item in enumerate(data)]

@api.multi
@api.onchange('product_id')
def product_id_change(self):
super(BusinessRequirementDeliverable, self).product_id_change()
Expand Down Expand Up @@ -62,7 +62,6 @@ class BusinessRequirementResourceTemplate(models.Model):
default='task'
)

@api.multi
@api.onchange('product_id')
def product_id_change(self):
description = ''
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
# © 2017 Elico Corp (https://www.elico-corp.com).
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from openerp import fields, models
from odoo import fields, models


class ProductTemplate(models.Model):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
# © 2016 Elico Corp (https://www.elico-corp.com).
# © 2017 Elico Corp (https://www.elico-corp.com).
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import test_br_resource_template
from . import test_br_deliverable
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# -*- coding: utf-8 -*-
# © 2017 Elico Corp (https://www.elico-corp.com).
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo.tests import common


class BusinessRequirementDeliverable(common.TransactionCase):
def setUp(self):
super(BusinessRequirementDeliverable, self).setUp()
self.categ_wtime = self.env.ref('product.uom_categ_wtime')
self.categ_kgm = self.env.ref('product.product_uom_categ_kgm')

self.UomObj = self.env['product.uom']
self.uom_hours = self.UomObj.create({
'name': 'Test-Hours',
'category_id': self.categ_wtime.id,
'factor': 8,
'uom_type': 'smaller'})
self.uom_kg = self.UomObj.create({
'name': 'Test-KG',
'category_id': self.categ_kgm.id,
'factor_inv': 1,
'factor': 1,
'uom_type': 'reference',
'rounding': 0.000001})
self.ProductS = self.env.ref('product.service_order_01')
vals = {
'description': ' test',
'deliverable_lines': [
(0, 0, {'name': 'deliverable line1', 'qty': 1.0,
'product_id': self.ProductS.id,
'sale_price_unit': 900, 'uom_id': 1}),
(0, 0, {'name': 'deliverable line2', 'qty': 1.0,
'sale_price_unit': 1100, 'uom_id': 1}),
(0, 0, {'name': 'deliverable line3', 'qty': 1.0,
'sale_price_unit': 1300, 'uom_id': 1}),
(0, 0, {'name': 'deliverable line4', 'qty': 1.0,
'sale_price_unit': 1500, 'uom_id': 1,
}),
]
}
self.br = self.env['business.requirement'].create(vals)
self.BRTemplate = self.env['business.requirement.resource.template']

def test_product_id_change(self):
for dl in self.br.deliverable_lines:
dl.product_id_change()

def test_prepare_resource_lines(self):
self.BRT = self.BRTemplate.create({
'name': 'BR Template',
'product_template_id': self.ProductS.product_tmpl_id.id,
'uom_id': self.uom_hours.id,
'resource_type': 'task'
})
for dl in self.br.deliverable_lines:
dl._prepare_resource_lines()
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# -*- coding: utf-8 -*-
# © 2016 Elico Corp (https://www.elico-corp.com).
# © 2017 Elico Corp (https://www.elico-corp.com).
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from openerp.tests import common
from openerp.exceptions import ValidationError
from odoo.tests import common
from odoo.exceptions import ValidationError


class BusinessRequirementResourceTemplate(common.TransactionCase):
Expand All @@ -24,7 +24,7 @@ def setUp(self):
'factor': 1,
'uom_type': 'reference',
'rounding': 0.000001})
self.ProductS = self.env.ref('product.product_product_consultant')
self.ProductS = self.env.ref('product.service_order_01')
self.ProductObj = self.env['product.template']
self.productA = self.ProductObj.create({
'name': 'Product A',
Expand All @@ -37,9 +37,11 @@ def setUp(self):
'resource_type': 'task'
})]})

def test_product_id_onchnage(self):
def test_product_id_change(self):
for resource in self.productA.resource_lines:
resource.product_id_change()
description = self.ProductS.name_get()[0][1]
self.assertEqual(resource.name, description)

def test_resource_uom_change(self):
for line in self.productA:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="product_template_only_form_view" model="ir.ui.view">
<field name="name">product.template.form</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="product.product_template_only_form_view"/>
<field name="arch" type="xml">
<page name="variants" position='after'>
<page name="resources"
string="Default Resource Template Lines">
<field name="resource_lines">
<tree editable="top" default_order="sequence">
<field name="sequence" widget="handle"/>
<field name="resource_type"/>
<field name="product_id"/>
<field name="name"/>
<field name="qty"/>
<field name="uom_id"/>
</tree>
</field>
</page>
<odoo>

<record id="product_template_only_form_view" model="ir.ui.view">
<field name="name">product.template.form</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="product.product_template_only_form_view"/>
<field name="arch" type="xml">
<page name="variants" position='after'>
<page name="resources"
string="Default Resource Template Lines">
<field name="resource_lines">
<tree editable="top" default_order="sequence">
<field name="sequence" widget="handle"/>
<field name="resource_type"/>
<field name="product_id"/>
<field name="name"/>
<field name="qty"/>
<field name="uom_id"/>
</tree>
</field>
</page>
</field>
</record>
</data>
</openerp>
</page>
</field>
</record>

</odoo>

0 comments on commit 4793547

Please sign in to comment.