Skip to Content
Menu
This question has been flagged
6 Replies
4157 Views

¿Its possible to raise a warning when adding a product to an invoice?

This functionality is currently working fine in the sales module. If i create a quotation, and add a product with a warning configured, the message is displayed. However, in the invoicing module, nothing happens.

This only happens with products, if i set a warning in a partner, this works fine.

Version: 11.0CE

Avatar
Discard

Hi, have a look at this paid solution - https://apps.odoo.com/apps/modules/11.0/smart_warnings/. It let configure almost any sort of warnings for any document

Author

Thanks for the suggestion! However if a user validates the invoice without saving it prior, will the warning be displayed before the invoice confirmation?

Anyway, i'll keep in mind the plugin for other projects.

Yes, warnings are regretfully shown only after reloading (after saving or refreshing a page, e.g.)

Best Answer

Hello, 

Currently in Odoo warning on the onchange product is available for the only sale.order  (Sale module). It is not raised when you change the product in account.invoice.  Generally in Odoo invoice is created from sale.order so they are not put this option in invoicing. 

So to raise a warning on adding a product to an invoice you have to call the onchange method of product in account.invoice and raise warning.

you can refer the below method in sale module sale.py : 1002:

@api.multi

    @api.onchange('product_id')

    def product_id_change(self):

        if not self.product_id:

            return {'domain': {'product_uom': []}}


        vals = {}

        domain = {'product_uom': [('category_id', '=', self.product_id.uom_id.category_id.id)]}

        if not self.product_uom or (self.product_id.uom_id.id != self.product_uom.id):

            vals['product_uom'] = self.product_id.uom_id

            vals['product_uom_qty'] = 1.0


        product = self.product_id.with_context(

            lang=self.order_id.partner_id.lang,

            partner=self.order_id.partner_id.id,

            quantity=vals.get('product_uom_qty') or self.product_uom_qty,

            date=self.order_id.date_order,

            pricelist=self.order_id.pricelist_id.id,

            uom=self.product_uom.id

        )


        result = {'domain': domain}


        title = False

        message = False

        warning = {}

        if product.sale_line_warn != 'no-message':

            title = _("Warning for %s") % product.name

            message = product.sale_line_warn_msg

            warning['title'] = title

            warning['message'] = message

            result = {'warning': warning}

            if product.sale_line_warn == 'block':

                self.product_id = False

                return result


        name = product.name_get()[0][1]

        if product.description_sale:

            name += '\n' + product.description_sale

        vals['name'] = name


        self._compute_tax_id()


        if self.order_id.pricelist_id and self.order_id.partner_id:

            vals['price_unit'] = self.env['account.tax']._fix_tax_included_price_company(self._get_display_price(product), product.taxes_id, self.tax_id, self.company_id)

        self.update(vals)


        return result


If you want more help you can contact us.

Thank You.

Avatar
Discard
Best Answer

Hi,

It seems you are looking for something  in invocing like raise a warning if the selected product is out of stock. As you know by default this is there in the sale order but the same is not there in the invoice.

In the invoicing the product is not a required field. If you need the same functionality of the sale in invoicing, you can copy the onchange function in the sale which raise the warning to invoicing.


Thanks

Avatar
Discard
Author

No, i'm not looking to an out of stock warning, i'm looking to a configurable warning in the product, so if a user adds the product to the invoice, the warning is displayed (just like the sales order function).

It's because we do an activity which sometimes is taxed, and sometimes no, so the warning serves as a reminder so the correct taxes are applied.

Related Posts Replies Views Activity
0
Jan 23
1751
1
Apr 25
136
0
Nov 24
1646
0
Mar 23
2217
1
Mar 23
3388