bemade_fsm: Finished a test tour for adding equipment to a sales order.

This commit is contained in:
Marc Durepos 2023-06-26 21:44:00 -04:00
parent e1268d2fda
commit 90ba705eef
6 changed files with 59 additions and 36 deletions

View file

@ -49,7 +49,7 @@
'assets': { 'assets': {
'web.assets_tests': [ 'web.assets_tests': [
'bemade_fsm/static/tests/tours/task_template_tour.js', 'bemade_fsm/static/tests/tours/task_template_tour.js',
'bemade_fsm/static/tests/tours/task_equipment_tour.js', 'bemade_fsm/static/tests/tours/equipment_tour.js',
], ],
}, },
'installable': True, 'installable': True,

View file

@ -49,7 +49,6 @@ class Equipment(models.Model):
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') ondelete='cascade')
location_notes = fields.Text(string="Physical Location Notes", location_notes = fields.Text(string="Physical Location Notes",

View file

@ -22,13 +22,14 @@ class SaleOrder(models.Model):
compute='_compute_equipment', compute='_compute_equipment',
inverse='_inverse_equipment', inverse='_inverse_equipment',
string='Equipment to Service', string='Equipment to Service',
store=True) store=True,
ondelete='restrict')
@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:
rec.site_contacts = rec.partner_id.site_contacts rec.site_contacts = rec.partner_shipping_id.site_contacts
rec.work_order_contacts = rec.partner_id.work_order_contacts rec.work_order_contacts = rec.partner_shipping_id.work_order_contacts
def _inverse_default_contacts(self): def _inverse_default_contacts(self):
pass pass
@ -36,7 +37,8 @@ class SaleOrder(models.Model):
@api.depends('partner_id') @api.depends('partner_id')
def _compute_equipment(self): def _compute_equipment(self):
for rec in self: for rec in self:
rec.equipment_ids = self.partner_id.equipment_ids if len(self.partner_id.equipment_ids) <= 1 else False rec.equipment_ids = self.partner_shipping_id.equipment_ids if len(
self.partner_shipping_id.equipment_ids) <= 1 else False
def _inverse_equipment(self): def _inverse_equipment(self):
pass pass

View file

@ -101,6 +101,26 @@ tour.register('equipment_sale_order_tour', {
trigger: 'a.nav-link[role="tab"]:contains(Field Service)' trigger: 'a.nav-link[role="tab"]:contains(Field Service)'
}, { }, {
content: 'Check that default equipment shows up.', content: 'Check that default equipment shows up.',
trigger: `tr:has(label.o_form_label:contains(Site Equipment)) td.o_field_cell:contains(${TEST_EQPT1})` trigger: `.o_field_cell:contains(${TEST_EQPT1})`,
}, }, {
content: 'Add test equipment 2',
trigger: `div[name="equipment_ids"] a:contains(Add a line)`,
}, {
content: 'Click create',
trigger: '.modal-footer > button:has(span:contains(Create))',
}, {
content: 'Name the new equipment',
trigger: 'input.o_field_widget[name="name"]',
run: `text ${TEST_EQPT2}`,
}, {
content: 'Save & Close',
trigger: 'button:has(span:contains(Save & Close))',
}, {
content: 'Save',
trigger: 'button.o_form_button_save',
}, {
content: 'Check that the new equipment was added',
trigger: `.o_field_cell:contains(${TEST_EQPT2})`,
run: function () {},
}
]); ]);

View file

@ -27,7 +27,7 @@
</field> </field>
<field name="work_order_contacts" attrs="{'invisible': [('company_type','=','person')]}"> <field name="work_order_contacts" attrs="{'invisible': [('company_type','=','person')]}">
<tree editable="bottom"> <tree editable="bottom">
<field name="name" widget="res_partner_many2one"/> <field name="name" widget="res_partner_many2one" />
<field name="email" widget="email"/> <field name="email" widget="email"/>
<field name="phone" widget="phone"/> <field name="phone" widget="phone"/>
<field name="mobile" widget="phone"/> <field name="mobile" widget="phone"/>

View file

@ -9,33 +9,35 @@
<xpath expr="//page[@name='other_information']" position="before"> <xpath expr="//page[@name='other_information']" position="before">
<page name="field_service" string="Field Service"> <page name="field_service" string="Field Service">
<group name="contacts"> <group name="contacts">
<field name="site_contacts"> <field name="site_contacts">
<tree editable="bottom"> <tree editable="bottom">
<field name="name" widget="res_partner_many2one"/> <field name="name" widget="res_partner_many2one"/>
<field name="email" widget="email"/> <field name="email" widget="email"/>
<field name="phone" widget="phone"/> <field name="phone" widget="phone"/>
<field name="mobile" widget="phone"/> <field name="mobile" widget="phone"/>
</tree> </tree>
</field> </field>
<field name="work_order_contacts"> <field name="work_order_contacts">
<tree editable="bottom"> <tree editable="bottom">
<field name="name" widget="res_partner_many2one"/> <field name="name" widget="res_partner_many2one"/>
<field name="email" widget="email"/> <field name="email" widget="email"/>
<field name="phone" widget="phone"/> <field name="phone" widget="phone"/>
<field name="mobile" widget="phone"/> <field name="mobile" widget="phone"/>
</tree> </tree>
</field> </field>
<field name="equipment_ids"> <field name="equipment_ids"
<tree editable="bottom"> domain="[('partner_location_id', '=', partner_shipping_id)]"
<field name="pid_tag"/> context="{'default_partner_location_id': partner_shipping_id}">
<field name="name"/> <tree editable="bottom">
<field name="location_notes"/> <field name="pid_tag"/>
<button name="action_view_equipment" <field name="name"/>
type="object" <field name="location_notes"/>
string="Details" <button name="action_view_equipment"
icon="fa-external-link"/> type="object"
</tree> string="Details"
</field> icon="fa-external-link"/>
</tree>
</field>
</group> </group>
</page> </page>
</xpath> </xpath>