تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
4 الردود
11097 أدوات العرض

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
نوفمبر 24
20197
1
سبتمبر 23
3013
3
مايو 23
5624
7
أبريل 23
48981
1
ديسمبر 22
7859