diff --git a/__init__.py b/__init__.py index 1c27b3d5ebb6c2e4b58abfa06fb9a74a719ce387..282e9498b6912dcd07b681d5c892677863dfbcd5 100644 --- a/__init__.py +++ b/__init__.py @@ -19,3 +19,4 @@ ############################################################################## from . import wizard # noqa +from . import models # noqa diff --git a/models/__init__.py b/models/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..bcb753da1c31156b9e351d2bab7f0d71c2ffd877 --- /dev/null +++ b/models/__init__.py @@ -0,0 +1 @@ +from . import sale_order_line # noqa diff --git a/models/sale_order_line.py b/models/sale_order_line.py new file mode 100644 index 0000000000000000000000000000000000000000..92b200010c1e2d93792e1d7fedd62fed263418ab --- /dev/null +++ b/models/sale_order_line.py @@ -0,0 +1,17 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from odoo import models, fields, api, _ +from odoo.exceptions import UserError +from odoo.addons import decimal_precision as dp + + +class SaleOrderLine(models.Model): + _inherit = 'sale.order.line' + + price_reduce = fields.Float(compute='_get_price_reduce', string='Price Reduce', digits=dp.get_precision('Product Price'), readonly=True, store=True) + + @api.depends('price_unit', 'discount') + def _get_price_reduce(self): + for line in self: + line.price_reduce = line.price_unit * (1.0 - line.discount / 100.0) \ No newline at end of file diff --git a/wizard/price_info.py b/wizard/price_info.py index 8b4093101522804357e789f4bf4d9ac989114143..4fefa2ffa1e4a68aebe95e798b59325daa91df66 100644 --- a/wizard/price_info.py +++ b/wizard/price_info.py @@ -48,14 +48,10 @@ class PriceInfo(models.TransientModel): namedtuple_args = namedtuple_args or ["query", "arguments"] return namedtuple("queryData", ["query", "arguments"]) - - """ T3078 IMPORTANTE - Quite l.price_reduce de la consulta, puesto que esta depende de - sale_discount_total de https://github.com/gabrielo77/CybroAddons - """ def _select_str(self): select_str = """ - SELECT o.id sale_order_id, l.price_unit, l.product_uom_qty, l.qty_invoiced, l.discount + SELECT o.id sale_order_id, l.price_unit, l.product_uom_qty, l.qty_invoiced, l.discount, + l.price_reduce """ return select_str diff --git a/wizard/price_info_view.xml b/wizard/price_info_view.xml index 7d82e9bc19cd15217d214fbeccb173069beb5298..34b6c00836ca7aa7bd5ec59bf795e19b668abd8a 100644 --- a/wizard/price_info_view.xml +++ b/wizard/price_info_view.xml @@ -19,8 +19,9 @@ <field name="product_uom_qty"/> <field name="qty_invoiced"/> <field name="price_unit"/> - <field name="price_reduce" groups="sale.group_discount_per_so_line"/> - <field name="discount" groups="sale.group_discount_per_so_line"/> + <!--Desde Odoo 13, group_discount_per_so_line esta en product y no en sale--> + <field name="price_reduce" groups="product.group_discount_per_so_line"/> + <field name="discount" groups="product.group_discount_per_so_line"/> </tree> </field> <footer>