Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
2637 Lượt xem

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
Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ

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 ?

Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
3
thg 3 25
10725
2
thg 10 21
4372
0
thg 4 24
1004
0
thg 1 24
169
1
thg 11 22
8148