I have a scenario where I can copy one record to other existing records as below:
@classmethod
def __setup__(cls):
cls.month_of_billing.selection = cls._month_get()
cls.year_of_billing.selection = cls._year_get()
super(SOInternalRecord, cls).__setup__()
cls._buttons.update({
'copy_quot': {
'invisible': And(
Eval('quot_quantity', None) == None,
Eval('fc_quot_quantity', None) == None,
),
},
})
@classmethod
@ModelView.button
def copy_quot(cls, object):
record = object[0]
scenario = record.scenario
sales_order = record.sales_order
if sales_order and sales_order.id:
SOInternalRecord = Pool().get('afx.sales.order.internal.record')
if SOInternalRecord:
records = SOInternalRecord.search([
('sales_order', '=', record.sales_order.id),
('id', '>', record.id)
])
if len(records) > 0:
for rec in records:
if scenario == 'LCLC' or scenario == 'LCFC':
rec.quot_quantity = record.quot_quantity
rec.quot_unit_price = record.quot_unit_price
rec.quot_sst = record.quot_sst
elif scenario == 'FCFC' or scenario == 'FCLC':
rec.fc_quot_quantity = record.fc_quot_quantity
rec.fc_quot_unit_price = record.fc_quot_unit_price
rec.fc_quot_sst = record.fc_quot_sst
rec.save()
The button is located on each row in the list as below:
I only have one problem with this approach, which is when the copying finished, the List in frontend is not refreshing, and I have manually refresh the browser. This is very inconvenient for users.
I want to be able to behave as we update the child records using parent’s SAVE button as below:
Bromo

