sbejaoui
6 years ago
5 changed files with 141 additions and 82 deletions
-
3contract_variable_quantity/__manifest__.py
-
28contract_variable_quantity/views/abstract_contract_view.xml
-
87contract_variable_quantity/views/contract_line_formula.xml
-
23contract_variable_quantity/views/contract_template_view.xml
-
82contract_variable_quantity/views/contract_view.xml
@ -0,0 +1,28 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<odoo> |
|||
|
|||
<record id="account_abstract_analytic_contract_line_view_form" |
|||
model="ir.ui.view"> |
|||
<field name="name">Account Abstract Analytic Contract Line Form View |
|||
</field> |
|||
<field name="model">account.abstract.analytic.contract.line</field> |
|||
<field name="inherit_id" |
|||
ref="contract.account_abstract_analytic_contract_line_view_form"/> |
|||
<field name="arch" type="xml"> |
|||
<xpath expr="//field[@name='quantity']" position="before"> |
|||
<field name="qty_type"/> |
|||
</xpath> |
|||
<xpath expr="//field[@name='quantity']" position="after"> |
|||
<field name="qty_formula_id" |
|||
attrs="{'required': [('qty_type', '=', 'variable')], 'invisible': [('qty_type', '!=', 'variable')]}" |
|||
/> |
|||
</xpath> |
|||
<xpath expr="//field[@name='quantity']" position="attributes"> |
|||
<attribute name="attrs">{'required': [('qty_type', '=', |
|||
'fixed')], 'invisible': [('qty_type', '!=', 'fixed')]} |
|||
</attribute> |
|||
</xpath> |
|||
</field> |
|||
</record> |
|||
|
|||
</odoo> |
@ -0,0 +1,87 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<odoo> |
|||
|
|||
<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" widget="ace" |
|||
options="{'mode': 'python'}"/> |
|||
<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> |
@ -0,0 +1,23 @@ |
|||
<?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> |
|||
|
|||
</odoo> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue