-
-
Notifications
You must be signed in to change notification settings - Fork 983
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
158 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg | ||
:alt: License: AGPL-3 | ||
|
||
Product Last Price Info - Sale | ||
================================== | ||
|
||
This module adds the last sale info of the product. | ||
|
||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/sale-workflow/issues>`_. | ||
In case of trouble, please check there if your issue has already been reported. | ||
If you spotted it first, help us smashing it by providing a detailed and welcomed feedback | ||
`here <https://github.com/OCA/sale-workflow/issues/new?body=module:%20sale_last_price_info%0Aversion:%208.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. | ||
|
||
|
||
Credits | ||
======= | ||
|
||
Contributors | ||
------------ | ||
* Alfredo de la Fuente <alfredodelafuente@avanzosc.es> | ||
* Oihane Crucelaegui <oihanecrucelaegi@avanzosc.es> | ||
* Pedro M. Baeza <pedro.baeza@serviciosbaeza.com> | ||
* Ana Juaristi <anajuaristi@avanzosc.es> | ||
|
||
Maintainer | ||
---------- | ||
|
||
.. image:: https://odoo-community.org/logo.png | ||
:alt: Odoo Community Association | ||
:target: https://odoo-community.org | ||
|
||
This module is maintained by the OCA. | ||
|
||
OCA, or the Odoo Community Association, is a nonprofit organization whose | ||
mission is to support the collaborative development of Odoo features and | ||
promote its widespread use. | ||
|
||
To contribute to this module, please visit http://odoo-community.org. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# -*- encoding: utf-8 -*- | ||
############################################################################## | ||
# For copyright and license notices, see __openerp__.py file in root directory | ||
############################################################################## | ||
|
||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# -*- encoding: utf-8 -*- | ||
############################################################################## | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Affero General Public License as published | ||
# by the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Affero General Public License | ||
# along with this program. If not, see http://www.gnu.org/licenses/. | ||
# | ||
############################################################################## | ||
|
||
{ | ||
"name": "Product Last Price Info - Sale", | ||
"version": "1.0", | ||
"category": "Hidden/Dependency", | ||
"license": "AGPL-3", | ||
"author": "OdooMRP team, " | ||
"AvanzOSC, " | ||
"Serv. Tecnol. Avanzados - Pedro M. Baeza, " | ||
"Odoo Community Association (OCA)", | ||
"website": "http://www.odoomrp.com", | ||
"contributors": [ | ||
"Alfredo de la Fuente <alfredodelafuente@avanzosc.es>", | ||
"Oihane Crucelaegui <oihanecrucelaegi@avanzosc.es>", | ||
"Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>", | ||
"Ana Juaristi <anajuaristi@avanzosc.es>", | ||
], | ||
"depends": [ | ||
"sale", | ||
], | ||
"data": [ | ||
"views/product_view.xml", | ||
], | ||
"installable": True, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# -*- encoding: utf-8 -*- | ||
############################################################################## | ||
# For copyright and license notices, see __openerp__.py file in root directory | ||
############################################################################## | ||
|
||
from . import product |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# -*- encoding: utf-8 -*- | ||
############################################################################## | ||
# For copyright and license notices, see __openerp__.py file in root directory | ||
############################################################################## | ||
|
||
from openerp import api, fields, models | ||
|
||
|
||
class ProductProduct(models.Model): | ||
_inherit = 'product.product' | ||
|
||
@api.one | ||
def _get_last_sale(self): | ||
""" | ||
Get last sale price, last sale date and last customer | ||
""" | ||
lines = self.env['sale.order.line'].search( | ||
[('product_id', '=', self.id), | ||
('state', 'in', ['confirmed', 'done'])]).sorted( | ||
key=lambda l: l.order_id.date_order, reverse=True) | ||
self.last_sale_date = lines[:1].order_id.date_order | ||
self.last_sale_price = lines[:1].price_unit | ||
self.last_customer = lines[:1].order_id.partner_id | ||
|
||
last_sale_price = fields.Float( | ||
string='Last Sale Price', compute='_get_last_sale') | ||
last_sale_date = fields.Date( | ||
string='Last Sale Date', compute='_get_last_sale') | ||
last_customer = fields.Many2one( | ||
comodel_name='res.partner', string='Last Customer', | ||
compute='_get_last_sale') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<openerp> | ||
<data> | ||
<record model="ir.ui.view" id="product.product_last_info_page_form_view"> | ||
<field name="name">product.last.info.page.form</field> | ||
<field name="model">product.product</field> | ||
<field name="inherit_id" ref="product.product_normal_form_view" /> | ||
<field name="arch" type="xml"> | ||
<notebook position="inside"> | ||
<page string="Last Price Info"/> | ||
</notebook> | ||
</field> | ||
</record> | ||
|
||
<record model="ir.ui.view" id="product_last_sale_info_form_view"> | ||
<field name="name">product.last.sale.info.form</field> | ||
<field name="model">product.product</field> | ||
<field name="inherit_id" ref="product.product_last_info_page_form_view" /> | ||
<field name="arch" type="xml"> | ||
<page string="Last Price Info" position="inside"> | ||
<group string="Sale" name="last_sale_info"> | ||
<field name="last_customer" /> | ||
<field name="last_sale_date" /> | ||
<field name="last_sale_price" /> | ||
</group> | ||
</page> | ||
</field> | ||
</record> | ||
|
||
</data> | ||
</openerp> |