Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
2 Odpowiedzi
2524 Widoki

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
Awatar
Odrzuć
Autor Najlepsza odpowiedź

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

Awatar
Odrzuć

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 ?

Najlepsza odpowiedź

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

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
3
mar 25
10370
2
paź 21
4220
0
kwi 24
933
0
sty 24
169
1
lis 22
8041