Better user experience with "Return Sale" wizard
- it should ask for confirmation - it should show the created return sales review975004
This commit is contained in:
1 parent
06a2f23eb5
commit
31d07a8d6a
4 files changed
+42
-13
No files matched your search
@@ -24,6 +24,7 @@ def register():
|
||||
ShipmentOutReturn,
|
||||
HandleShipmentExceptionAsk,
|
||||
HandleInvoiceExceptionAsk,
|
||||
ReturnSaleStart,
|
||||
Configuration,
|
||||
Invoice,
|
||||
InvoiceLine,
|
||||
|
||||
@@ -19,7 +19,7 @@ __all__ = ['Sale', 'SaleInvoice', 'SaleIgnoredInvoice', 'SaleRecreatedInvoice',
|
||||
'ShipmentOut', 'ShipmentOutReturn', 'Move', 'OpenCustomer',
|
||||
'HandleShipmentExceptionAsk', 'HandleShipmentException',
|
||||
'HandleInvoiceExceptionAsk', 'HandleInvoiceException',
|
||||
'ReturnSale']
|
||||
'ReturnSaleStart', 'ReturnSale']
|
||||
__metaclass__ = PoolMeta
|
||||
|
||||
_ZERO = Decimal(0)
|
||||
@@ -1843,17 +1843,31 @@ class HandleInvoiceException(Wizard):
|
||||
return 'end'
|
||||
|
||||
|
||||
class ReturnSale(Wizard):
|
||||
__name__ = 'sale.return_sale'
|
||||
start_state = 'make_return'
|
||||
make_return = StateTransition()
|
||||
class ReturnSaleStart(ModelView):
|
||||
'Return Sale'
|
||||
__name__ = 'sale.return_sale.start'
|
||||
|
||||
def transition_make_return(self):
|
||||
|
||||
class ReturnSale(Wizard):
|
||||
'Return Sale'
|
||||
__name__ = 'sale.return_sale'
|
||||
start = StateView('sale.return_sale.start',
|
||||
'sale.return_sale_start_view_form', [
|
||||
Button('Cancel', 'end', 'tryton-cancel'),
|
||||
Button('Return', 'return_', 'tryton-ok', default=True),
|
||||
])
|
||||
return_ = StateAction('sale.act_sale_form')
|
||||
|
||||
def do_return_(self, action):
|
||||
Sale = Pool().get('sale.sale')
|
||||
|
||||
sale = Sale(Transaction().context['active_id'])
|
||||
new_sale, = Sale.copy([sale])
|
||||
for new_line in new_sale.lines:
|
||||
new_line.quantity *= -1
|
||||
new_line.save()
|
||||
return 'end'
|
||||
sales = Sale.browse(Transaction().context['active_ids'])
|
||||
return_sales = Sale.copy(sales)
|
||||
for sale in return_sales:
|
||||
for line in sale.lines:
|
||||
line.quantity *= -1
|
||||
line.save()
|
||||
data = {'res_id': [s.id for s in return_sales]}
|
||||
if len(return_sales) == 1:
|
||||
action['views'].reverse()
|
||||
return action, data
|
||||
@@ -305,8 +305,14 @@ this repository contains the full copyright notices and license terms. -->
|
||||
icon="tryton-list"
|
||||
id="menu_customer"/>
|
||||
|
||||
<record model="ir.ui.view" id="return_sale_start_view_form">
|
||||
<field name="model">sale.return_sale.start</field>
|
||||
<field name="type">form</field>
|
||||
<field name="name">return_sale_start_form</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.action.wizard" id="wizard_return_sale">
|
||||
<field name="name">Create Return Sale</field>
|
||||
<field name="name">Return Sale</field>
|
||||
<field name="wiz_name">sale.return_sale</field>
|
||||
<field name="model">sale.sale</field>
|
||||
</record>
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0"?>
|
||||
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
this repository contains the full copyright notices and license terms. -->
|
||||
<form string="Return Sale" col="2">
|
||||
<image name="tryton-dialog-information" xexpand="0" xfill="0"/>
|
||||
<label string="Are you sure to return those/this sale(s)?" id="return"
|
||||
yalign="0.0" xalign="0.0" xexpand="1"/>
|
||||
</form>
|
||||
Reference in new issue
Block a user