Refactoring to views to reuse trees for fsm contacts and equipment. Began remodeling equipment/task relationship (breaks tests).
This commit is contained in:
parent
89a09aebb7
commit
653e22d13c
4 changed files with 76 additions and 67 deletions
|
|
@ -4,8 +4,24 @@ from odoo import fields, models, api
|
|||
class Task(models.Model):
|
||||
_inherit = "project.task"
|
||||
|
||||
equipment_id = fields.Many2one("bemade_fsm.equipment", string="Target Equipment")
|
||||
|
||||
work_order_contacts = fields.Many2many(related='sale_line_id.order_id.work_order_contacts')
|
||||
site_contacts = fields.Many2many(related='sale_line_id.order_id.site_contacts')
|
||||
equipment_ids = fields.Many2many(related='sale_line_id.order_id.equipment_ids')
|
||||
work_order_contacts = fields.Many2many(comodel_name="res.partner",
|
||||
relation="task_work_order_contact_rel",
|
||||
column1="task_id",
|
||||
column2="res_partner_id",
|
||||
compute="_compute_contacts",
|
||||
inverse="_inverse_contacts",
|
||||
store=True)
|
||||
site_contacts = fields.Many2many(comodel_name="res.partner",
|
||||
relation="task_site_contact_rel",
|
||||
column1="task_id",
|
||||
column2="res_partner_id",
|
||||
compute="_compute_contacts",
|
||||
inverse="_inverse_contacts",
|
||||
store=True)
|
||||
equipment_ids = fields.Many2many(comodel_name="bemade_fsm.equipment",
|
||||
relation="task_equipment_rel",
|
||||
column1="task_id",
|
||||
column2="res_partner_id",
|
||||
compute="_compute_equipment",
|
||||
inverse="_inverse_equipment",
|
||||
store=True)
|
||||
|
|
|
|||
|
|
@ -17,42 +17,19 @@
|
|||
<page name="field_service" string="Field Service">
|
||||
<field name="owned_equipment_ids" invisible="True"/>
|
||||
<group>
|
||||
<field name="site_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="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="location_notes"/>
|
||||
<button name="action_view_equipment"
|
||||
type="object"
|
||||
string="Details"
|
||||
icon="fa-external-link"/>
|
||||
</tree>
|
||||
</field>
|
||||
<field name="site_contacts"
|
||||
attrs="{'invisible': [('company_type','=','person')]}"
|
||||
context="{'tree_view_ref': 'bemade_fsm.fsm_contacts_view_tree'}"/>
|
||||
<field name="work_order_contacts"
|
||||
attrs="{'invisible': [('company_type','=','person')]}"
|
||||
context="{'tree_view_ref': 'bemade_fsm.fsm_contacts_view_tree'}"/>
|
||||
<field name="equipment_ids" attrs="{'invisible': [('company_type','=','person')]}"
|
||||
context="{'tree_view_ref': 'bemade_fsm.fsm_equipment_view_tree'}"
|
||||
readonly="False"/>
|
||||
<field attrs="{'invisible': ['|', ('company_type','=','person'), ('owned_equipment_ids','=',False)]}"
|
||||
name="owned_equipment_ids">
|
||||
<tree editable="False">
|
||||
<field name="pid_tag"/>
|
||||
<field name="name"/>
|
||||
<field name="partner_location_id" widget="res_partner_many2one"/>
|
||||
<field name="location_notes"/>
|
||||
</tree>
|
||||
</field>
|
||||
context="{'tree_view_ref': 'bemade_fsm.fsm_equipment_view_tree'}"
|
||||
name="owned_equipment_ids"
|
||||
readonly="True"/>
|
||||
<field name="site_ids"
|
||||
attrs="{'invisible': [('company_type','=','company')]}">
|
||||
<tree editable="bottom">
|
||||
|
|
@ -75,4 +52,31 @@
|
|||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
<record id="fsm_contacts_view_tree" model="ir.ui.view">
|
||||
<field name="name">bemade_fsm.contacts.tree</field>
|
||||
<field name="model">res.partner</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree editable="bottom">
|
||||
<field name="name" />
|
||||
<field name="email" widget="email"/>
|
||||
<field name="phone" widget="phone"/>
|
||||
<field name="mobile" widget="phone"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
<record id="fsm_equipment_view_tree" model="ir.ui.view">
|
||||
<field name="name">bemade_fsm.equipment.tree</field>
|
||||
<field name="model">bemade_fsm.equipment</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree>
|
||||
<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>
|
||||
</record>
|
||||
</odoo>
|
||||
|
|
|
|||
|
|
@ -9,35 +9,14 @@
|
|||
<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="site_contacts"
|
||||
context="{'tree_view_ref': 'bemade_fsm.fsm_contacts_view_tree'}"/>
|
||||
<field name="work_order_contacts"
|
||||
context="{'tree_view_ref': 'bemade_fsm.fsm_contacts_view_tree'}"/>
|
||||
<field name="equipment_ids"
|
||||
domain="[('partner_location_id', '=', partner_shipping_id)]"
|
||||
context="{'default_partner_location_id': partner_shipping_id}">
|
||||
<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>
|
||||
context="{'default_partner_location_id': partner_shipping_id,
|
||||
'tree_view_ref': 'bemade_fsm.equipment_view_tree'}"/>
|
||||
</group>
|
||||
</page>
|
||||
</xpath>
|
||||
|
|
|
|||
|
|
@ -10,6 +10,16 @@
|
|||
<xpath expr="//field[@name='partner_id']" position="after">
|
||||
<field name="equipment_id" domain="[('partner_location_id','=',partner_id)]"/>
|
||||
</xpath>
|
||||
<xpath expr="//page[@name='extra_info']" position="after">
|
||||
<page>
|
||||
<group name="contacts">
|
||||
<field name="site_contacts"
|
||||
context="{'tree_view_ref': 'bemade_fsm.fsm_contacts_view_tree'}"/>
|
||||
<field name="work_order_contacts"
|
||||
context="{'tree_view_ref': 'bemade_fsm.fsm_contacts_view_tree'}"/>
|
||||
</group>
|
||||
</page>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
</data>
|
||||
|
|
|
|||
Loading…
Reference in a new issue