Add return wizard
issue9049 review256631002
This commit is contained in:
1 parent
976ff7e1dc
commit
0c560c4e8a
5 files changed
+57
No files matched your search
@@ -1,3 +1,4 @@
|
||||
* Add return wizard
|
||||
* Add employee on purchases for some states
|
||||
* Add contact and invoice party on purchase
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ def register():
|
||||
stock.Location,
|
||||
party.Party,
|
||||
party.CustomerCode,
|
||||
purchase.ReturnPurchaseStart,
|
||||
module='purchase', type_='model')
|
||||
Pool.register(
|
||||
purchase.PurchaseReport,
|
||||
@@ -47,4 +48,5 @@ def register():
|
||||
party.PartyReplace,
|
||||
party.PartyErase,
|
||||
purchase.ModifyHeader,
|
||||
purchase.ReturnPurchase,
|
||||
module='purchase', type_='wizard')
|
||||
+33
@@ -1903,3 +1903,36 @@ class ModifyHeader(Wizard):
|
||||
Line.save(purchase.lines)
|
||||
|
||||
return 'end'
|
||||
|
||||
|
||||
class ReturnPurchaseStart(ModelView):
|
||||
"Return Purchase"
|
||||
__name__ = 'purchase.return_purchase.start'
|
||||
|
||||
|
||||
class ReturnPurchase(Wizard):
|
||||
"Return Purchase"
|
||||
__name__ = 'purchase.return_purchase'
|
||||
start = StateView('purchase.return_purchase.start',
|
||||
'purchase.return_purchase_start_view_form', [
|
||||
Button("Cancel", 'end', 'tryton-cancel'),
|
||||
Button("Return", 'return_', 'tryton-ok', default=True),
|
||||
])
|
||||
return_ = StateAction('purchase.act_purchase_form')
|
||||
|
||||
def do_return_(self, action):
|
||||
Purchase = Pool().get('purchase.purchase')
|
||||
|
||||
purchases = Purchase.browse(Transaction().context['active_ids'])
|
||||
return_purchases = Purchase.copy(purchases)
|
||||
for return_purchase, purchase in zip(return_purchases, purchases):
|
||||
for line in return_purchase.lines:
|
||||
if line.type == 'line':
|
||||
line.quantity *= -1
|
||||
return_purchase.lines = return_purchase.lines # Force saving
|
||||
Purchase.save(return_purchases)
|
||||
|
||||
data = {'res_id': [s.id for s in return_purchases]}
|
||||
if len(return_purchases) == 1:
|
||||
action['views'].reverse()
|
||||
return action, data
|
||||
@@ -515,6 +515,22 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<field name="name">template_tree</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="return_purchase_start_view_form">
|
||||
<field name="model">purchase.return_purchase.start</field>
|
||||
<field name="type">form</field>
|
||||
<field name="name">return_purchase_start_form</field>
|
||||
</record>
|
||||
<record model="ir.action.wizard" id="wizard_return_purchase">
|
||||
<field name="name">Return Purchase</field>
|
||||
<field name="wiz_name">purchase.return_purchase</field>
|
||||
<field name="model">purchase.purchase</field>
|
||||
</record>
|
||||
<record model="ir.action.keyword" id="act_wizard_return_purchase_keyword">
|
||||
<field name="keyword">form_action</field>
|
||||
<field name="model">purchase.purchase,-1</field>
|
||||
<field name="action" ref="wizard_return_purchase"/>
|
||||
</record>
|
||||
|
||||
<record model="ir.action.wizard" id="act_open_supplier">
|
||||
<field name="name">Parties associated to Purchases</field>
|
||||
<field name="wiz_name">purchase.open_supplier</field>
|
||||
|
||||
@@ -122,4 +122,9 @@ def suite():
|
||||
tearDown=doctest_teardown, encoding='utf-8',
|
||||
optionflags=doctest.REPORT_ONLY_FIRST_FAILURE,
|
||||
checker=doctest_checker))
|
||||
suite.addTests(doctest.DocFileSuite(
|
||||
'scenario_purchase_return_wizard.rst',
|
||||
tearDown=doctest_teardown, encoding='utf-8',
|
||||
optionflags=doctest.REPORT_ONLY_FIRST_FAILURE,
|
||||
checker=doctest_checker))
|
||||
return suite
|
||||
Reference in new issue
Block a user