Duplicate + open form
This commit is contained in:
@@ -7,7 +7,7 @@ from trytond.model import ModelView, fields
|
||||
from trytond.pool import Pool
|
||||
from trytond.pyson import Bool, Eval
|
||||
from trytond.transaction import Transaction
|
||||
from trytond.wizard import Button, StateTransition, StateView, Wizard
|
||||
from trytond.wizard import Button, StateAction, StateTransition, StateView, Wizard
|
||||
|
||||
from trytond.modules.purchase_trade.service import ContractFactory
|
||||
|
||||
@@ -32,6 +32,7 @@ class TradeCustomDuplicateStart(ModelView):
|
||||
('purchase.purchase', 'Purchase'),
|
||||
('sale.sale', 'Sale'),
|
||||
], readonly=True)
|
||||
duplicated_record_id = fields.Integer("Duplicated Record ID", readonly=True)
|
||||
party = fields.Many2One('party.party', "Counterparty", required=True)
|
||||
currency = fields.Many2One('currency.currency', "Currency", required=True)
|
||||
payment_term = fields.Many2One(
|
||||
@@ -63,6 +64,8 @@ class TradeCustomDuplicate(Wizard):
|
||||
Button("Duplicate", 'duplicate', 'tryton-ok', default=True),
|
||||
])
|
||||
duplicate = StateTransition()
|
||||
open_purchase = StateAction('purchase.act_purchase_form')
|
||||
open_sale = StateAction('sale.act_sale_form')
|
||||
|
||||
@staticmethod
|
||||
def _trade_line(record):
|
||||
@@ -219,9 +222,22 @@ class TradeCustomDuplicate(Wizard):
|
||||
options = self.start
|
||||
new_record = self._copy_contract(record, options)
|
||||
new_line = self._apply_line_options(new_record, options)
|
||||
self.start.duplicated_record_id = new_record.id
|
||||
if options.create_matched_mirror:
|
||||
self._create_matched_mirror(new_record, new_line, options)
|
||||
return 'end'
|
||||
if new_record.__name__ == 'purchase.purchase':
|
||||
return 'open_purchase'
|
||||
return 'open_sale'
|
||||
|
||||
def _open_duplicated_record(self, action):
|
||||
action['views'].reverse()
|
||||
return action, {'res_id': self.start.duplicated_record_id}
|
||||
|
||||
def do_open_purchase(self, action):
|
||||
return self._open_duplicated_record(action)
|
||||
|
||||
def do_open_sale(self, action):
|
||||
return self._open_duplicated_record(action)
|
||||
|
||||
def end(self):
|
||||
return 'reload'
|
||||
|
||||
@@ -27,4 +27,5 @@
|
||||
<label name="mirror_party"/>
|
||||
<field name="mirror_party"/>
|
||||
<field name="source" invisible="1"/>
|
||||
<field name="duplicated_record_id" invisible="1"/>
|
||||
</form>
|
||||
|
||||
Reference in New Issue
Block a user