Skip to content

Commit b94791c

Browse files
committed
[add] product_pricelist: models and views are inherited
1 parent 4c650f3 commit b94791c

7 files changed

+80
-0
lines changed

Diff for: product_pricelist/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import models

Diff for: product_pricelist/__manifest__.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
'name': "Book Price Pricelist",
3+
'version': '1.0',
4+
'depends': ['base', 'sale_management', 'account'],
5+
'author': "ppch",
6+
'category': 'Category',
7+
'description': """
8+
Book Price on Sales order line and accunt move line
9+
""",
10+
'license': "LGPL-3",
11+
'data': [
12+
'views/sale_order_line_views.xml',
13+
'views/account_move_line_views.xml',
14+
],
15+
'installable': True,
16+
}

Diff for: product_pricelist/models/__init__.py

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
from . import account_move_line
2+
from . import sale_order_line

Diff for: product_pricelist/models/account_move_line.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from odoo import api, fields, models
2+
3+
4+
class AccountMoveLine(models.Model):
5+
_inherit = "account.move.line"
6+
7+
book_price = fields.Float(
8+
string="Book Price",
9+
compute="_compute_book_price",
10+
store=True
11+
)
12+
13+
@api.depends('product_id', 'quantity', 'move_id.invoice_origin')
14+
def _compute_book_price(self):
15+
pass
16+
#define

Diff for: product_pricelist/models/sale_order_line.py

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from odoo import api, fields, models
2+
3+
4+
class SaleOrderLine(models.Model):
5+
_inherit = "sale.order.line"
6+
7+
book_price = fields.Float(
8+
string="Book Price",
9+
compute="_compute_book_price",
10+
store=True
11+
)
12+
13+
@api.depends('product_id', 'product_uom_qty')
14+
def _compute_book_price(self):
15+
for record in self:
16+
if not record.product_id:
17+
record.book_price = 0.0
18+
else:
19+
record.book_price = record._get_pricelist_price() * record.product_uom_qty

Diff for: product_pricelist/views/account_move_line_views.xml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<odoo>
3+
<record id="account_move_form_inherite_book_price" model="ir.ui.view">
4+
<field name="name">account.move.form.inherite.book.price</field>
5+
<field name="model">account.move</field>
6+
<field name="inherit_id" ref="account.view_move_form"/>
7+
<field name="arch" type="xml">
8+
<xpath expr="//notebook//page//field[@name='invoice_line_ids']//list//field[@name='quantity']" position="before">
9+
<field name="book_price" readonly="True"/>
10+
</xpath>
11+
</field>
12+
</record>
13+
</odoo>

Diff for: product_pricelist/views/sale_order_line_views.xml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<odoo>
3+
<record id="sale_order_form_inherite_book_price" model="ir.ui.view">
4+
<field name="name">sale.order.form.inherite.book.price</field>
5+
<field name="model">sale.order</field>
6+
<field name="inherit_id" ref="sale.view_order_form"/>
7+
<field name="arch" type="xml">
8+
<xpath expr="//notebook//page//list//field[@name='product_uom_qty']" position="before">
9+
<field name="book_price" readonly="True"/>
10+
</xpath>
11+
</field>
12+
</record>
13+
</odoo>

0 commit comments

Comments
 (0)