Remove safe_eval
We convert all the fields that were storing python code into PYSON. We add a pyson attribute on field tag to store PYSON value. issue4416 review6971002
This commit is contained in:
1 parent
139da7ec62
commit
fbed749bba
5 files changed
+43
-30
No files matched your search
+12
-1
@@ -14,7 +14,7 @@ from trytond.report import Report
|
||||
from trytond.wizard import Wizard, StateView, StateTransition, StateAction, \
|
||||
Button
|
||||
from trytond import backend
|
||||
from trytond.pyson import If, Eval, Bool, Id
|
||||
from trytond.pyson import If, Eval, Bool, Id, PYSONEncoder
|
||||
from trytond.tools import reduce_ids, grouped_slice
|
||||
from trytond.transaction import Transaction
|
||||
from trytond.pool import Pool
|
||||
@@ -957,6 +957,10 @@ class Invoice(Workflow, ModelSQL, ModelView, TaxableMixin):
|
||||
return ', '.join(set(itertools.ifilter(None,
|
||||
(l.origin_name for l in self.lines))))
|
||||
|
||||
@classmethod
|
||||
def view_attributes(cls):
|
||||
return [('//field[@name="comment"]', 'spell', Eval('party_lang'))]
|
||||
|
||||
@classmethod
|
||||
def delete(cls, invoices):
|
||||
cls.check_modify(invoices)
|
||||
@@ -1842,6 +1846,13 @@ class InvoiceLine(ModelSQL, ModelView, TaxableMixin):
|
||||
'invoice': line.invoice.rec_name
|
||||
})
|
||||
|
||||
@classmethod
|
||||
def view_attributes(cls):
|
||||
return [('//field[@name="note"]|//field[@name="description"]', 'spell',
|
||||
If(Bool(Eval('_parent_invoice')),
|
||||
Eval('_parent_invoice', {}).get('party_lang'),
|
||||
Eval('party_lang')))]
|
||||
|
||||
@classmethod
|
||||
def delete(cls, lines):
|
||||
cls.check_modify(lines)
|
||||
|
||||
+26
-22
@@ -41,8 +41,8 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<record model="ir.action.act_window" id="act_invoice_out_invoice_form">
|
||||
<field name="name">Invoices</field>
|
||||
<field name="res_model">account.invoice</field>
|
||||
<field name="domain">[('type', '=', 'out_invoice')]</field>
|
||||
<field name="context">{'type': 'out_invoice'}</field>
|
||||
<field name="domain" eval="[('type', '=', 'out_invoice')]" pyson="1"/>
|
||||
<field name="context" eval="{'type': 'out_invoice'}" pyson="1"/>
|
||||
<field name="search_value"></field>
|
||||
</record>
|
||||
<record model="ir.action.act_window.view" id="act_invoice_out_invoice_form_view1">
|
||||
@@ -58,19 +58,19 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<record model="ir.action.act_window.domain" id="act_invoice_out_invoice_domain_draft">
|
||||
<field name="name">Draft</field>
|
||||
<field name="sequence" eval="10"/>
|
||||
<field name="domain">[('state', '=', 'draft')]</field>
|
||||
<field name="domain" eval="[('state', '=', 'draft')]" pyson="1"/>
|
||||
<field name="act_window" ref="act_invoice_out_invoice_form"/>
|
||||
</record>
|
||||
<record model="ir.action.act_window.domain" id="act_invoice_out_invoice_domain_validated">
|
||||
<field name="name">Validated</field>
|
||||
<field name="sequence" eval="20"/>
|
||||
<field name="domain">[('state', '=', 'validated')]</field>
|
||||
<field name="domain" eval="[('state', '=', 'validated')]" pyson="1"/>
|
||||
<field name="act_window" ref="act_invoice_out_invoice_form"/>
|
||||
</record>
|
||||
<record model="ir.action.act_window.domain" id="act_invoice_out_invoice_domain_posted">
|
||||
<field name="name">Posted</field>
|
||||
<field name="sequence" eval="30"/>
|
||||
<field name="domain">[('state', '=', 'posted')]</field>
|
||||
<field name="domain" eval="[('state', '=', 'posted')]" pyson="1"/>
|
||||
<field name="act_window" ref="act_invoice_out_invoice_form"/>
|
||||
</record>
|
||||
<record model="ir.action.act_window.domain" id="act_invoice_out_invoice_domain_all">
|
||||
@@ -85,8 +85,8 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<record model="ir.action.act_window" id="act_invoice_out_credit_note_form">
|
||||
<field name="name">Credit Notes</field>
|
||||
<field name="res_model">account.invoice</field>
|
||||
<field name="domain">[('type', '=', 'out_credit_note')]</field>
|
||||
<field name="context">{'type': 'out_credit_note'}</field>
|
||||
<field name="domain" eval="[('type', '=', 'out_credit_note')]" pyson="1"/>
|
||||
<field name="context" eval="{'type': 'out_credit_note'}" pyson="1"/>
|
||||
<field name="search_value"></field>
|
||||
</record>
|
||||
<record model="ir.action.act_window.view" id="act_invoice_out_credit_note_form_view1">
|
||||
@@ -102,19 +102,19 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<record model="ir.action.act_window.domain" id="act_invoice_out_credit_note_domain_draft">
|
||||
<field name="name">Draft</field>
|
||||
<field name="sequence" eval="10"/>
|
||||
<field name="domain">[('state', '=', 'draft')]</field>
|
||||
<field name="domain" eval="[('state', '=', 'draft')]" pyson="1"/>
|
||||
<field name="act_window" ref="act_invoice_out_credit_note_form"/>
|
||||
</record>
|
||||
<record model="ir.action.act_window.domain" id="act_invoice_out_credit_note_domain_validated">
|
||||
<field name="name">Validated</field>
|
||||
<field name="sequence" eval="20"/>
|
||||
<field name="domain">[('state', '=', 'validated')]</field>
|
||||
<field name="domain" eval="[('state', '=', 'validated')]" pyson="1"/>
|
||||
<field name="act_window" ref="act_invoice_out_credit_note_form"/>
|
||||
</record>
|
||||
<record model="ir.action.act_window.domain" id="act_invoice_out_credit_note_domain_posted">
|
||||
<field name="name">Posted</field>
|
||||
<field name="sequence" eval="30"/>
|
||||
<field name="domain">[('state', '=', 'posted')]</field>
|
||||
<field name="domain" eval="[('state', '=', 'posted')]" pyson="1"/>
|
||||
<field name="act_window" ref="act_invoice_out_credit_note_form"/>
|
||||
</record>
|
||||
<record model="ir.action.act_window.domain" id="act_invoice_out_credit_note_domain_all">
|
||||
@@ -129,8 +129,8 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<record model="ir.action.act_window" id="act_invoice_in_invoice_form">
|
||||
<field name="name">Supplier Invoices</field>
|
||||
<field name="res_model">account.invoice</field>
|
||||
<field name="domain">[('type', '=', 'in_invoice')]</field>
|
||||
<field name="context">{'type': 'in_invoice'}</field>
|
||||
<field name="domain" eval="[('type', '=', 'in_invoice')]" pyson="1"/>
|
||||
<field name="context" eval="{'type': 'in_invoice'}" pyson="1"/>
|
||||
<field name="search_value"></field>
|
||||
</record>
|
||||
<record model="ir.action.act_window.view" id="act_invoice_in_invoice_form_view1">
|
||||
@@ -146,19 +146,19 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<record model="ir.action.act_window.domain" id="act_invoice_in_invoice_domain_draft">
|
||||
<field name="name">Draft</field>
|
||||
<field name="sequence" eval="10"/>
|
||||
<field name="domain">[('state', '=', 'draft')]</field>
|
||||
<field name="domain" eval="[('state', '=', 'draft')]" pyson="1"/>
|
||||
<field name="act_window" ref="act_invoice_in_invoice_form"/>
|
||||
</record>
|
||||
<record model="ir.action.act_window.domain" id="act_invoice_in_invoice_domain_validated">
|
||||
<field name="name">Validated</field>
|
||||
<field name="sequence" eval="20"/>
|
||||
<field name="domain">[('state', '=', 'validated')]</field>
|
||||
<field name="domain" eval="[('state', '=', 'validated')]" pyson="1"/>
|
||||
<field name="act_window" ref="act_invoice_in_invoice_form"/>
|
||||
</record>
|
||||
<record model="ir.action.act_window.domain" id="act_invoice_in_invoice_domain_posted">
|
||||
<field name="name">Posted</field>
|
||||
<field name="sequence" eval="30"/>
|
||||
<field name="domain">[('state', '=', 'posted')]</field>
|
||||
<field name="domain" eval="[('state', '=', 'posted')]" pyson="1"/>
|
||||
<field name="act_window" ref="act_invoice_in_invoice_form"/>
|
||||
</record>
|
||||
<record model="ir.action.act_window.domain" id="act_invoice_in_invoice_domain_all">
|
||||
@@ -173,8 +173,8 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<record model="ir.action.act_window" id="act_invoice_in_credit_note_form">
|
||||
<field name="name">Supplier Credit Notes</field>
|
||||
<field name="res_model">account.invoice</field>
|
||||
<field name="domain">[('type', '=', 'in_credit_note')]</field>
|
||||
<field name="context">{'type': 'in_credit_note'}</field>
|
||||
<field name="domain" eval="[('type', '=', 'in_credit_note')]" pyson="1"/>
|
||||
<field name="context" eval="{'type': 'in_credit_note'}" pyson="1"/>
|
||||
<field name="search_value"></field>
|
||||
</record>
|
||||
<record model="ir.action.act_window.view" id="act_invoice_in_credit_note_form_view1">
|
||||
@@ -190,19 +190,19 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<record model="ir.action.act_window.domain" id="act_invoice_in_credit_note_domain_draft">
|
||||
<field name="name">Draft</field>
|
||||
<field name="sequence" eval="10"/>
|
||||
<field name="domain">[('state', '=', 'draft')]</field>
|
||||
<field name="domain" eval="[('state', '=', 'draft')]" pyson="1"/>
|
||||
<field name="act_window" ref="act_invoice_in_credit_note_form"/>
|
||||
</record>
|
||||
<record model="ir.action.act_window.domain" id="act_invoice_in_credit_note_domain_validated">
|
||||
<field name="name">Validated</field>
|
||||
<field name="sequence" eval="20"/>
|
||||
<field name="domain">[('state', '=', 'validated')]</field>
|
||||
<field name="domain" eval="[('state', '=', 'validated')]" pyson="1"/>
|
||||
<field name="act_window" ref="act_invoice_in_credit_note_form"/>
|
||||
</record>
|
||||
<record model="ir.action.act_window.domain" id="act_invoice_in_credit_note_domain_posted">
|
||||
<field name="name">Posted</field>
|
||||
<field name="sequence" eval="30"/>
|
||||
<field name="domain">[('state', '=', 'posted')]</field>
|
||||
<field name="domain" eval="[('state', '=', 'posted')]" pyson="1"/>
|
||||
<field name="act_window" ref="act_invoice_in_credit_note_form"/>
|
||||
</record>
|
||||
<record model="ir.action.act_window.domain" id="act_invoice_in_credit_note_domain_all">
|
||||
@@ -413,7 +413,9 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<field name="global_p" eval="True"/>
|
||||
</record>
|
||||
<record model="ir.rule" id="rule_invoice1">
|
||||
<field name="domain">[('company', '=', user.company.id if user.company else None)]</field>
|
||||
<field name="domain"
|
||||
eval="[('company', '=', Eval('user', {}).get('company', None))]"
|
||||
pyson="1"/>
|
||||
<field name="rule_group" ref="rule_group_invoice"/>
|
||||
</record>
|
||||
|
||||
@@ -422,7 +424,9 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<field name="global_p" eval="True"/>
|
||||
</record>
|
||||
<record model="ir.rule" id="rule_invoice_line1">
|
||||
<field name="domain">[('company', '=', user.company.id if user.company else None)]</field>
|
||||
<field name="domain"
|
||||
eval="[('company', '=', Eval('user', {}).get('company', None))]"
|
||||
pyson="1"/>
|
||||
<field name="rule_group" ref="rule_group_invoice_line"/>
|
||||
</record>
|
||||
</data>
|
||||
|
||||
@@ -23,7 +23,8 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<record model="ir.action.act_window" id="act_invoice_form2">
|
||||
<field name="name">Invoices</field>
|
||||
<field name="res_model">account.invoice</field>
|
||||
<field name="domain">[('party', 'in', Eval('active_ids'))]</field>
|
||||
<field name="domain"
|
||||
eval="[('party', 'in', Eval('active_ids'))]" pyson="1"/>
|
||||
</record>
|
||||
<record model="ir.action.keyword"
|
||||
id="act_open_invoice_keyword1">
|
||||
|
||||
@@ -76,8 +76,7 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<label name="cancel_move"/>
|
||||
<field name="cancel_move"/>
|
||||
<separator name="comment" colspan="4"/>
|
||||
<field name="comment" colspan="4"
|
||||
spell="Eval('party_lang')"/>
|
||||
<field name="comment" colspan="4"/>
|
||||
</page>
|
||||
<page string="Payment" id="payment">
|
||||
<label name="amount_to_pay_today"/>
|
||||
|
||||
@@ -16,8 +16,7 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<field name="account"/>
|
||||
<newline/>
|
||||
<label name="description"/>
|
||||
<field name="description" colspan="3" yexpand="0"
|
||||
spell="If(Bool(Eval('_parent_invoice')), Get(Eval('_parent_invoice', {}), 'party_lang'), Eval('party_lang'))"/>
|
||||
<field name="description" colspan="3" yexpand="0"/>
|
||||
<label name="quantity"/>
|
||||
<field name="quantity"/>
|
||||
<label name="unit"/>
|
||||
@@ -30,8 +29,7 @@ this repository contains the full copyright notices and license terms. -->
|
||||
</page>
|
||||
<page string="Notes" id="notes">
|
||||
<separator name="note" colspan="4"/>
|
||||
<field name="note" colspan="4"
|
||||
spell="If(Bool(Eval('_parent_invoice')), Get(Eval('_parent_invoice', {}), 'party_lang'), Eval('party_lang'))"/>
|
||||
<field name="note" colspan="4"/>
|
||||
</page>
|
||||
</notebook>
|
||||
<field name="party_lang" invisible="1" colspan="4"/>
|
||||
|
||||
Reference in new issue
Block a user