Odoo Help

Welcome!

This community 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.

3

Need a feature for identifying how an SO was created, if by Create or by Duplicate.

By
Santiago EV
on 7/18/16, 1:58 PM 334 views

How can I add a field to the SO table where I can check it if the SO was created by a user via the Create New SO button or if by Duplicate button from an existing PO?

Thanks

2

deep

--deep--
1617
| 5 4 7
Bengaluru, India
--deep--

Techno-Functional Associate with 6+ years of experience in Odoo (formerly known as OpenERP).

deep
On 7/19/16, 9:22 AM

Create button will trigger the ORM method "create"

similarly Duplicate Action will trigger the ORM method "copy"

So you can inherit the copy method, and append a flag (probably a boolean: set it as true) to the param "default" before returning the super call


Note:

There are 2 methods/ways involved while duplicating a record.

"copy" : will copy the data and creates a new record, returning the ID of the newly created one.

"copy_data": will just copy the data and returns you the dict of values which are being copied.

So according to your need, use the appropriate one.

Thanks! Do you have an example? I would only mark the SOs with copy, I would want to use the copy (not copy_data). So like:

def copy(self, cr, uid, id, default={}, context=None):

if not default:

default = {}

default.update({

'[field]': '[value]',

})

return super([class], self).copy(cr, uid, id, default, context=context)`

Santiago EV
on 7/19/16, 12:02 PM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 7/18/16, 1:58 PM
Seen: 334 times
Last updated: 7/19/16, 9:22 AM