Skip to Content
Menu
This question has been flagged
4 Replies
10244 Views

Hi All,

class EquipmentCreation(models.Model):
    _name = "assets.creation"

     owner_user_id1 = fields.Many2one('res.users', string='Assignee',readonly=False)


class MaintenanceEquipment(models.Model):
    _inherit = "maintenance.equipment"

      owner_user_id = fields.Many2one('res.users', string='Assignee',readonly=False)


I need data of owner_user_id to owner_user_id1..the moment u save?

How to fetch the data by using create method..??

Avatar
Discard
Best Answer

Hi,

You can super the create method of the model maintenance.equipment and then search the record in the model  assets.creation (based on the relation) and write values into it.

@api.model
def create(self, vals):
res = super(Classname, self).create(vals)
#Here you can search the record in the another model
    #In the vals you will get the required values
#and write the values into it
return res

Also while posting the question use meaning full titles.
Thanks

Avatar
Discard
Best Answer

class MaintenanceEquipment(models.Model):
    _inherit = "maintenance.equipment"

      owner_user_id = fields.Many2one('res.users', string='Assignee',readonly=False)

      @api.model

      def create(self.vals)

          obj = super(MaintenanceEquipment, self).create(vals)

          print('XYZ', vals)

          if obj.owner_user_id:

              print('check in terminal for debugging', obj.owner_user_id)

              obj.owner_user_id.owner_user_id1 = obj.owner_user_id.id

          return obj

    

Go to front-end and do the following steps to see the result.

1. Go "assets.creation" object, and create one record. (here is your owner_user_id1 field in which you get the value by default.

2. Open link in new tab and go to "maintenance.equipment", create record and also fill owner_user_id as you want it to be print in "owner_user_id1".

3. Refresh the window of "assets.creation".

Thanks

Adesh Paul

Avatar
Discard
Best Answer

https://stackoverflow.com/questions/34171367/remove-create-and-edit-from-many2one-fieldlot-id-for-type-outgoing-using-f


I think this link will help you.

Avatar
Discard

The link is for removing the create and edit option from the Many2one field is right ?

Related Posts Replies Views Activity
1
Nov 24
18020
1
Sep 23
1203
3
May 23
4092
7
Apr 23
47094
1
Dec 22
6435