Odoo Aide

0

0
1 Answer
2
Avatar

Niyas Raphy

--Niyas Raphy--
24469
| 7 7 11
Wayanad, Inde
--Niyas Raphy--

Odoo Techno Functionalist

Feel free to connect :  niyasraphyk@gmail.com

Twitter:https://twitter.com/niyasraphy
LinkedIn: https://www.linkedin.com/in/niyasraphy/
FB:https://www.facebook.com/niyasraphy123

Happy to help :)

Niyas Raphy
11/01/2018 00:28

Hi,

self.copy is enough for taking a copy of the current record. On clicking the button a new record , which is duplicate of current record will be created.

Thanks

7 Comments
Manish Kumar Bohra
11/01/2018 00:32

If i want to open duplicate sale order on other other model, then what should i do?

I have customer id(sale order id) on that model.

Niyas Raphy
11/01/2018 00:46

Didn't understand, are you looking to take copy of the sale order from other model ?

Manish Kumar Bohra
11/01/2018 00:51

Yes..!!!!!!

Niyas Raphy
11/01/2018 01:13

try something like this , self.env['model_name'].search([('id', '=', 5)]).copy()

Manish Kumar Bohra
11/01/2018 01:21

Thanks @Niyas,

self.env['operation.process'].search([('id', '=',self.pro_customer_id)]).copy()

Then i getting :

ValueError: Expected singleton: operation.process()

Niyas Raphy
11/01/2018 02:05

try this, self.env['operation.process'].search([('id', '=',self.pro_customer_id)], limit=1).copy()

this will return only one record, for your case we are getting multiple results in search either you have to use ensure_one or iterate the record over the for loop

Manish Kumar Bohra
11/01/2018 02:14

Hello @Niyas,

still getting this error

File "/opt/odoo10/odoo/odoo/models.py", line 4388, in copy

self.ensure_one()

File "/opt/odoo10/odoo/odoo/models.py", line 4822, in ensure_one

raise ValueError("Expected singleton: %s" % self)

ValueError: Expected singleton: operation.process()

for code:-

@api.one

def dup_line(self):

print "Copyyyyyyyyyyyyyyy"

self.env['operation.process'].search([('id', '=',self.pro_customer_id)], limit=1).copy()

Poser une question
Étiquettes
Keep Informed
1 Abonné(e)s
About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register
Odoo Training Center

Access to our eLearning platform and experience all Odoo Apps through learning videos, use cases and quizzes.

Test it now