-
-
Notifications
You must be signed in to change notification settings - Fork 750
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
[MIG] purchase_last_price_info: Migration to 10.0 #406
Conversation
Can this one be merged? |
@@ -14,16 +11,22 @@ def _get_last_purchase(self): | |||
""" Get last purchase price, last purchase date and last supplier """ | |||
lines = self.env['purchase.order.line'].search( | |||
[('product_id', '=', self.id), | |||
('state', 'in', ['confirmed', 'done'])]).sorted( | |||
('state', 'in', ['purchase', 'done'])]).sorted( | |||
key=lambda l: l.order_id.date_order, reverse=True) | |||
self.last_purchase_date = lines[:1].order_id.date_order | |||
self.last_purchase_price = lines[:1].price_unit | |||
self.last_supplier_id = lines[:1].order_id.partner_id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The search
and sorted
could be replaced by:
self.env['purchase.order.line'].search( [('product_id', '=', self.id), ('state', 'in', ['purchase', 'done'])], order='date_order DESC', limit=1)
Then you can change lines[:1]
to lines
.
Also you can take the date_order
and partner_id
from lines directly.
string='Last Purchase Price', compute='_get_last_purchase') | ||
string='Last Purchase Price', | ||
compute='_get_last_purchase', | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add the digits=dp.get_precision('Product Price')
for display the same decimal precisions as in the lines.
Change For the rest, the module is working. @kittiu if you can't do the changes I can do it. |
ping @kittiu |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Improve Code
"category": "Purchase Management", | ||
"license": "AGPL-3", | ||
"author": "OdooMRP team, " | ||
"AvanzOSC, " | ||
"Serv. Tecnol. Avanzados - Pedro M. Baeza, " | ||
"Ecosoft - Kitti U., " | ||
"Odoo Community Association (OCA)", | ||
"website": "http://www.odoomrp.com", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace website URL as per this
############################################################################## | ||
|
||
# -*- coding: utf-8 -*- | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
from openerp import api, fields, models |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
odoo
Superseeded by #587 |
Propose to merge this module.