[IMP] contract: add section and notes in contract line

This commit is contained in:
Ernesto Tejeda
2020-03-17 17:27:28 -04:00
committed by Pedro M. Baeza
parent 97843dbde8
commit cba85b966f
13 changed files with 254 additions and 67 deletions

View File

@@ -7,24 +7,38 @@
<field name="model">contract.abstract.contract.line</field>
<field name="arch" type="xml">
<form>
<header/>
<field name="display_type" invisible="1"/>
<header attrs="{'invisible': [('display_type', '!=', False)]}"/>
<sheet>
<group col="4">
<field colspan="4" name="product_id"/>
<field colspan="4" name="name"/>
<field colspan="2" name="quantity"/>
<field colspan="2" name="uom_id"/>
<field name="specific_price" invisible="1"/>
<group col="4" attrs="{'invisible': [('display_type', '!=', False)]}">
<field colspan="4"
name="product_id"
attrs="{'required': [('display_type', '=', False)]}"/>
<label for="quantity"/>
<div class="o_row">
<field name="quantity" class="oe_inline"/>
<field name="uom_id"
class="oe_inline"
groups="uom.group_uom"
attrs="{'required': [('display_type', '=', False)]}"/>
</div>
<field colspan="2" name="automatic_price"/>
<field name="specific_price" invisible="1"/>
<field colspan="2" name="price_unit"
attrs="{'readonly': [('automatic_price', '=', True)]}"/>
<field colspan="2" name="discount" groups="base.group_no_one"/>
</group>
<group col="4">
<label for="name" string="Description" attrs="{'invisible': [('display_type', '!=', False)]}"/>
<label for="name" string="Section" attrs="{'invisible': [('display_type', '!=', 'line_section')]}"/>
<label for="name" string="Note" attrs="{'invisible': [('display_type', '!=', 'line_note')]}"/>
<field name="name" nolabel="1"/>
<group col="4" attrs="{'invisible': [('display_type', '!=', False)]}">
<field colspan="2" name="is_auto_renew"/>
<field colspan="2" name="is_canceled" invisible="1"/>
</group>
<group attrs="{'invisible':[('is_auto_renew', '=', False)]}">
<group attrs="{'invisible':['|', ('is_auto_renew', '=', False), ('display_type', '!=', False)]}">
<group>
<label for="auto_renew_interval"/>
<div>
@@ -48,10 +62,10 @@
</div>
</group>
</group>
<group name="recurrence_info">
<group name="recurrence_info" attrs="{'invisible': [('display_type', '!=', False)]}">
<group>
<label for="recurring_interval"/>
<div>
<div class="o_row">
<field name="recurring_interval"
class="oe_inline" nolabel="1"/>
<field name="recurring_rule_type"

10
contract/views/assets.xml Normal file
View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2020 Tecnativa - Ernesto Tejeda
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
<odoo>
<template id="assets_backend" name="contract assets" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<script type="text/javascript" src="/contract/static/src/js/section_and_note_fields_backend.js"></script>
</xpath>
</template>
</odoo>

View File

@@ -105,9 +105,76 @@
</group>
<notebook>
<page name="recurring_invoice_line"
string="Recurring Invoices">
<field name="contract_line_ids" attrs="{'readonly': [('is_terminated','=',True)]}"
context="{'default_contract_type': contract_type}"/>
string="Recurring Invoices">
<field name="contract_line_ids"
attrs="{'readonly': [('is_terminated','=',True)]}"
widget="section_and_note_one2many"
context="{'default_contract_type': contract_type}">
<tree decoration-muted="is_canceled"
decoration-info="create_invoice_visibility and not is_canceled">
<control>
<create string="Add a line"/>
<create string="Add a section" context="{'default_display_type': 'line_section'}"/>
<create string="Add a note" context="{'default_display_type': 'line_note'}"/>
</control>
<field name="display_type" invisible="1"/>
<field name="sequence" widget="handle"/>
<field name="product_id"/>
<field name="name" widget="section_and_note_text"/>
<field name="analytic_account_id" groups="analytic.group_analytic_accounting"/>
<field name="analytic_tag_ids" widget="many2many_tags" groups="analytic.group_analytic_tags"/>
<field name="quantity"/>
<field name="uom_id"/>
<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="base.group_no_one"/>
<field name="price_subtotal"/>
<field name="recurring_interval" invisible="1"/>
<field name="recurring_rule_type" invisible="1"/>
<field name="recurring_invoicing_type" invisible="1"/>
<field name="date_start" required="1"/>
<field name="date_end"/>
<field name="recurring_next_date" required="1"/>
<field name="last_date_invoiced" groups="base.group_no_one"/>
<field name="create_invoice_visibility" invisible="1"/>
<field name="is_plan_successor_allowed" invisible="1"/>
<field name="is_stop_plan_successor_allowed" invisible="1"/>
<field name="is_stop_allowed" invisible="1"/>
<field name="is_cancel_allowed" invisible="1"/>
<field name="is_un_cancel_allowed" invisible="1"/>
<field name="is_auto_renew" invisible="1"/>
<field name="is_canceled" invisible="1"/>
<button name="action_plan_successor"
string="Plan Start" type="object"
icon="fa-calendar text-success"
attrs="{'invisible': [('is_plan_successor_allowed', '=', False)]}"/>
<button name="action_stop_plan_successor"
string="Stop Plan Successor"
type="object"
icon="fa-pause text-muted"
attrs="{'invisible': [('is_stop_plan_successor_allowed', '=', False)]}"/>
<button name="action_stop" string="Stop"
type="object"
icon="fa-stop text-danger"
attrs="{'invisible': [('is_stop_allowed', '=', False)]}"/>
<button name="cancel" string="Cancel"
type="object"
icon="fa-ban text-danger"
confirm="Are you sure you want to cancel this line"
attrs="{'invisible': [('is_cancel_allowed', '=', False)]}"/>
<button name="action_uncancel"
string="Un-cancel" type="object"
icon="fa-ban text-success"
attrs="{'invisible': [('is_un_cancel_allowed', '=', False)]}"/>
<button name="renew" string="Renew"
type="object"
icon="fa-fast-forward text-success"
groups="base.group_no_one"
attrs="{'invisible': [('is_auto_renew', '=', False)]}"/>
</tree>
</field>
<field name="note"/>
</page>
<page name="info" string="Other Information">

View File

@@ -38,7 +38,9 @@
</group>
</group>
<group name="recurrence_info" position="after">
<group name="analytic" groups="analytic.group_analytic_accounting,analytic.group_analytic_tags">
<group name="analytic"
groups="analytic.group_analytic_accounting,analytic.group_analytic_tags"
attrs="{'invisible': [('display_type', '!=', False)]}">
<field name="analytic_account_id" groups="analytic.group_analytic_accounting"/>
<field name="analytic_tag_ids" widget="many2many_tags" groups="analytic.group_analytic_tags"/>
</group>
@@ -77,6 +79,7 @@
</field>
</record>
<!-- TODO: Delete this view in migration to v13 or further migrations -->
<!--TREE view-->
<record id="contract_line_tree_view" model="ir.ui.view">
<field name="name">contract.line tree view (in contract)</field>

View File

@@ -19,11 +19,19 @@
</group>
</group>
<group name="group_invoice_lines" string="Contract Template Lines">
<field name="contract_line_ids" nolabel="1">
<field name="contract_line_ids"
widget="section_and_note_one2many"
nolabel="1">
<tree>
<control>
<create string="Add a line"/>
<create string="Add a section" context="{'default_display_type': 'line_section'}"/>
<create string="Add a note" context="{'default_display_type': 'line_note'}"/>
</control>
<field name="display_type" invisible="1"/>
<field name="sequence" widget="handle" />
<field name="product_id" />
<field name="name" />
<field name="name" widget="section_and_note_text"/>
<field name="quantity" />
<field name="uom_id" />
<field name="automatic_price" attrs="{'column_invisible': [('parent.contract_type','=','purchase')]}"/>