[IMP] Make sure it works for sale and purchase contracts

This commit is contained in:
mreficent
2018-07-04 19:07:35 +02:00
committed by Pedro M. Baeza
parent 3cc3c00452
commit 669249ad35
13 changed files with 144 additions and 72 deletions

View File

@@ -16,6 +16,9 @@
<button name="action_contract_send" type="object" string="Send by Email" groups="base.group_user"/>
</header>
</xpath>
<xpath expr='//field[@name="code"]' position='before'>
<field name="contract_type" invisible="1" required="1"/>
</xpath>
<group name="main" position="after">
<separator string="Recurring Invoices"
attrs="{'invisible': [('recurring_invoices','!=',True)]}"
@@ -39,7 +42,7 @@
/>
</div>
<group col="4" attrs="{'invisible': [('recurring_invoices','!=',True)]}">
<field name="contract_template_id" colspan="4"/>
<field name="contract_template_id" colspan="4" domain="['|', ('contract_type', '=', contract_type), ('contract_type', '=', False)]" context="{'default_contract_type': contract_type}"/>
<field name="journal_id"
attrs="{'required': [('recurring_invoices', '=', True)]}"
/>
@@ -98,47 +101,44 @@
<record id="account_analytic_account_sale_form" model="ir.ui.view">
<field name="name">account.analytic.account.sale.form</field>
<field name="model">account.analytic.account</field>
<field name="inherit_id" ref="contract.account_analytic_account_recurring_form_form"/>
<field name="inherit_id" ref="account_analytic_account_recurring_form_form"/>
<field name="mode">primary</field>
<field name="priority" eval="20"/>
<field name="arch" type="xml">
<field name="partner_id" position="attributes">
<attribute name="string">Customer</attribute>
<attribute name="domain">[('customer', '=', True)]</attribute>
<attribute name="context">{
'default_customer': True,
'default_supplier': False
}</attribute>
<attribute name="context">{'default_customer': True, 'default_supplier': False}</attribute>
</field>
<field name="journal_id" position="attributes">
<attribute name="domain">[('type', '=', 'sale')]</attribute>
</field>
<field name="product_id" position="attributes">
<attribute name="domain">[('sale_ok', '=', True)]</attribute>
</field>
<xpath expr='//field[@name="code"]' position='before'>
<field name="contract_type">sale</field>
</xpath>
</field>
</record>
<record id="account_analytic_account_purchase_form" model="ir.ui.view">
<field name="name">account.analytic.account.purchase.form</field>
<field name="model">account.analytic.account</field>
<field name="inherit_id" ref="contract.account_analytic_account_recurring_form_form"/>
<field name="inherit_id" ref="account_analytic_account_recurring_form_form"/>
<field name="mode">primary</field>
<field name="priority" eval="20"/>
<field name="arch" type="xml">
<field name="partner_id" position="attributes">
<attribute name="string">Supplier</attribute>
<attribute name="domain">[('supplier', '=', True)]</attribute>
<attribute name="context">{
'default_customer': False,
'default_supplier': True
}</attribute>
<attribute name="context">{'default_customer': False, 'default_supplier': True}</attribute>
</field>
<field name="journal_id" position="attributes">
<attribute name="domain">[('type', '=', 'purchase')]</attribute>
</field>
<field name="product_id" position="attributes">
<attribute name="domain">[('purchase_ok', '=', True)]</attribute>
</field>
<xpath expr='//field[@name="code"]' position='before'>
<field name="contract_type">purchase</field>
<xpath expr="//field[@name='recurring_invoice_line_ids']/tree/field[@name='automatic_price']" position="attributes">
<attribute name="invisible">True</attribute>
</xpath>
</field>
</record>
@@ -203,13 +203,13 @@
<!-- Action Sales/Sales/Contracts -->
<record id="action_account_analytic_sale_overdue_all" model="ir.actions.act_window">
<field name="name">Contracts</field>
<field name="name">Customer Contracts</field>
<field name="res_model">account.analytic.account</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="domain">[('contract_type', '=', 'sale')]</field>
<field name="context">{'is_contract':1, 'search_default_not_finished':1, 'search_default_recurring_invoices':1, 'default_recurring_invoices': 1, 'default_type': 'sale'}</field>
<field name="search_view_id" ref="analytic.view_account_analytic_account_search"/>
<field name="context">{'is_contract':1, 'search_default_not_finished':1, 'search_default_recurring_invoices':1, 'default_recurring_invoices': 1, 'default_contract_type': 'sale'}</field>
<field name="search_view_id" ref="view_account_analytic_account_contract_search"/>
<field name="help" type="html">
<p class="oe_view_nocontent_create">
Click to create a new contract.
@@ -239,13 +239,13 @@
<!-- Action Purchases/Purchases/Contracts -->
<record id="action_account_analytic_purchase_overdue_all" model="ir.actions.act_window">
<field name="name">Contracts</field>
<field name="name">Supplier Contracts</field>
<field name="res_model">account.analytic.account</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="domain">[('contract_type', '=', 'purchase')]</field>
<field name="context">{'is_contract':1, 'search_default_not_finished':1, 'search_default_recurring_invoices':1, 'default_recurring_invoices': 1, 'default_type': 'purchase'}</field>
<field name="search_view_id" ref="analytic.view_account_analytic_account_search"/>
<field name="context">{'is_contract':1, 'search_default_not_finished':1, 'search_default_recurring_invoices':1, 'default_recurring_invoices': 1, 'default_contract_type': 'purchase'}</field>
<field name="search_view_id" ref="view_account_analytic_account_contract_search"/>
<field name="help" type="html">
<p class="oe_view_nocontent_create">
Click to create a new contract.

View File

@@ -6,13 +6,15 @@
<field name="model">account.analytic.contract</field>
<field name="arch" type="xml">
<form string="Contract Template">
<group name="name">
<field name="name"/>
</group>
<group name="group_main">
<field name="company_id" invisible="1" />
<field name="name" />
<group name="group_main_left">
<field name="contract_type" />
<field name="journal_id" />
<field name="pricelist_id" />
<field name="company_id" groups="base.group_multi_company"/>
<field name="company_id" options="{'no_create': True}" groups="base.group_multi_company"/>
</group>
<group name="group_main_right">
<field name="recurring_invoicing_type" />
@@ -37,7 +39,7 @@
<field name="name" />
<field name="quantity" />
<field name="uom_id" />
<field name="automatic_price"/>
<field name="automatic_price" attrs="{'column_invisible': [('parent.contract_type','=','purchase')]}"/>
<field name="price_unit" attrs="{'readonly': [('automatic_price', '=', True)]}"/>
<field name="specific_price" invisible="1"/>
<field name="discount" groups="sale.group_discount_per_so_line" />
@@ -61,6 +63,7 @@
<field name="arch" type="xml">
<tree string="Contract Templates">
<field name="name" />
<field name="contract_type" />
<field name="recurring_rule_type" />
<field name="recurring_interval" />
<field name="recurring_invoicing_type" />
@@ -75,11 +78,15 @@
<field name="arch" type="xml">
<search string="Contract Templates">
<field name="name" />
<field name="contract_type" />
<field name="recurring_rule_type" />
<field name="recurring_interval" />
<field name="recurring_invoicing_type" />
<field name="pricelist_id" />
<field name="journal_id" />
<filter string="Contract Type"
context="{'group_by': 'contract_type'}"
/>
<filter string="Recurrence"
context="{'group_by': 'recurring_rule_type'}"
/>
@@ -101,6 +108,7 @@
<field name="res_model">account.analytic.contract</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="search_view_id" ref="account_analytic_contract_view_search"/>
<field name="help" type="html">
<p class="oe_view_nocontent_create">
Click to create a new contract template.

View File

@@ -9,9 +9,14 @@
<field type="xml" name="arch">
<xpath expr="//div[@name='button_box']" position="inside">
<button name="act_show_contract" type="object" class="oe_stat_button"
icon="fa-book"
help="Show the contracts for this partner">
<field name="contract_count" widget="statinfo" string="Contracts"/>
icon="fa-book" context="{'contract_type': 'sale'}"
help="Show the sale contracts for this partner">
<field name="sale_contract_count" widget="statinfo" string="Sale Contracts"/>
</button>
<button name="act_show_contract" type="object" class="oe_stat_button"
icon="fa-book" context="{'contract_type': 'purchase'}"
help="Show the purchase contracts for this partner">
<field name="purchase_contract_count" widget="statinfo" string="Purchase Contracts"/>
</button>
</xpath>
</field>