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

If I create a sale order and the forecasted quantity for a product is 0, I don't get an error, but the value simply becomes negative. I tried to do it the same way as it is done in MrpProduction, but I can't do it. I found the module "Sale Quantity Non-zero" on the Internet, but it is written for version 8 of odoo, and I am using version 14.

Sale Quantity Non-zero realization:

@api.one
    @api.constrains('product_uom_qty', 'product_uos_qty')
    def constraint_qty(self):

        if float_compare(0, self.product_uom_qty, precision_digits=2) >= 0:
            raise exceptions.ValidationError(
                _('Product quantity cannot be less than one!')
            )
        if float_compare(0, self.product_uos_qty, precision_digits=2) >= 0:
            raise exceptions.ValidationError(
                _('Product UoS quantity cannot be less than one!')
            )


My realizations (but its didn work):

_inherit = ['product.product']

@api.onchange('virtual_available')
def constraint_qty(self):

if float_is_zero(self.virtual_available, precision_digits=2):
raise UserError(
_('Product quantity cannot be less than one!')
)

MrpProduction realization:

def _pre_button_mark_done(self):
productions_to_immediate = self._check_immediate()
if productions_to_immediate:
return productions_to_immediate._action_generate_immediate_wizard()

for production in self:
if float_is_zero(production.qty_producing, precision_rounding=production.product_uom_id.rounding):
raise UserError(_('The quantity to produce must be positive!'))
if not any(production.move_raw_ids.mapped('quantity_done')):
raise UserError(_("You must indicate a non-zero amount consumed for at least one of your components"))

consumption_issues = self._get_consumption_issues()
if consumption_issues:
return self._action_generate_consumption_wizard(consumption_issues)

quantity_issues = self._get_quantity_produced_issues()
if quantity_issues:
return self._action_generate_backorder_wizard(quantity_issues)
return True
아바타
취소
작성자 베스트 답변

When you create quotes in the sales module, forecasted still becomes negative. I've already tried three modules, and none of them help at all.

this is "virtual_available" field

아바타
취소

This is an expected behaviour , so how you are trying to alter this behaviour? Need to block the creation of quotation or can't confirm the order when there is no stock ?

베스트 답변

Hi,
If you are looking to prevent quantities getting negative in the system, you can use this module:  https://apps.odoo.com/apps/modules/16.0/stock_no_negative/

or you can refer the coding done.

Thanks

아바타
취소
관련 게시물 답글 화면 활동
3
3월 25
11181
2
10월 21
4518
0
4월 24
1170
0
1월 24
169
1
11월 22
8368