bemade_fsm: Further testing for equipment, site contacts, work order contacts (integration testing). re #37.
This commit is contained in:
parent
31528dbdc6
commit
e1268d2fda
7 changed files with 132 additions and 12 deletions
|
|
@ -44,6 +44,7 @@
|
||||||
'views/res_partner.xml',
|
'views/res_partner.xml',
|
||||||
'views/menus.xml',
|
'views/menus.xml',
|
||||||
'views/task_views.xml',
|
'views/task_views.xml',
|
||||||
|
'views/sale_order_views.xml',
|
||||||
],
|
],
|
||||||
'assets': {
|
'assets': {
|
||||||
'web.assets_tests': [
|
'web.assets_tests': [
|
||||||
|
|
|
||||||
|
|
@ -41,13 +41,16 @@ class Equipment(models.Model):
|
||||||
partner_id = fields.Many2one('res.partner',
|
partner_id = fields.Many2one('res.partner',
|
||||||
string="Owner",
|
string="Owner",
|
||||||
compute="_compute_partner",
|
compute="_compute_partner",
|
||||||
search="_search_partner", )
|
search="_search_partner",)
|
||||||
|
|
||||||
description = fields.Text(string="Description",
|
description = fields.Text(string="Description",
|
||||||
tracking=True)
|
tracking=True)
|
||||||
|
|
||||||
partner_location_id = fields.Many2one('res.partner',
|
partner_location_id = fields.Many2one('res.partner',
|
||||||
string="Physical Address",
|
string="Physical Address",
|
||||||
tracking=True, )
|
tracking=True,
|
||||||
|
required=True,
|
||||||
|
ondelete='cascade')
|
||||||
|
|
||||||
location_notes = fields.Text(string="Physical Location Notes",
|
location_notes = fields.Text(string="Physical Location Notes",
|
||||||
tracking=True)
|
tracking=True)
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,12 @@ class SaleOrder(models.Model):
|
||||||
string='Work Order Recipients',
|
string='Work Order Recipients',
|
||||||
store=True)
|
store=True)
|
||||||
|
|
||||||
|
equipment_ids = fields.Many2many(comodel_name='bemade_fsm.equipment',
|
||||||
|
compute='_compute_equipment',
|
||||||
|
inverse='_inverse_equipment',
|
||||||
|
string='Equipment to Service',
|
||||||
|
store=True)
|
||||||
|
|
||||||
@api.depends('partner_id')
|
@api.depends('partner_id')
|
||||||
def _compute_default_contacts(self):
|
def _compute_default_contacts(self):
|
||||||
for rec in self:
|
for rec in self:
|
||||||
|
|
@ -27,6 +33,14 @@ class SaleOrder(models.Model):
|
||||||
def _inverse_default_contacts(self):
|
def _inverse_default_contacts(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@api.depends('partner_id')
|
||||||
|
def _compute_equipment(self):
|
||||||
|
for rec in self:
|
||||||
|
rec.equipment_ids = self.partner_id.equipment_ids if len(self.partner_id.equipment_ids) <= 1 else False
|
||||||
|
|
||||||
|
def _inverse_equipment(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class SaleOrderLine(models.Model):
|
class SaleOrderLine(models.Model):
|
||||||
_inherit = 'sale.order.line'
|
_inherit = 'sale.order.line'
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,11 @@
|
||||||
/** @odoo-module **/
|
/** @odoo-module **/
|
||||||
|
|
||||||
import tour from 'web_tour.tour';
|
import tour from 'web_tour.tour';
|
||||||
|
|
||||||
const TEST_COMPANY = "Test Partner Company";
|
const TEST_COMPANY = "Test Partner Company";
|
||||||
const TEST_EQPT1 = "Test Equipment 1";
|
const TEST_EQPT1 = "Test Equipment 1";
|
||||||
const TEST_EQPT2 = "Test Equipment 2";
|
const TEST_EQPT2 = "Test Equipment 2";
|
||||||
tour.register('task_equipment_tour', {
|
tour.register('equipment_base_tour', {
|
||||||
test: true,
|
test: true,
|
||||||
url: '/web',
|
url: '/web',
|
||||||
}, /* Create a new "Test Equipment" and link it to "Test Partner Company" */
|
}, /* Create a new "Test Equipment" and link it to "Test Partner Company" */
|
||||||
|
|
@ -66,10 +67,40 @@ tour.register('task_equipment_tour', {
|
||||||
content: 'Make sure we have a first test equipment',
|
content: 'Make sure we have a first test equipment',
|
||||||
/*trigger: `div[name="equipment_ids"]:has(td:contains(${TEST_EQPT1}))`,*/
|
/*trigger: `div[name="equipment_ids"]:has(td:contains(${TEST_EQPT1}))`,*/
|
||||||
trigger: `td:contains(${TEST_EQPT1})`,
|
trigger: `td:contains(${TEST_EQPT1})`,
|
||||||
run: function() {},
|
run: function () {
|
||||||
|
},
|
||||||
}, {
|
}, {
|
||||||
content: 'Make sure we have a second test equipment',
|
content: 'Make sure we have a second test equipment',
|
||||||
trigger: `div[name="equipment_ids"]:has(td:contains(${TEST_EQPT2}))`,
|
trigger: `div[name="equipment_ids"]:has(td:contains(${TEST_EQPT2}))`,
|
||||||
run: function() {},
|
run: function () {
|
||||||
|
},
|
||||||
}
|
}
|
||||||
])
|
]);
|
||||||
|
|
||||||
|
tour.register('equipment_sale_order_tour', {
|
||||||
|
test: true,
|
||||||
|
url: '/web',
|
||||||
|
}, [tour.stepUtils.showAppsMenuItem(), {
|
||||||
|
content: 'Navigate to the Sales menu',
|
||||||
|
trigger: '.o_app[data-menu-xmlid="sale.sale_menu_root"]',
|
||||||
|
}, {
|
||||||
|
content: 'Create an order',
|
||||||
|
trigger: 'button.o_list_button_add',
|
||||||
|
}, {
|
||||||
|
content: 'Select the test partner',
|
||||||
|
trigger: 'div[name="partner_id"] input',
|
||||||
|
run: `text ${TEST_COMPANY}`,
|
||||||
|
}, {
|
||||||
|
content: 'Click the partner in the dropdown',
|
||||||
|
trigger: `li a.dropdown-item:contains(${TEST_COMPANY})`,
|
||||||
|
}, {
|
||||||
|
content: 'Save',
|
||||||
|
trigger: 'button.o_form_button_save',
|
||||||
|
}, {
|
||||||
|
content: 'Navigate to the Field Service tab.',
|
||||||
|
trigger: 'a.nav-link[role="tab"]:contains(Field Service)'
|
||||||
|
}, {
|
||||||
|
content: 'Check that default equipment shows up.',
|
||||||
|
trigger: `tr:has(label.o_form_label:contains(Site Equipment)) td.o_field_cell:contains(${TEST_EQPT1})`
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
from odoo.tests.common import HttpCase, tagged
|
from odoo.tests.common import HttpCase, tagged
|
||||||
from .test_bemade_fsm_common import FSMManagerUserTransactionCase
|
from .test_bemade_fsm_common import FSMManagerUserTransactionCase
|
||||||
|
from odoo import Command
|
||||||
|
from odoo.exceptions import MissingError
|
||||||
|
|
||||||
|
|
||||||
@tagged("-at_install", "post_install")
|
@tagged("-at_install", "post_install")
|
||||||
|
|
@ -32,8 +34,24 @@ class TestEquipmentCommon(FSMManagerUserTransactionCase):
|
||||||
|
|
||||||
|
|
||||||
@tagged('-at_install', 'post_install')
|
@tagged('-at_install', 'post_install')
|
||||||
class TestEquipmentTour(HttpCase, TestEquipmentCommon):
|
class TestEquipmentBase(TestEquipmentCommon):
|
||||||
|
|
||||||
def test_equipment_tour(self):
|
def test_crd(self):
|
||||||
self.start_tour('/web', 'task_equipment_tour',
|
# Just make sure the basic ORM stuff is OK
|
||||||
|
self.assertTrue(self.equipment in self.partner_company.equipment_ids)
|
||||||
|
self.assertTrue(len(self.partner_company.equipment_ids) == 1)
|
||||||
|
self.partner_company.write({'equipment_ids': [Command.set([])]})
|
||||||
|
# Delete should cascade
|
||||||
|
with self.assertRaises(MissingError):
|
||||||
|
self.equipment.name
|
||||||
|
|
||||||
|
|
||||||
|
@tagged('-at_install', 'post_install')
|
||||||
|
class TestEquipmentTours(HttpCase, TestEquipmentCommon):
|
||||||
|
|
||||||
|
def test_equipment_base_tour(self):
|
||||||
|
self.start_tour('/web', 'equipment_base_tour',
|
||||||
login=self.user.login, )
|
login=self.user.login, )
|
||||||
|
|
||||||
|
def test_equipment_sale_order_tour(self):
|
||||||
|
self.start_tour('/web', 'equipment_sale_order_tour', login=self.user.login)
|
||||||
|
|
@ -25,10 +25,18 @@
|
||||||
<field name="mobile" widget="phone"/>
|
<field name="mobile" widget="phone"/>
|
||||||
</tree>
|
</tree>
|
||||||
</field>
|
</field>
|
||||||
|
<field name="work_order_contacts" attrs="{'invisible': [('company_type','=','person')]}">
|
||||||
|
<tree editable="bottom">
|
||||||
|
<field name="name" widget="res_partner_many2one"/>
|
||||||
|
<field name="email" widget="email"/>
|
||||||
|
<field name="phone" widget="phone"/>
|
||||||
|
<field name="mobile" widget="phone"/>
|
||||||
|
</tree>
|
||||||
|
</field>
|
||||||
<field name="equipment_ids" attrs="{'invisible': [('company_type','=','person')]}">
|
<field name="equipment_ids" attrs="{'invisible': [('company_type','=','person')]}">
|
||||||
<tree editable="bottom">
|
<tree editable="bottom">
|
||||||
<field name="pid_tag"/>
|
<field name="pid_tag"/>
|
||||||
<field name="name" />
|
<field name="name"/>
|
||||||
<field name="location_notes"/>
|
<field name="location_notes"/>
|
||||||
<button name="action_view_equipment"
|
<button name="action_view_equipment"
|
||||||
type="object"
|
type="object"
|
||||||
|
|
@ -40,7 +48,7 @@
|
||||||
name="owned_equipment_ids">
|
name="owned_equipment_ids">
|
||||||
<tree editable="False">
|
<tree editable="False">
|
||||||
<field name="pid_tag"/>
|
<field name="pid_tag"/>
|
||||||
<field name="name" />
|
<field name="name"/>
|
||||||
<field name="partner_location_id" widget="res_partner_many2one"/>
|
<field name="partner_location_id" widget="res_partner_many2one"/>
|
||||||
<field name="location_notes"/>
|
<field name="location_notes"/>
|
||||||
</tree>
|
</tree>
|
||||||
|
|
@ -48,7 +56,7 @@
|
||||||
<field name="site_ids"
|
<field name="site_ids"
|
||||||
attrs="{'invisible': [('company_type','=','company')]}">
|
attrs="{'invisible': [('company_type','=','company')]}">
|
||||||
<tree editable="bottom">
|
<tree editable="bottom">
|
||||||
<field name="name" widget="res_partner_many2one" />
|
<field name="name" widget="res_partner_many2one"/>
|
||||||
</tree>
|
</tree>
|
||||||
</field>
|
</field>
|
||||||
</group>
|
</group>
|
||||||
|
|
|
||||||
45
views/sale_order_views.xml
Normal file
45
views/sale_order_views.xml
Normal file
|
|
@ -0,0 +1,45 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<odoo>
|
||||||
|
<data>
|
||||||
|
<record id="sale_order_form_inherit" model="ir.ui.view">
|
||||||
|
<field name="name">bemade_fsm.sale_order.form</field>
|
||||||
|
<field name="model">sale.order</field>
|
||||||
|
<field name="inherit_id" ref="sale.view_order_form"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<xpath expr="//page[@name='other_information']" position="before">
|
||||||
|
<page name="field_service" string="Field Service">
|
||||||
|
<group name="contacts">
|
||||||
|
<field name="site_contacts">
|
||||||
|
<tree editable="bottom">
|
||||||
|
<field name="name" widget="res_partner_many2one"/>
|
||||||
|
<field name="email" widget="email"/>
|
||||||
|
<field name="phone" widget="phone"/>
|
||||||
|
<field name="mobile" widget="phone"/>
|
||||||
|
</tree>
|
||||||
|
</field>
|
||||||
|
<field name="work_order_contacts">
|
||||||
|
<tree editable="bottom">
|
||||||
|
<field name="name" widget="res_partner_many2one"/>
|
||||||
|
<field name="email" widget="email"/>
|
||||||
|
<field name="phone" widget="phone"/>
|
||||||
|
<field name="mobile" widget="phone"/>
|
||||||
|
</tree>
|
||||||
|
</field>
|
||||||
|
<field name="equipment_ids">
|
||||||
|
<tree editable="bottom">
|
||||||
|
<field name="pid_tag"/>
|
||||||
|
<field name="name"/>
|
||||||
|
<field name="location_notes"/>
|
||||||
|
<button name="action_view_equipment"
|
||||||
|
type="object"
|
||||||
|
string="Details"
|
||||||
|
icon="fa-external-link"/>
|
||||||
|
</tree>
|
||||||
|
</field>
|
||||||
|
</group>
|
||||||
|
</page>
|
||||||
|
</xpath>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
</data>
|
||||||
|
</odoo>
|
||||||
Loading…
Reference in a new issue