Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
4 Răspunsuri
11098 Vizualizări

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..??

Imagine profil
Abandonează
Cel mai bun răspuns

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

Imagine profil
Abandonează
Cel mai bun răspuns

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

Imagine profil
Abandonează
Cel mai bun răspuns

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.

Imagine profil
Abandonează

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

Related Posts Răspunsuri Vizualizări Activitate
1
nov. 24
20198
1
sept. 23
3013
3
mai 23
5624
7
apr. 23
48984
1
dec. 22
7859