Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
518 Lượt xem

Odoo offers the possiblity to apply the a percentage discount on sales order lines, and that results in a nice visual indication with strikethrough and new price.

But if you have a product with a listprice of 4868 euro, and as a sales person i want to sell it at 4500 ... i would prefer to be able to enter that. instead of having to calculate the percentage and apply that.


how would we do this ?

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hello there,

If you wish to show the customer, the sales price of the product has been changed, as in a discount on sales order lines,

  • Then, click the Discount button, choose the Fixed amount & enter the desired amount.

  • which creates another sales order line with a negative unit price, or else create a "Discount" as product name with Service type & all to the sales order line with a negative unit price



The preview would be,



Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi,


A better way is to add a new field called “Net Price” on the sales order line. With this field, the salesperson just types the final price they want to sell at (e.g., 4500). Odoo will then automatically calculate the correct discount percentage in the background and apply it. That way:


    The salesperson works directly with the real selling price they agreed on.


    Odoo still shows the discount percentage and the strikethrough list price on the quotation, so the customer sees the discount clearly.


Try with the following code,


Python


class SaleOrderLine(models.Model):

    _inherit = "sale.order.line"


    net_price = fields.Float(

        string="Net Price",

        help="Final selling price entered directly by the salesperson."

    )


    @api.onchange('net_price')

    def _onchange_net_price(self):

        for line in self:

            if line.net_price and line.price_unit:

                # Calculate discount %

                discount = (1 - (line.net_price / line.price_unit)) * 100

                line.discount = max(discount, 0.0)


XML


<record id="view_order_form_net_price" model="ir.ui.view">

        <field name="name">sale.order.form.net.price</field>

        <field name="model">sale.order</field>

        <field name="inherit_id" ref="sale.view_order_form"/>

        <field name="arch" type="xml">

            <xpath expr="//field[@name='order_line']/tree/field[@name='discount']" position="after">

                <field name="net_price"/>

            </xpath>

            <xpath expr="//field[@name='order_line']/form/field[@name='discount']" position="after">

                <field name="net_price"/>

            </xpath>

        </field>

    </record>



Hope it helps

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 9 25
469
1
thg 1 25
2113
2
thg 11 24
1386
1
thg 2 24
1675
0
thg 12 23
1258