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.

1

how to set default location_src_id (Odoo)

By
Adnier Rosello
on 10/2/15, 10:23 AM 504 views

I need to know how to put on a production order, an stock location by default that I've created, I see the use of "_src_id_default" function, but I don't know how to add the second parameter (xml_id) of "get_object_reference" function, any solution?

Greetings

1

Akhil P Sivan

--Akhil P Sivan--
3423
| 5 3 6
Kochi, India
--Akhil P Sivan--

Interested in exploring Odoo both technically & functionality wise.

email-id : akhilpsivan01@gmail.com

Akhil P Sivan
On 10/2/15, 1:59 PM

Hi,

One option is to override the "_src_id_default" function, to get your desired location as default source location.

For that you just need to redefine the field and function in your custom module python file. Just put the following code in your .py file. Replace the search term by your location name. Hope you are working in v8.

class mrp_production(models.Model):
_inherit = 'mrp.production'


def _src_id_default(self):

location_id = self.env['stock.location'].search([('name', '=', 'My Location')])
if location_id.id:
return location_id.id
else:
return False

location_src_id = fields.Many2one('stock.location', string = 'Raw Materials Location', required=True,
readonly=True, states={'draft': [('readonly', False)]},
help="Location where the system will look for components.", default=_src_id_default)

thanks Akhil, I have tried the solution and it is working perfectly.

Adnier Rosello
on 10/5/15, 4:22 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: 10/2/15, 10:23 AM
Seen: 504 times
Last updated: 10/6/15, 2:16 AM