콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
12 답글
8748 화면

How to add a default minimum stock rule for newly created products ?

When creating a new product I want a default minimum stock rule to be added automatically. I am not asking how to define minimum stock rule to the product. For normal fields I can define by set defaults menu. However it does not work with minimum stock rule field since there is a create button and a seperate rule is created and selected.

아바타
취소

ok I've deleted both answers since they are not related to your question

Where is "minimum order quantity field"?

작성자

sorry it is "minimum stock rules" since I am using openerp in my native such errors occurs. I just corrected the question.

Just tried editing the default value directly in the database "stock_warehouse_orderpoint" but had no affect - Sorry - i'll bump the question

Maybe by creating an automatic action to be triggered when creating new products? I've seen that this is possible in administrator settings

베스트 답변

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.

아바타
취소

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

베스트 답변

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)

아바타
취소
베스트 답변

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).

아바타
취소
작성자

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.

베스트 답변

Hope this will help you:

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

아바타
취소
작성자

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

관련 게시물 답글 화면 활동
3
8월 24
2081
0
8월 21
2205
2
3월 15
8467
1
12월 24
2520
1
12월 24
1384