summaryrefslogtreecommitdiff
path: root/addons/sale_project/views/project_task_views.xml
blob: 992e55c97c914233feab8d1cd2e18776d38881f4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<?xml version="1.0" encoding="utf-8"?>
<odoo>

    <record id="project_project_view_tree_inherit_sale_project" model="ir.ui.view">
        <field name="name">project.project.tree.inherit.sale.project</field>
        <field name="model">project.project</field>
        <field name="inherit_id" ref="project.view_project"/>
        <field name="arch" type="xml">
            <xpath expr="//field[@name='analytic_account_id']" position="after">
                <field name="sale_order_id" optional="hide" widget="sale_order_many2one"/>
                <field name="sale_line_id" optional="hide" widget="sale_order_many2one" readonly="1"/>
            </xpath>
        </field>
    </record>

    <record id="view_edit_project_inherit_form" model="ir.ui.view">
        <field name="name">project.project.view.inherit</field>
        <field name="model">project.project</field>
        <field name="inherit_id" ref="project.edit_project"/>
        <field name="arch" type="xml">
            <div class="oe_button_box" position="inside">
                <button class="d-none d-md-inline oe_stat_button" 
                    type="object" name="action_view_so" icon="fa-dollar" 
                    attrs="{'invisible': [('sale_order_id', '=', False)]}" 
                    groups="sales_team.group_sale_salesman"
                    string="Sales Order">
                    <field name="sale_order_id" attrs="{'invisible': True}"/> 
                </button>
            </div>
            <xpath expr="//field[@name='partner_id']" position="attributes">
                <attribute name="options">{'always_reload': True}</attribute>
                <attribute name="context">{'res_partner_search_mode': 'customer'}</attribute>
            </xpath>
        </field>
    </record>

    <record id="view_sale_project_inherit_form" model="ir.ui.view">
        <field name="name">project.task.view.inherit</field>
        <field name="model">project.task</field>
        <field name="groups_id" eval="[(4, ref('base.group_user'))]"/>
        <field name="inherit_id" ref="project.view_task_form2"/>
        <field name="arch" type="xml">
            <div name="button_box" position="inside">
                <button class="d-none d-md-inline oe_stat_button"
                        type="object" name="action_view_so" icon="fa-dollar"
                        attrs="{'invisible': [('sale_order_id', '=', False)]}"
                        string="Sales Order"
                        groups="sales_team.group_sale_salesman"/>
            </div>
            <xpath expr="//field[@name='partner_id']" position="attributes">
                <attribute name="options">{'always_reload': True}</attribute>
                <attribute name="context">{'res_partner_search_mode': 'customer'}</attribute>
            </xpath>
            <xpath expr="//field[@name='partner_phone']" position="after">
                <field name="sale_order_id" attrs="{'invisible': True}" groups="sales_team.group_sale_salesman"/>
                <field name="sale_line_id" string="Sales Order Item" attrs="{'invisible': [('partner_id', '=', False)]}" options='{"no_open": True}' readonly="1" context="{'create': False, 'edit': False, 'delete': False}"/>
                <field name="commercial_partner_id" invisible="1" />
                <field name="project_sale_order_id" invisible="1"/>
            </xpath>
        </field>
    </record>

    <record id="project_task_view_form_inherit_sale_line_editable" model="ir.ui.view">
        <field name="name">project.task.form.inherit.sale.line.editable.salesman</field>
        <field name="model">project.task</field>
        <field name="inherit_id" ref="view_sale_project_inherit_form"/>
        <field name="arch" type="xml">
            <xpath expr="//field[@name='sale_line_id']" position="attributes">
                <attribute name="options">{"no_create": True}</attribute>
                <attribute name="readonly">0</attribute>
            </xpath>
        </field>
        <field name="groups_id" eval="[(4, ref('sales_team.group_sale_salesman'))]"/>
    </record>

    <record id="project_task_view_search" model="ir.ui.view">
        <field name="name">project.task.search.inherit</field>
        <field name="model">project.task</field>
        <field name="inherit_id" ref="project.view_task_search_form"/>
        <field name="arch" type="xml">
            <xpath expr="//field[@name='stage_id']" position="before">
                <field name="sale_order_id" string="Sale Order" filter_domain="['|', ('sale_order_id', 'ilike', self), ('sale_line_id', 'ilike', self)]"/>
            </xpath>
        </field>
    </record>

    <!-- To invoice batch action -->
    <record id="project_task_server_action_batch_invoice" model="ir.actions.server">
        <field name="name">Create invoice</field>
        <field name="model_id" ref="project.model_project_task"/>
        <field name="binding_model_id" ref="project.model_project_task"/>
        <field name="state">code</field>
        <field name="code">
            if records:
                action = records.action_create_invoice()
        </field>
    </record>

</odoo>