Odoo Help

3

0
12 Answers
3
Avatar

Andreas Brueckl Austria

--Andreas Brueckl--

5536
| 8 8 9
Vienna, Austria
--Andreas Brueckl--
OpenERP Consulting and Development
Andreas Brueckl Austria
2/22/13, 5:01 AM

If you are familiar with OpenERP modules I would suggest to override the create()-method in product.product:

class product_product(osv.Model):
    _inherit = 'product.product'

    def create(self, cr, uid, data, context=None):
        prod_id = super(product_product, self).create(cr, uid, data, context=context)

        vals = {
           'product_id': prod_id,
           ....
        }
        self.pool.get('stock.warehouse.orderpoint').create(cr, uid, vals, context=context)
        return prod_id

But it is not that easy because there are other required fields in stock.warehouse.orderpoint which you would have to populate. (e.g. warehouse_id, location_id).

If you use 'Automated Actions', the problem with the required fields also exist. However I do not think that is possible apply Automated Actions on created objects.

1 Comment
Hachem Chraiti Tunisia
5/9/14, 7:28 AM

i can not find the create method of the product?? from which method the product creation is handled?

0
Herve GUERIN France
9/15/17, 10:40 AM

Hi,

Thanks to 

I needed this trick in odoo v8, so here is my version :


    class ProductProduct(models.Model):

      _inherit = 'product.product' 

      @api.model

      def create(self, data, context=None):

        """ add a default orderpoint line to every new product """

        product = super(ProductProduct, self).create(data, context=context)

        # apply same domain rule as the one of button "Règles de réassort" of the odoo-web interface

        if product.product_tmpl_id.type != 'service':

            # add automatically the orderpoint (règle d'approvisionnement)

            vals = {

               'product_id': product.id,

               'product_min_qty': 0,

               'product_max_qty': 0,

               'qty_multiple': 1,

            }

            # desperatly a call with old api way but I didn't succeded to do this with the new api way

            self.pool.get('stock.warehouse.orderpoint').create(self._cr, self._uid, vals, context=context)

        return product


Now, I'd like to add a rule to check if the sub-record stock.warehouse.orderpoint is still there when there is an update (otherwize, the integrity is not fully checked)

0
Jānis Latvia
2/13/13, 4:49 AM

Hope this will help you:

go to product card and open page Procurements and in section Suppliers make new entry with minimal quantity.

1 Comment
Altınkaya Elektronik Cihaz Kutuları imalat Ticaret ltd sti, Ahmet Altinisik Turkey
2/13/13, 5:02 AM

sorry maybe question was not clear enogh, I updated the question

0
Gilles Major (gim) Belgium
2/13/13, 4:57 AM

I'm not exactly sure what you mean.

If what you're concerned about is defining minimum quantities for purchases: - go to the product form => procurements tab. In the Suppliers section, you can define a minimal order quantity for a given supplier (you need to activate "Manage pricelist per supplier" in the purchase settings first).

1 Comment
Altınkaya Elektronik Cihaz Kutuları imalat Ticaret ltd sti, Ahmet Altinisik Turkey
2/13/13, 4:59 AM

When creating a new product I want a default minimum order quantitiy value to be added automatically. I am not asking how to define minimum order quantitiy.

Ask a Question
Writer
Keep Informed
1 follower(s)
About This Community

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

Register
Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now