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
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"xml.symbols.enabled": false,
"python.languageServer": "None"
}
1 change: 1 addition & 0 deletions estate_pricelist_imp/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
19 changes: 19 additions & 0 deletions estate_pricelist_imp/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "Sales Pricelist",
"version": "19.0.0",
"category": "Tutorials",
"depends": ["sale", "account"],
"author": "hemeh",
"application": True,
"summary": "Estate Account",
"description": """
Estate Pricelist Sales.
""",
"data": [
"views/estate_pricelist.xml",
"views/estate_account_pricelist.xml",
],
"website": "https://odoo.com",
"license": "LGPL-3",
"installable": True,
}
1 change: 1 addition & 0 deletions estate_pricelist_imp/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import account_move_line, sale_order_line
15 changes: 15 additions & 0 deletions estate_pricelist_imp/models/account_move_line.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from odoo import api, fields, models


class EstateAccountPrice(models.Model):
_inherit = 'account.move.line'
_description = "Invoicing Book Price"
book_price = fields.Monetary(compute="_compute_book_price", readonly=True)

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


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

book_price = fields.Monetary(compute="_compute_book_price", readonly=True)

@api.depends('product_uom_qty', 'product_id', 'order_id.pricelist_id')
def _compute_book_price(self):
for line in self:
if not line.product_id:
line.book_price = 0.0
continue

pricelist = line.order_id.pricelist_id

if pricelist:
line.book_price = pricelist._get_product_price(
product=line.product_id,
quantity=line.product_uom_qty,
)
else:
line.book_price = line.product_id.list_price
13 changes: 13 additions & 0 deletions estate_pricelist_imp/views/estate_account_pricelist.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">account.move.line.form.inherit.book.price</field>
<field name="model">account.move</field>
<field name="inherit_id" ref="account.view_move_form"/>
<field name="arch" type="xml">
<xpath expr="//notebook//page//list//field[@name='quantity']" position="before">
<field name="book_price" />
</xpath>
</field>
</record>
</odoo>
13 changes: 13 additions & 0 deletions estate_pricelist_imp/views/estate_pricelist.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="sale_order_line_view_form_inherit" model="ir.ui.view">
<field name="name">sale.order.form.inherit.book.price</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form" />
<field name="arch" type="xml">
<xpath expr="//notebook//page//list//field[@name='product_uom_qty']" position="before">
<field name="book_price" />
</xpath>
</field>
</record>
</odoo>