我如何将 ratecard_multiple 中的 schedule_for 传递给 ratecard_sin_radio 中的 schedule ,以便我可以在 radio_sin_radio 函数 action_four_weeks_schedule_form 中使用它 在这里我添加了所有正在使用的代码
class ratecard_multiple(models.Model):
# pudb.set_trace()
_name = 'ratecard.multiple'
_rec_name = 'display_name'
name = fields.Char(string='Multiple RateCard Product Name ', required=True)
code = fields.Char(string='Multiple RateCard Code ', readonly=True)
scheduled_for = fields.Integer(string='SCHEDULED FOR', default=1, track_visibility='always', store=True)
# scheduled_for = fields.Integer(string='SCHEDULED FOR', compute='_compute_scheduled_for',default=1 ,track_visibility='always',store=True)
min_weeks = fields.Integer(string="MINIMUM NO OF WEEKS", default=1, store=True)
max_weeks = fields.Integer(string="Maximum NO OF WEEKS", default=1, track_visibility='always', store=True)
multiple_ratecard_id = fields.Many2many(comodel_name='ratecard.sin.radio',
relation='ratecard_multiple_singular_rel',
column1='ratecard_multiple_id',
column2='ratecard_sin_radio_id',
string='RATECARDS')
class ratecard_sin_radio(models.Model):
_name = 'ratecard.sin.radio'
_description = 'RATECARD SINGULAR RADIO '
code = fields.Char(string='RADIO SINGULR RATECARD CODE', readonly=True)
name = fields.Char(string='NAME')
outlet_id = fields.Many2one(comodel_name='outlet', string='Outlet')
timeband_id = fields.Many2one(comodel_name='timeband', string='TimeBand')
def action_four_weeks_schedule_form(self,cr,uid,ids,context):
order_obj = self.pool.get('ratecard.multiple').browse(cr,uid,ids)[0]
return {
'name':_("Four Week Schedule to Process"),
'view_mode': 'form',
'view_id': False,
'view_type': 'form',
'res_model': 'four.weeks.schedule',
'context':{'default_scheduled_for': order_obj.scheduled_for, 'default_code': order_obj.code},
'type': 'ir.actions.act_window',
'nodestroy': True,
'target': 'new',
'domain': '[]',
'flags': {'form': {'action_buttons': True}}
}
class FourWeeksSchedule(models.Model):
_name = 'four.weeks.schedule'
code = fields.Char( string='RateCard Code ',)
scheduled_for = fields.Integer(string='SCHEDULED FOR', track_visibility='always', store=True)
from_date = fields.Date(
'From Date', required=True, default=lambda self: fields.Date.today())
to_date = fields.Date(
'To Date', required=True, default=lambda self: fields.Date.today())
monday = fields.Integer(string='MON')
tuesday = fields.Integer(string='TUE')
wednesday = fields.Integer(string='WED')
thursday = fields.Integer(string='THUR')
friday = fields.Integer(string='FRI')
saturday = fields.Integer(string='SAT')
sunday = fields.Integer(string='SUN')
spot_total = fields.Integer(compute='compute_totalspots', string='SPOTS TOTAL', readonly=True, store=True)
In the view of the ratecard.multiple i have this
<tree editable="bottom">
<group colspan="2" col="2" >
<field name="name"/>
<field name='display_name'/>
<field name='code'/>
<field name="validity_date"/>
<field name="scheduled_for"/>
<field name="min_weeks"/>
<field name="max_weeks"/>
<!--<field name="multiple_ratecard_id_count"/>-->
<field name="multiple_ratecard_id_count" widget="statinfo"/>
<!--<field name="allocate_schedule_count"/>-->
<!--<field name='company_id'/>-->
</group>
<field name='multiple_ratecard_id' nolabel="1" options="{'reload_on_button': true}"> <!-- widget="many2many"-->
<tree string="ALLOCATE SPOTS" editable="bottom" >
<button name="action_four_weeks_schedule_form" string="CREATE SCHEDULE" type="object" />
<field name="code"/>
<field name="name"/>
<field name="outlet_id" on_change="onchange_outlet(outlet_id)" placeholder="OUTLET"/>
</tree>
</field>
</tree>