Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
1 Відповісти
4132 Переглядів

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

Related Posts Відповіді Переглядів Дія
2
серп. 22
11651
2
трав. 21
8548
2
бер. 24
11960
5
вер. 20
6264
1
груд. 19
9677