Merge all kind of buttons

review483002
This commit is contained in:
Cédric Krier
2012-09-10 15:28:33 +02:00
parent 584f793a68
commit fe4d332806
2 changed files with 32 additions and 16 deletions
+21 -1
View File
@@ -10,7 +10,7 @@ from trytond.modules.company import CompanyReport
from trytond.wizard import Wizard, StateAction, StateView, StateTransition, \
Button
from trytond.backend import TableHandler
from trytond.pyson import If, Eval, Bool, PYSONEncoder
from trytond.pyson import If, Eval, Bool, PYSONEncoder, Id
from trytond.transaction import Transaction
from trytond.pool import Pool
from trytond.config import CONFIG
@@ -202,6 +202,18 @@ class Sale(Workflow, ModelSQL, ModelView):
'process': {
'invisible': Eval('state') != 'confirmed',
},
'handle_invoice_exception': {
'invisible': ((Eval('invoice_state') != 'exception')
| (Eval('state') == 'cancel')),
'readonly': ~Eval('groups', []).contains(
Id('sale', 'group_sale')),
},
'handle_shipment_exception': {
'invisible': ((Eval('shipment_state') != 'exception')
| (Eval('state') == 'cancel')),
'readonly': ~Eval('groups', []).contains(
Id('sale', 'group_sale')),
},
})
# The states where amounts are cached
self._states_cached = ['confirmed', 'processing', 'done', 'cancel']
@@ -910,6 +922,14 @@ class Sale(Workflow, ModelSQL, ModelView):
self.set_sale_date(ids)
self.store_cache(ids)
@ModelView.button_action('sale.wizard_invoice_handle_exception')
def handle_invoice_exception(self, ids):
pass
@ModelView.button_action('sale.wizard_shipment_handle_exception')
def handle_shipment_exception(self, ids):
pass
@ModelView.button
@Workflow.transition('processing')
def process(self, ids):
+11 -15
View File
@@ -89,24 +89,20 @@ this repository contains the full copyright notices and license terms. -->
<label name="total_amount" xalign="1.0" xexpand="1"/>
<field name="total_amount" xalign="1.0" xexpand="0"/>
<group col="7" colspan="2" id="buttons">
<button name="cancel" type="object" string="Cancel"
<button name="cancel" string="Cancel"
icon="tryton-cancel"/>
<button name="draft" type="object" string="Draft"/>
<button name="quote" type="object" string="Quote"
<button name="draft" string="Draft"/>
<button name="quote" string="Quote"
icon="tryton-go-next"/>
<button name="%(wizard_invoice_handle_exception)d"
string="Handle Invoice Exception"
type="action"
states="{'invisible': Or(Not(Equal(Eval('invoice_state'), 'exception')), Equal(Eval('state'), 'cancel')), 'readonly': Not(In(%(group_sale)d, Eval('groups', [])))}"
icon="tryton-go-next"/>
<button name="%(wizard_shipment_handle_exception)d"
type="action"
string="Handle Shipment Exception"
states="{'invisible': Or(Not(Equal(Eval('shipment_state'), 'exception')), Equal(Eval('state'), 'cancel')), 'readonly': Not(In(%(group_sale)d, Eval('groups', [])))}"
icon="tryton-go-next"/>
<button name="confirm" type="object" string="Confirm"
<button name="handle_invoice_exception"
string="Handle Invoice Exception"
icon="tryton-go-next"/>
<button name="process" type="object" string="Process"
<button name="handle_shipment_exception"
string="Handle Shipment Exception"
icon="tryton-go-next"/>
<button name="confirm" string="Confirm"
icon="tryton-go-next"/>
<button name="process" string="Process"
icon="tryton-go-next"/>
</group>
</group>