Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
3786 Lượt xem

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.



Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

If you find answer for this means please post here

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 10 19
6555
1
thg 5 19
5549
1
thg 3 18
11401
3
thg 5 17
11148
2
thg 7 25
4331