Showing posts with label Procurement. Show all posts
Showing posts with label Procurement. Show all posts

Wednesday, 15 March 2017

ValueError Expected singleton in Odoo

Expected Singleton:

Class methods required single invoking object (Single Browsable Record) to invoke the method and suppose it will call by multiple invoking objects (Browsable Recordsets) then method is not able to identify for which object it should process, therefore it will raise an error Expected Singleton.

New API decorator is used to define method calling pattern whether methods allows only single object or multiple objects to invoke this method.


For Example:


if self.location_id:     #face ValueError Expected singleton because self contains multiple recordset.

    ########

Need to change with following:

for warehouse in self:

    if warehouse.location_id:

        ########


@api.one

This decorator loops automatically on Records of RecordSet for you. Self is redefined as current record

Note:

Caution: the returned value is put in a list. This is not always supported by the web client, e.g. on button action
methods. In that case, you should use @api.multi to decorate your method, and probably call self.ensure_one() in
the method definition.

@api.multi

Self will be the current RecordSet without iteration. It is the default behavior (multiple browsable objects). Methods which returns non premitive type data(list, dictionary, function) must be decorated with @api.multi

@api.model

This decorator will convert old API calls to decorated function to new API signature. It allows to be polite when
migrating code. Self does not contain any record/recordset in methods which are decorated by this decorator.

So simply call like this

self.env['model_name'].method_name(arguments)

Monday, 21 September 2015

What is procurement ? | Odoo

Procurement is "The action of obtaining for required products".  On confirming Sale Order or checking minimum stock rules for replenishment, a demand of stock will be generated. So procurement is the process to prepare and process on that demand.  
Procurement is the central place where system decides what to do against demand. Whether to purchase or to produce upon product's routes. The process of procurement is often part of a company's strategy because the ability to purchase certain materials will determine if operations will continue or not. A business will not be able to survive, if it's price of procurement is more than the profit it makes on selling the actual product.

In a nutshell, Procurement = Acquisition process to obtain required materials.