You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

107 lines
5.2 KiB

<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="account_analytic_contract_view_form" model="ir.ui.view">
<field name="name">Contract Template Variable Qty</field>
<field name="model">account.analytic.contract</field>
<field name="inherit_id" ref="contract.account_analytic_contract_view_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='recurring_invoice_line_ids']//field[@name='quantity']" position="before">
<field name="qty_type"/>
</xpath>
<xpath expr="//field[@name='recurring_invoice_line_ids']//field[@name='quantity']" position="after">
<field name="qty_formula_id"
attrs="{'required': [('qty_type', '=', 'variable')], 'invisible': [('qty_type', '!=', 'variable')]}"
/>
</xpath>
<xpath expr="//field[@name='recurring_invoice_line_ids']//field[@name='quantity']" position="attributes">
<attribute name="attrs">{'required': [('qty_type', '=', 'fixed')], 'invisible': [('qty_type', '!=', 'fixed')]}</attribute>
</xpath>
</field>
</record>
<record id="account_analytic_account_recurring_form_form" model="ir.ui.view">
<field name="model">account.analytic.account</field>
<field name="inherit_id" ref="contract.account_analytic_account_recurring_form_form"/>
<field name="arch" type="xml">
<field name="recurring_next_date" position="after">
<field name="skip_zero_qty"/>
</field>
<xpath expr="//field[@name='recurring_invoice_line_ids']//field[@name='quantity']" position="before">
<field name="qty_type"/>
</xpath>
<xpath expr="//field[@name='recurring_invoice_line_ids']//field[@name='quantity']" position="after">
<field name="qty_formula_id"
attrs="{'required': [('qty_type', '=', 'variable')], 'invisible': [('qty_type', '!=', 'variable')]}"
/>
</xpath>
<xpath expr="//field[@name='recurring_invoice_line_ids']//field[@name='quantity']" position="attributes">
<attribute name="attrs">{'required': [('qty_type', '=', 'fixed')], 'invisible': [('qty_type', '!=', 'fixed')]}</attribute>
</xpath>
</field>
</record>
<record id="view_contract_line_qty_formula_tree" model="ir.ui.view">
<field name="model">contract.line.qty.formula</field>
<field name="arch" type="xml">
<tree>
<field name="name"/>
</tree>
</field>
</record>
<record id="view_contract_line_qty_formula_form" model="ir.ui.view">
<field name="model">contract.line.qty.formula</field>
<field name="arch" type="xml">
<form >
<sheet>
<div class="oe_title">
<h1>
<field name="name" placeholder="Name"/>
</h1>
</div>
<group string="Code">
<div style="margin-top: 4px;">
<field name="code" nolabel="1"/>
<h3>Help with Python expressions.</h3>
<p>You have to insert valid Python code block that stores at some moment a float/integer value of the quantity to invoice in the variable 'result'.</p>
<p>You can use these variables to compute your formula:</p>
<ul>
<li><i>env</i>: Environment variable for getting other models.</li>
<li><i>context</i>: Current context dictionary.</li>
<li><i>user</i>: Current user.</li>
<li><i>line</i>: Contract recurring invoice line that triggers this formula.</li>
<li><i>contract</i>: Contract whose line belongs to.</li>
<li><i>invoice</i>: Invoice (header) being created.</li>
</ul>
<div>
<p>Example of Python code</p>
<code>
result = env['product.product'].search_count([('sale_ok', '=', True)])
</code>
</div>
</div>
</group>
</sheet>
</form>
</field>
</record>
<record id="action_contract_quantity_formula" model="ir.actions.act_window">
<field name="name">Formulas (quantity)</field>
<field name="res_model">contract.line.qty.formula</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="help" type="html">
<p class="oe_view_nocontent_create">
Click to create a new formula for variable quantities.
</p>
</field>
</record>
<menuitem id="menu_contract_quantity_formula"
action="action_contract_quantity_formula"
parent="contract.menu_config_contract"
/>
</odoo>