Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions sale_pricelist_price/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
11 changes: 11 additions & 0 deletions sale_pricelist_price/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "Pricelist Price",
"description": "Client will have the ability to see the original price(book price) on sale order and incoice line.",
"depends": ["sale_management"],
"data": [
"views/sale_order_views.xml",
"views/account_move_views.xml",
],
"installable": True,
"license": "LGPL-3",
}
2 changes: 2 additions & 0 deletions sale_pricelist_price/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import sale_order_line
from . import account_move_line
9 changes: 9 additions & 0 deletions sale_pricelist_price/models/account_move_line.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from odoo import fields, models


class AccountMoveLine(models.Model):
_inherit = "account.move.line"

book_price = fields.Float(
string="Book Price", related="sale_line_ids.book_price", readonly=True
)
19 changes: 19 additions & 0 deletions sale_pricelist_price/models/sale_order_line.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from odoo import api, fields, models


class SaleOrderLine(models.Model):
_inherit = "sale.order.line"

book_price = fields.Float(
string="Book Price", compute="_compute_book_price", store=True
)

@api.depends("product_id", "product_uom_qty", "order_id.pricelist_id")
def _compute_book_price(self):
for line in self:
if line.product_id and line.order_id.pricelist_id:
line.book_price = line.order_id.pricelist_id._get_product_price(
product=line.product_id, quantity=line.product_uom_qty
)
else:
line.book_price = 0.0
13 changes: 13 additions & 0 deletions sale_pricelist_price/views/account_move_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="view_move_form" model="ir.ui.view">
<field name="name">view.move.form.inherit.sale.pricelist.price</field>
<field name="model">account.move</field>
<field name="inherit_id" ref="account.view_move_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='invoice_line_ids']/list/field[@name='quantity']" position="before">
<field name="book_price" readonly="1" column_invisible="parent.move_type != 'out_invoice'"/>
</xpath>
</field>
</record>
</odoo>
17 changes: 17 additions & 0 deletions sale_pricelist_price/views/sale_order_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="view_order_form_inherit_sale_pricelist_price" model="ir.ui.view">
<field name="name">sale.order.form.inherit.sale.pricelist.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']/list/field[@name='product_uom_qty']" position="before">
<field name="book_price" readonly="1"/>
</xpath>
<xpath expr="//field[@name='order_line']/list" position="attributes">
<attribute name="decoration-success">price_unit &gt; book_price</attribute>
<attribute name="decoration-danger">price_unit &lt; book_price</attribute>
</xpath>
</field>
</record>
</odoo>