How to duplicate a line in a sale order?
We are in Odoo 10. I have created a button on each sale order line. We want to duplicate the sale order line in the same sale order when the button is clicked. See image below, the new duplicate icon at the right.
I think that we have to retrieve all the values of the current clicked line and after create the new line.
My skills are too limited to achieve this kind of thing.
COuld you guide me just a little please?
This is not really what we want to achieve, but this would give me a great beginning to achieve the rest.
Our actual code (empty!!!)
_logger.error(" self :: %s", str(self))
In image :
I have now this code for my button :
But I get this error :
The operation cannot be completed, probably due to the following:
- deletion: you may be trying to delete a record while other records still reference it- creation/update: a mandatory field is not correctly set
[object with reference: order_id - order.id]
It is clear that the problem is the order_id field.
With this code, I can easily see the self.order_id in the debug. But the copy() function doesn't include the order_id field.
logger.error(" self.order_id :: %s", str(self.order_id))