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 pricelist_price/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
15 changes: 15 additions & 0 deletions pricelist_price/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
'name': 'pricelist_price',
'author': 'soham',
'version': "1.0",
'description': 'Added pricelist price',
'depends': ['sale_management'],
'license': 'LGPL-3',
'data': [
'views/account_move_line_view.xml',
'views/sale_order_line_view.xml'
],
'application': True,
'installable': True,
'auto-install': True,
}
2 changes: 2 additions & 0 deletions 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
19 changes: 19 additions & 0 deletions pricelist_price/models/account_move_line.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from odoo import api, fields, models


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

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

@api.depends("sale_line_ids.book_price")
def _compute_book_price(self):
for line in self:
if line.sale_line_ids:
line.book_price = line.sale_line_ids[0].book_price
else:
line.book_price = 0.0
17 changes: 17 additions & 0 deletions pricelist_price/models/sale_order_line.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from odoo import models, fields, api


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

book_price = fields.Float(compute="_compute_pricelist", readonly=True)

@api.depends("product_id", "product_uom_qty", "order_id.pricelist_id", "product_template_id.list_price")
def _compute_pricelist(self):
for record in self:
if not record.product_id:
record.book_price = 0.0
elif not record.order_id.pricelist_id:
record.book_price = record.product_template_id.list_price
else:
record.book_price = record.order_id.pricelist_id._get_product_price(record.product_id, record.product_uom_qty)
12 changes: 12 additions & 0 deletions pricelist_price/views/account_move_line_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<odoo>
<record id="view_move_form" model="ir.ui.view">
<field name="name">account.move.view.form.inherit</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='quantity']" position="before">
<field name="book_price" invisible="move_type != 'out_invoice'"/>
</xpath>
</field>
</record>
</odoo>
12 changes: 12 additions & 0 deletions pricelist_price/views/sale_order_line_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<odoo>
<record id="sale_order_from_pricelist" model="ir.ui.view">
<field name="name">sale.order.view.form.inherit</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="arch" type="xml">
<xpath expr="//list//field[@name='product_uom_qty']" position="before">
<field name="book_price"/>
</xpath>
</field>
</record>
</odoo>