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/menus.xml',
|
||||
'views/task_views.xml',
|
||||
'views/sale_order_views.xml',
|
||||
],
|
||||
'assets': {
|
||||
'web.assets_tests': [
|
||||
|
|
|
|||
|
|
@ -41,13 +41,16 @@ class Equipment(models.Model):
|
|||
partner_id = fields.Many2one('res.partner',
|
||||
string="Owner",
|
||||
compute="_compute_partner",
|
||||
search="_search_partner", )
|
||||
search="_search_partner",)
|
||||
|
||||
description = fields.Text(string="Description",
|
||||
tracking=True)
|
||||
|
||||
partner_location_id = fields.Many2one('res.partner',
|
||||
string="Physical Address",
|
||||
tracking=True, )
|
||||
tracking=True,
|
||||
required=True,
|
||||
ondelete='cascade')
|
||||
|
||||
location_notes = fields.Text(string="Physical Location Notes",
|
||||
tracking=True)
|
||||
|
|
|
|||
|
|
@ -18,6 +18,12 @@ class SaleOrder(models.Model):
|
|||
string='Work Order Recipients',
|
||||
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')
|
||||
def _compute_default_contacts(self):
|
||||
for rec in self:
|
||||
|
|
@ -27,6 +33,14 @@ class SaleOrder(models.Model):
|
|||
def _inverse_default_contacts(self):
|
||||
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):
|
||||
_inherit = 'sale.order.line'
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
/** @odoo-module **/
|
||||
|
||||
import tour from 'web_tour.tour';
|
||||
|
||||
const TEST_COMPANY = "Test Partner Company";
|
||||
const TEST_EQPT1 = "Test Equipment 1";
|
||||
const TEST_EQPT2 = "Test Equipment 2";
|
||||
tour.register('task_equipment_tour', {
|
||||
tour.register('equipment_base_tour', {
|
||||
test: true,
|
||||
url: '/web',
|
||||
}, /* 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',
|
||||
/*trigger: `div[name="equipment_ids"]:has(td:contains(${TEST_EQPT1}))`,*/
|
||||
trigger: `td:contains(${TEST_EQPT1})`,
|
||||
run: function() {},
|
||||
run: function () {
|
||||
},
|
||||
}, {
|
||||
content: 'Make sure we have a second test equipment',
|
||||
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 .test_bemade_fsm_common import FSMManagerUserTransactionCase
|
||||
from odoo import Command
|
||||
from odoo.exceptions import MissingError
|
||||
|
||||
|
||||
@tagged("-at_install", "post_install")
|
||||
|
|
@ -32,8 +34,24 @@ class TestEquipmentCommon(FSMManagerUserTransactionCase):
|
|||
|
||||
|
||||
@tagged('-at_install', 'post_install')
|
||||
class TestEquipmentTour(HttpCase, TestEquipmentCommon):
|
||||
class TestEquipmentBase(TestEquipmentCommon):
|
||||
|
||||
def test_equipment_tour(self):
|
||||
self.start_tour('/web', 'task_equipment_tour',
|
||||
def test_crd(self):
|
||||
# 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, )
|
||||
|
||||
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"/>
|
||||
</tree>
|
||||
</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')]}">
|
||||
<tree editable="bottom">
|
||||
<field name="pid_tag"/>
|
||||
<field name="name" />
|
||||
<field name="name"/>
|
||||
<field name="location_notes"/>
|
||||
<button name="action_view_equipment"
|
||||
type="object"
|
||||
|
|
@ -40,7 +48,7 @@
|
|||
name="owned_equipment_ids">
|
||||
<tree editable="False">
|
||||
<field name="pid_tag"/>
|
||||
<field name="name" />
|
||||
<field name="name"/>
|
||||
<field name="partner_location_id" widget="res_partner_many2one"/>
|
||||
<field name="location_notes"/>
|
||||
</tree>
|
||||
|
|
@ -48,7 +56,7 @@
|
|||
<field name="site_ids"
|
||||
attrs="{'invisible': [('company_type','=','company')]}">
|
||||
<tree editable="bottom">
|
||||
<field name="name" widget="res_partner_many2one" />
|
||||
<field name="name" widget="res_partner_many2one"/>
|
||||
</tree>
|
||||
</field>
|
||||
</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