Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
2 Odpovědi
2512 Zobrazení

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
Avatar
Zrušit
Autor Nejlepší odpověď

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

Avatar
Zrušit

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 ?

Nejlepší odpověď

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

Avatar
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
3
bře 25
10331
2
říj 21
4208
0
dub 24
927
0
led 24
169
1
lis 22
8030