Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
2 Antwoorden
2558 Weergaven

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
Annuleer
Auteur Beste antwoord

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
Annuleer

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 ?

Beste antwoord

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
Annuleer
Gerelateerde posts Antwoorden Weergaven Activiteit
3
mrt. 25
10558
2
okt. 21
4291
0
apr. 24
954
0
jan. 24
169
1
nov. 22
8081