Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
1 Balas
3547 Tampilan

I have 2 models, 'cus.enq' and 'cus.act'. The models for customer enquiries and customer activities. Some fields in both models are common. 

#cus.enq

class CustomerEnquiries(models.Model):

    _name = 'cus.enq'


    task_ids = fields.One2many('cus.act', 'enquiries_id')

    partner_id = fields.Many2one('res.partner', string="Customer Name")

    source_id = fields.Many2one('utm.source', string="Source")

    email = fields.Char()

    partner_phone = fields.Char(string="Phone")

    partner_mobile = fields.Char(string="Mobile")

Here i have a one2many field that is related to 'cus.act' model.

#cus.act

class CustomerActivities(models.Model):

    _name = 'cus.act'

    

    action_id = fields.Many2one('lmc.action', required=True, string="Action")

    create_uid = fields.Many2one('res.users', string="Created By", readonly=True)

    source_id = fields.Many2one('utm.source', string="Source")

    partner_id = fields.Many2one('res.partner', string="Client")

    partner_phone = fields.Char(string="Phone")

    user_id = fields.Many2one('res.users', string="Responsible")

    partner_mobile = fields.Char(string="Mobile")

    email = fields.Char()

    enquiries_id = fields.Many2one('lmc.enq')

#xml

<notebook>

    <page string="Related Tasks">
<group>
<field name="task_ids" nolabel="1">

      <tree editable="bottom"

    <field name="create_uid"/>

      <field name="action_id"/>

      <field name="user_id"/>
</tree>

      </field>

      </group>

        </page>

 </notebook>

#notes

in xml the page is one2many of cus.enq module.My question is i want to create the record of models 'cus.act' from the model 'cus.enq'. How it is possible. I want to create the create when the save button is pressed.I know the create method is used here.Please help me how it is used here.Thanks in advance.



Avatar
Buang
Jawaban Terbai

If you find answer for this means please post here

Avatar
Buang
Post Terkait Replies Tampilan Aktivitas
2
Okt 19
6284
1
Mei 19
5294
1
Mar 18
11017
3
Mei 17
10943
2
Des 24
7120