コンテンツへスキップ
メニュー
この質問にフラグが付けられました
4 返信
11096 ビュー

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

アバター
破棄
最善の回答

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

アバター
破棄
最善の回答

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

アバター
破棄
最善の回答

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.

アバター
破棄

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

関連投稿 返信 ビュー 活動
1
11月 24
20197
1
9月 23
3013
3
5月 23
5624
7
4月 23
48981
1
12月 22
7859