-
Notifications
You must be signed in to change notification settings - Fork 3k
[ADD] product_pricelist: Book price added in Sale Order Line #398
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
03ad262
4cd71df
eed4ae3
ef05a40
128c007
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| from . import models |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| { | ||
| 'name': "Book Price (Pricelist Price)", | ||
| 'version': '1.0', | ||
| 'depends': ['base', 'sale_management'], | ||
| 'author': "ppch", | ||
| 'category': 'Category', | ||
| 'description': """ | ||
| Book Price (Pricelist Price) on sales order lines and invoice lines | ||
| which will be used to compare between Book Price (Pricelist Price) and | ||
| manually adjusted price on the lines. | ||
| """, | ||
ppch-odoo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| 'license': "LGPL-3", | ||
| 'data': [ | ||
| 'views/sale_order_line_views.xml', | ||
| 'views/account_move_line_views.xml', | ||
| ], | ||
| 'installable': True, | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| from . import account_move_line | ||
| from . import sale_order_line |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| 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') | ||
|
|
||
| @api.depends('product_id', 'quantity', 'move_id.invoice_origin') | ||
| def _compute_book_price(self): | ||
| sale_orders = {so.name: so for so in self.env['sale.order'].search([('name', 'in', self.mapped('move_id.invoice_origin'))])} | ||
|
||
| for record in self: | ||
| if not record.product_id: | ||
| record.book_price = 0.0 | ||
| continue | ||
|
|
||
| sale_order = sale_orders.get(record.move_id.invoice_origin) | ||
| if sale_order: | ||
| record.book_price = sale_order.pricelist_id._get_product_price( | ||
| record.product_id, record.quantity | ||
| ) * record.quantity | ||
| else: | ||
| record.book_price = record.product_id.lst_price * record.quantity | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| 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') | ||
|
|
||
| @api.depends('product_id', 'product_uom_qty', 'order_id.pricelist_id') | ||
| def _compute_book_price(self): | ||
| for record in self: | ||
| if not record.product_id: | ||
| record.book_price = 0.0 | ||
| continue | ||
|
|
||
| pricelist = record.order_id.pricelist_id if record.order_id else None | ||
| if pricelist: | ||
| record.book_price = pricelist._get_product_price( | ||
| record.product_id, record.product_uom_qty | ||
| ) * record.product_uom_qty | ||
|
||
| else: | ||
| record.book_price = record.product_id.lst_price * record.product_uom_qty | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <odoo> | ||
| <record id="account_move_form_inherit_book_price" model="ir.ui.view"> | ||
| <field name="name">account.move.form.inherite.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//field[@name='invoice_line_ids']//list//field[@name='quantity']" position="before"> | ||
| <field name="book_price" readonly="True" column_invisible="context.get('default_move_type') != 'out_invoice'"/> | ||
| </xpath> | ||
| </field> | ||
| </record> | ||
| </odoo> |
| 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_form_inherit_book_price" model="ir.ui.view"> | ||
| <field name="name">sale.order.form.inherite.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" readonly="True"/> | ||
| </xpath> | ||
| </field> | ||
| </record> | ||
| </odoo> |
Uh oh!
There was an error while loading. Please reload this page.