跳至內容
選單
此問題已被標幟
1 回覆
4164 瀏覽次數

Hello All,

I have added a button(Re-new) for product type service in inventory module and invoice is already created for that service. Now i want to Re-new(button) this service for next 2 years. So, i want create duplicate sale order on that button with full of data. So, how can i use copy function for this button?

My Coding structure like below:

@api.one
def dup_line(self)
         self.copy()
<button name="dup_line" type="object" string="Re-New" class="oe_highlight"/>

Thanks in advance

頭像
捨棄
最佳答案

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

頭像
捨棄

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.

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

Yes..!!!!!!

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

Thanks @Niyas,

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

Then i getting :

ValueError: Expected singleton: operation.process()

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

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()

相關帖文 回覆 瀏覽次數 活動
2
8月 22
11668
2
5月 21
8556
2
3月 24
11965
5
9月 20
6269
1
12月 19
9679